Commit 2068f14e by 崔彦峰

svn to git

0 parents
Showing 328 changed files with 4829 additions and 0 deletions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-webapp</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>web-dj-wechat</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>web-dj-wechat</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
<version>2.24.0</version>
</dependency>
<dependency>
<groupId>com.zbj.zop</groupId>
<artifactId>rop-client</artifactId>
</dependency>
<dependency>
<groupId>org.oreframework</groupId>
<artifactId>ore-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-swagger</artifactId>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-system-api</artifactId>
<version>0.0.9-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-hardware-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-aibschance-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-kafka-aibschance-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-wechat-api</artifactId>
<version>0.0.3-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>rpc-dj-insure-api</artifactId>
<version>0.0.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-reports-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-customer-api</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-marketing-api</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-gop-api</artifactId>
<version>0.0.4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.wechat;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
/**
* @Title: Main.java
* @Description:
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
@ComponentScan(basePackages = {"com.glsx.ice","cn.com.glsx.dj.wechat"})
@EnableCaching
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.dj.wechat.config;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.MultipartConfigElement;
import org.apache.commons.lang.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.env.Environment;
import org.springframework.core.task.TaskExecutor;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
*
* @Title: BeansConfig.java
* @Description:
* @author zhoulm
* @date 2019年6月3日 下午4:11:04
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Configuration
public class BeansConfig {
final String[] parsePatterns = new String[]{"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss"};
private final static org.slf4j.Logger LOGGER = LoggerFactory.getLogger(BeansConfig.class);
@Bean
public Converter<String, Date> addDateConvertor() {
return new Converter<String, Date>() {
@Override
public Date convert(String source) {
try {
source = URLDecoder.decode(source,"utf-8");
return org.apache.commons.lang.time.DateUtils.parseDate(source, parsePatterns);
} catch (ParseException e) {
// e.printStackTrace();
LOGGER.error("日期解析错误,当前日期为:"+source);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
};
}
@Bean
public Converter<String,Boolean> string2BooleanConverter(){
return new Converter<String,Boolean>(){
@Override
public Boolean convert(String s) {
if(StringUtils.isEmpty(s)){
return false;
}
return Boolean.parseBoolean(s);
}
};
}
@Bean
public Converter<String,String> stringTrimConverter(){
return new Converter<String,String>(){
@Override
public String convert(String s) {
return StringUtils.trim(s);
}
};
}
/**
* 将返回页面的date格式化时间字符串
* @return
*/
@Bean
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
return new Jackson2ObjectMapperBuilderCustomizer() {
@Override
public void customize(Jackson2ObjectMapperBuilder builder) {
builder.dateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
}
};
}
/**
* 上传附件容量限制
*
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize("102400KB");
factory.setMaxRequestSize("112400KB");
return factory.createMultipartConfig();
}
@Bean
public TaskExecutor taskExecutor(){
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(100);
taskExecutor.setMaxPoolSize(200);
taskExecutor.setQueueCapacity(10002);
taskExecutor.setKeepAliveSeconds(300);
return taskExecutor;
}
@Bean(name = "bigDataCenterRop")
public RopProperty bigDateCenterRopProperty(Environment env){
RopProperty ropProperty = new RopProperty();
ropProperty.setAppKey(env.getProperty("bigdata.center.rop.appkey"));
ropProperty.setSecret(env.getProperty("bigdata.center.rop.secret"));
ropProperty.setUrl(env.getProperty("bigdata.center.rop.url"));
return ropProperty;
}
}
package cn.com.glsx.dj.wechat.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
/**
*
* @Title: HttpSessionConfig.java
* @Description:
* @author zhoulm
* @date 2019年6月3日 下午5:51:52
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Configuration
@EnableRedisHttpSession(redisNamespace="web-dj-wechat")
public class HttpSessionConfig {
}
package cn.com.glsx.dj.wechat.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Inherited
@Target({ElementType.METHOD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Privilege {
public static final String NOT_AUTH_MENU = "NOT_AUTH_MENU";
/**
* 是否需要登录
* @return
*/
boolean login() default true;
/**
* 是否需要微信授权
* @return
*/
boolean wechat() default true;
/**
* 是否拥有此菜单地址权限
* @Description:
* @return
* @author zhoulm
* @date 2019年8月14日 下午2:13:41
*/
String menu() default "";
}
package cn.com.glsx.dj.wechat.config;
/**
* @Title: RopProperty.java
* @Description:
* @author zengqi
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
public class RopProperty {
/**
* rop应用key
*/
private String appKey;
/**
* rop秘钥
*/
private String secret;
/**
* rop接口地址
*/
private String url;
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.aibschance.remote.CarCollisionRemote;
import cn.com.glsx.dj.aibschance.remote.CarLossWarningRemote;
import cn.com.glsx.dj.aibschance.remote.CarMaintainRemote;
import cn.com.glsx.dj.aibschance.remote.CarShopWarningRemote;
import cn.com.glsx.dj.aibschance.remote.CollisionNoticeConfigRemote;
import cn.com.glsx.dj.aibschance.remote.CompetitionMerchantRemote;
import cn.com.glsx.dj.aibschance.remote.CompetitionRelRemote;
import cn.com.glsx.dj.aibschance.remote.FollowRecordRemote;
import cn.com.glsx.dj.kafka.aibschance.remote.UpdatePermanentRemote;
/**
* @Title: AinicheManageDubboConfig.java
* @Description: Ai管家Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:35:15
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class AinicheManageDubboConfig extends DubboConfig{
@Bean
public CarCollisionRemote carCollisionRemote(){
return factory.builder(CarCollisionRemote.class).check(check).timeout(timeout).build();
}
@Bean
public CarLossWarningRemote carLossWarningRemote(){
return factory.builder(CarLossWarningRemote.class).check(check).timeout(timeout).build();
}
@Bean
public CarMaintainRemote carMaintainRemote(){
return factory.builder(CarMaintainRemote.class).check(check).timeout(timeout).build();
}
@Bean
public CarShopWarningRemote carShopWarningRemote(){
return factory.builder(CarShopWarningRemote.class).check(check).timeout(timeout).build();
}
@Bean
public CollisionNoticeConfigRemote collisionNoticeConfigRemote() {
return factory.builder(CollisionNoticeConfigRemote.class).check(check).timeout(timeout).build();
}
@Bean
public CompetitionMerchantRemote competitionMerchantRemote(){
return factory.builder(CompetitionMerchantRemote.class).check(false).timeout(timeout).build();
}
@Bean
public CompetitionRelRemote competitionRelRemote(){
return factory.builder(CompetitionRelRemote.class).check(false).timeout(timeout).build();
}
@Bean
public FollowRecordRemote followRecordRemote(){
return factory.builder(FollowRecordRemote.class).check(check).timeout(timeout).build();
}
@Bean
public UpdatePermanentRemote updatePermanentRemote(){
return factory.builder(UpdatePermanentRemote.class).check(false).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.insure.remote.DidiInsureRemote;
import cn.com.glsx.dj.insure.remote.InsuranceAddDeviceConfigRemote;
import cn.com.glsx.dj.insure.remote.InsuranceAddDeviceRecordRemote;
import cn.com.glsx.dj.insure.remote.InsureCardRemote;
import cn.com.glsx.dj.insure.remote.InsureDeviceRemote;
import cn.com.glsx.dj.insure.remote.InsureExportRemote;
import cn.com.glsx.dj.insure.remote.InsureRemote;
import cn.com.glsx.dj.insure.remote.InsureSpecialPromiseCompanyRemote;
import cn.com.glsx.dj.insure.remote.InsureVehicleRemote;
import cn.com.glsx.dj.insure.remote.PromiseRemote;
/**
* @Title: BusinessManageDubboConfig.java
* @Description: 保单业务管理Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:35:26
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class BusinessManageDubboConfig extends DubboConfig{
@Bean
public InsureRemote insureRemote(){
return factory.builder(InsureRemote.class).check(check).timeout(60000).build();
}
@Bean
public InsureDeviceRemote insureDeviceRemote(){
return factory.builder(InsureDeviceRemote.class).check(check).timeout(timeout).build();
}
@Bean
public PromiseRemote promiseRemote() {
return factory.builder(PromiseRemote.class).check(check).timeout(timeout).build();
}
@Bean
public DidiInsureRemote didiInsureRemote() {
return factory.builder(DidiInsureRemote.class).check(false).timeout(timeout).build();
}
@Bean
public InsureVehicleRemote insureVehicleRemote() {
return factory.builder(InsureVehicleRemote.class).check(false).timeout(timeout).build();
}
@Bean
public InsuranceAddDeviceConfigRemote insuranceAddDeviceConfigRemote(){
return factory.builder(InsuranceAddDeviceConfigRemote.class).check(false).timeout(timeout).build();
}
@Bean
public InsureCardRemote insureCardRemote(){
return factory.builder(InsureCardRemote.class).check(false).timeout(timeout).build();
}
@Bean
public InsureSpecialPromiseCompanyRemote insureSpecialPromiseCompanyRemote(){
return factory.builder(InsureSpecialPromiseCompanyRemote.class).check(false).timeout(timeout).build();
}
@Bean
public InsuranceAddDeviceRecordRemote insuranceAddDeviceRecordRemote(){
return factory.builder(InsuranceAddDeviceRecordRemote.class).check(false).timeout(timeout).build();
}
@Bean
public InsureExportRemote insureExportRemote(){
return factory.builder(InsureExportRemote.class).check(false).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.customer.remote.CustomerDeviceRemote;
/**
* @Title: CustomerDubboConfig.java
* @Description: 客户管理Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:35:37
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class CustomerDubboConfig extends DubboConfig{
@Bean
public CustomerDeviceRemote customerDeviceRemote() {
return factory.builder(CustomerDeviceRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
/**
*
* @Title: DubboConfig.java
* @Description:dubbo服务注册配置
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
@Autowired
protected ReferenceBuilderFactory factory;
protected final boolean check = false;
protected final int timeout = 30000;
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.gop.remote.GopAccountRemote;
import cn.com.glsx.dj.gop.remote.GopAddressRemote;
import cn.com.glsx.dj.gop.remote.GopCarInfoRemote;
import cn.com.glsx.dj.gop.remote.GopGpsLocationRemote;
import cn.com.glsx.dj.gop.remote.GopMerchantRemote;
import cn.com.glsx.dj.gop.remote.GopSendSmsRemote;
/**
* @Title: GopDubboConfig.java
* @Description:GOP Dubbo服务注册
* @author zhoulm
* @date 2019年11月19日 上午10:17:45
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Configuration
public class GopDubboConfig extends DubboConfig{
@Bean
public GopAddressRemote gopAddressRemote() {
return factory.builder(GopAddressRemote.class).check(check).timeout(timeout).build();
}
@Bean
public GopSendSmsRemote gopSendSmsRemote() {
return factory.builder(GopSendSmsRemote.class).check(check).timeout(timeout).build();
}
@Bean
public GopAccountRemote gopAccountRemote() {
return factory.builder(GopAccountRemote.class).check(check).timeout(timeout).build();
}
@Bean
public GopMerchantRemote gopMerchantRemote() {
return factory.builder(GopMerchantRemote.class).check(check).timeout(timeout).build();
}
@Bean
public GopCarInfoRemote gopCarInfoRemote() {
return factory.builder(GopCarInfoRemote.class).check(check).timeout(timeout).build();
}
@Bean
public GopGpsLocationRemote gopGpsLocationRemote(){
return factory.builder(GopGpsLocationRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.hardware.remote.MerchantKafkaRemote;
/**
* @Title: HardwareDubboConfig.java
* @Description: 智能硬件Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:57:14
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class HardwareDubboConfig extends DubboConfig {
@Bean
public MerchantKafkaRemote merchantKafkaRemote(){
return factory.builder(MerchantKafkaRemote.class).check(false).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.reports.remote.HomeRemote;
/**
* @Title: HomeManagerDubboConfig.java
* @Description: 首页Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:35:47
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class HomeManagerDubboConfig extends DubboConfig{
@Bean
public HomeRemote homeRemote() {
return factory.builder(HomeRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.marketing.remote.AccountGoodsRemote;
import cn.com.glsx.dj.marketing.remote.MerchantAccountGoodsRemote;
/**
* @Title: MarketingDubboConfig.java
* @Description: 活动营销Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:36:04
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class MarketingDubboConfig extends DubboConfig{
@Bean
public MerchantAccountGoodsRemote merchantAccountGoodsRemote(){
return factory.builder(MerchantAccountGoodsRemote.class).check(false).timeout(timeout).build();
}
@Bean
public AccountGoodsRemote accountGoodsRemote(){
return factory.builder(AccountGoodsRemote.class).check(false).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.system.remote.ChannelConfigRemote;
import cn.com.glsx.dj.system.remote.ConfigRemote;
import cn.com.glsx.dj.system.remote.EmployeeRemote;
import cn.com.glsx.dj.system.remote.FunctionRemote;
import cn.com.glsx.dj.system.remote.LoginLogRemote;
import cn.com.glsx.dj.system.remote.MenuRemote;
import cn.com.glsx.dj.system.remote.MerchantRemote;
import cn.com.glsx.dj.system.remote.OperationLogRemote;
import cn.com.glsx.dj.system.remote.RoleFunctionRemote;
import cn.com.glsx.dj.system.remote.RoleFunctionValueRemote;
import cn.com.glsx.dj.system.remote.RoleMenuRemote;
import cn.com.glsx.dj.system.remote.RoleRemote;
import cn.com.glsx.dj.system.remote.UserRemote;
import cn.com.glsx.dj.system.remote.UserRoleRemote;
/**
* @Title: SystemDubboConfig.java
* @Description: 系统管理Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:36:51
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class SystemDubboConfig extends DubboConfig{
@Bean
public OperationLogRemote operationLogRemote() {
return factory.builder(OperationLogRemote.class).check(check).timeout(timeout).build();
}
@Bean
public RoleRemote roleRemote(){
return factory.builder(RoleRemote.class).check(check).timeout(timeout).build();
}
@Bean
public MenuRemote menuRemote(){
return factory.builder(MenuRemote.class).check(check).timeout(timeout).build();
}
@Bean
public FunctionRemote functionRemote(){
return factory.builder(FunctionRemote.class).check(check).timeout(timeout).build();
}
@Bean
public UserRoleRemote userRoleRemote(){
return factory.builder(UserRoleRemote.class).check(check).timeout(timeout).build();
}
@Bean
public RoleMenuRemote roleMenuRemote(){
return factory.builder(RoleMenuRemote.class).check(false).timeout(30000).build();
}
@Bean
public RoleFunctionValueRemote roleFunctionValueRemote(){
return factory.builder(RoleFunctionValueRemote.class).check(false).timeout(30000).build();
}
@Bean
public RoleFunctionRemote roleFunctionRemote(){
return factory.builder(RoleFunctionRemote.class).check(false).timeout(30000).build();
}
@Bean
public ChannelConfigRemote channelConfigRemote() {
return factory.builder(ChannelConfigRemote.class).check(check).timeout(timeout).build();
}
@Bean
public EmployeeRemote employeeRemote(){
return factory.builder(EmployeeRemote.class).check(check).timeout(timeout).build();
}
@Bean
public MerchantRemote merchantRemote(){
return factory.builder(MerchantRemote.class).check(check).timeout(timeout).build();
}
@Bean
public UserRemote userRemote(){
return factory.builder(UserRemote.class).check(check).timeout(timeout).build();
}
@Bean
public LoginLogRemote loginLogRemote(){
return factory.builder(LoginLogRemote.class).check(check).timeout(timeout).build();
}
@Bean
public ConfigRemote configRemote(){
return factory.builder(ConfigRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.dubbo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.wechat.remote.MerchantWechatAppRemote;
import cn.com.glsx.dj.wechat.remote.MerchantWechatAuthRemote;
import cn.com.glsx.dj.wechat.remote.WeappCodeRemote;
import cn.com.glsx.dj.wechat.remote.WeappCodeTemplateRemote;
import cn.com.glsx.dj.wechat.remote.WeappMemberRemote;
import cn.com.glsx.dj.wechat.remote.WeappVersionInfoRemote;
import cn.com.glsx.dj.wechat.remote.WechatAppAuthorizerInfoRemote;
import cn.com.glsx.dj.wechat.remote.WechatComponentAccessRemote;
import cn.com.glsx.dj.wechat.remote.WechatConfigRemote;
import cn.com.glsx.dj.wechat.remote.WechatH5AuthorizeInfoRemote;
import cn.com.glsx.dj.wechat.remote.WechatMediaRemote;
import cn.com.glsx.dj.wechat.remote.WechatMiniprogramRemote;
import cn.com.glsx.dj.wechat.remote.WechatUserAppRemote;
import cn.com.glsx.dj.wechat.remote.WechatUserInfoRemote;
/**
* @Title: WechatDubboConfig.java
* @Description: 微信授权Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:37:03
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class WechatDubboConfig extends DubboConfig {
/**
* 商户微信授权服务注册
* @return
* @author Alvin
* @date 2019年5月1日 下午6:26:11
*/
@Bean
public MerchantWechatAuthRemote merchantWechatAuthRemote(){
return factory.builder(MerchantWechatAuthRemote.class).check(check).timeout(timeout).build();
}
/**
* 微信小程序服务注册
* @return
* @author Alvin
* @date 2019年5月1日 下午6:26:24
*/
@Bean
public WechatMiniprogramRemote wechatMiniprogramRemote(){
return factory.builder(WechatMiniprogramRemote.class).check(check).timeout(timeout).build();
}
/**
* 微信应用授权信息服务注册
* @return
* @author Alvin
* @date 2019年5月2日 上午10:26:07
*/
@Bean
public WechatAppAuthorizerInfoRemote wechatAppAuthorizerInfoRemote(){
return factory.builder(WechatAppAuthorizerInfoRemote.class).check(check).timeout(timeout).build();
}
/**
* 微信媒体文件管理服务注册
* @return
* @author Alvin
* @date 2019年5月2日 下午1:56:39
*/
@Bean
public WechatMediaRemote wechatMediaRemote(){
return factory.builder(WechatMediaRemote.class).check(check).timeout(timeout).build();
}
/**
* 小程序版本信息服务注册
* @return
* @author Alvin
* @date 2019年5月2日 下午5:41:45
*/
@Bean
public WeappVersionInfoRemote weappVersionInfoRemote(){
return factory.builder(WeappVersionInfoRemote.class).check(check).timeout(timeout).build();
}
/**
* 小程序代码模板服务注册
* @return
* @author Alvin
* @date 2019年5月3日 上午11:44:14
*/
@Bean
public WeappCodeTemplateRemote weappCodeTemplateRemote(){
return factory.builder(WeappCodeTemplateRemote.class).check(check).timeout(timeout).build();
}
/**
* 小程序代码管理服务注册
* @return
* @author Alvin
* @date 2019年5月3日 上午11:44:57
*/
@Bean
public WeappCodeRemote weappCodeRemote(){
return factory.builder(WeappCodeRemote.class).check(check).timeout(timeout).build();
}
/**
* 微信成员管理服务注册
* @return
* @author Alvin
* @date 2019年5月3日 下午4:22:46
*/
@Bean
public WeappMemberRemote weappMemberRemote(){
return factory.builder(WeappMemberRemote.class).check(check).timeout(timeout).build();
}
/**
* 微信第三方平台方服务注册
* @return
* @author Alvin
* @date 2019年5月7日 下午7:32:17
*/
@Bean
public WechatComponentAccessRemote wechatComponentAccessRemote(){
return factory.builder(WechatComponentAccessRemote.class).check(check).timeout(timeout).build();
}
/**
* 商户微信应用管理服务注册
* @return
* @author Alvin
* @date 2019年5月7日 下午7:45:08
*/
@Bean
public MerchantWechatAppRemote merchantWechatAppRemote(){
return factory.builder(MerchantWechatAppRemote.class).check(check).timeout(timeout).build();
}
/**
* 微信网页授权
* @Description:
* @return
* @author zhoulm
* @date 2019年8月9日 下午5:49:11
*/
@Bean
public WechatH5AuthorizeInfoRemote wechatH5AuthorizeInfoRemote(){
return factory.builder(WechatH5AuthorizeInfoRemote.class).check(check).timeout(timeout).build();
}
/**
* 微信用户信息
* @Description:
* @return
* @author zhoulm
* @date 2019年8月12日 下午1:51:23
*/
@Bean
public WechatUserInfoRemote wechatUserInfoRemote(){
return factory.builder(WechatUserInfoRemote.class).check(check).timeout(timeout).build();
}
@Bean
public WechatUserAppRemote wechatUserAppRemote(){
return factory.builder(WechatUserAppRemote.class).check(check).timeout(timeout).build();
}
@Bean
public WechatConfigRemote wechatConfigRemote(){
return factory.builder(WechatConfigRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.wechat.config.tag;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.system.dto.FunctionDTO;
import cn.com.glsx.dj.system.dto.FunctionValueDTO;
import cn.com.glsx.dj.system.dto.MenuDTO;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.LoginUser;
/**
*
* @Title: GlsxWebTagUtil.java
* @Description:
* @author zhoulm
* @date 2019年8月14日 上午9:20:22
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Configuration
public class GlsxWebTagUtil {
public static boolean hasMenuFunction(String menuUrl,String functionAttrName){
LoginUser loginUser = CommonUtil.getLoginUser();
if(loginUser == null){
return false;
}
FunctionDTO function = getMenuFunction(menuUrl, functionAttrName);
return null != function;
}
public static boolean hasMenu(String menuUrl){
LoginUser loginUser = CommonUtil.getLoginUser();
if(loginUser == null){
return false;
}
if(loginUser.getIsSuper() != null && loginUser.getIsSuper()){
return true;
}
return null != getMenu(menuUrl);
}
public static MenuDTO getMenu(String menuUrl){
List<MenuDTO> list = CommonUtil.getLoginUserAuth();
if(CollectionUtils.isEmpty(list)){
return null;
}
for(MenuDTO m:list){
if(m.getUrl().equalsIgnoreCase(menuUrl)){
return m;
}
}
return null;
}
public static FunctionDTO getMenuFunction(String menuUrl,String functionAttrName){
MenuDTO menu = getMenu(menuUrl);
if(menu != null){
List<FunctionDTO> functionList = menu.getFunctionList();
if(CollectionUtils.isEmpty(functionList)){
return null;
}
for(FunctionDTO f:functionList){
if(f.getFunctionAttrName().equalsIgnoreCase(functionAttrName)){
return f;
}
}
}
return null;
}
public static List<FunctionValueDTO> getMenuFunctionValues(String menuUrl,String functionAttrName){
FunctionDTO f = getMenuFunction(menuUrl, functionAttrName);
if(null != f){
return f.getValueList();
}
return null;
}
}
package cn.com.glsx.dj.wechat.constant;
/**
*
* @Title: BaseConstants.java
* @Description:
* @author zhoulm
* @date 2019年9月12日 下午4:48:26
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public interface BaseConstants {
final static String ERRORMSG = "errormsg";
static final String ERROR_URL = "/myerror";
/**
* 设备位置点验证开关开启 on 关闭 off
*/
public final static String DEVICE_LOCATION_ONOFF_ON = "on";
/**
* sms会话编码(值为会话id)
*/
public final static String SMS_SESSION_CODE = "SMS_SESSION_CODE";
/**
* 导出短信验证标示
*/
public final static String EXPORT_SMS_VALIDATE_FLAG = "EXPORT_SMS_VALIDATE";
}
package cn.com.glsx.dj.wechat.constant;
/**
* @Title: CacheKeyConstants.java
* @Description: 缓存键常量
* @author Alvin
* @date 2019年6月28日 上午11:25:12
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
public class CacheKeyConstants {
/**
* 保单序列号缓存key前缀:DJ_SEQ_NO_
*/
public static final String SEQ_NO_CACHE_KEY_PREFIX = "DJ_SEQ_NO_";
}
package cn.com.glsx.dj.wechat.constant;
/**
* 常量类
*
* @author liuyf@didihu.com.cn
* @version 1.0
* @history 2017年9月20日 create by liuyf@didihu.com.cn
*/
public class ReportsConstants {
/**
* remark:每个excel存放的数据量
*/
public static final int POI_DIVISION = 50000;
/**
* 今天
*/
public static final int TIMETYPE_TODAY = 1;
/**
* 昨天
*/
public static final int TIMETYPE_YESTERDAY = 2;
/**
* 本周
*/
public static final int TIMETYPE_THISWEEK = 3;
/**
* 上周
*/
public static final int TIMETYPE_LASTWEEK = 4;
/**
* 本月
*/
public static final int TIMETYPE_THISMONTH = 5;
/**
* 上月
*/
public static final int TIMETYPE_LASTMONTH = 6;
/**
* 今年
*/
public static final int TIMETYPE_YEAR = 14;
/**
* 本季度
*/
public static final int TIMETYPE_CURRENT_QUARTER = 15;
/**
* 展业至今
*/
public static final int TIMETYPE_SOFAR = 16;
/**
* 入库模板
*/
public static final int DEVICE_TEMPLATE_FILE_NAME = 20;
/**
* 厂商ID
*/
public static final String MSJ_FACTORY_ID = "msj";
public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
/**
* dubbo接口常量
* 数据切换之hbase
*/
public static final String HBASE_STRING="hbase";
/**数据切换之hbase备用*/
public static final String HBASE_BACKUP="hbaseBackup";
/**调用ice类型*/
public static final String GPS_TYPE="5";
/**
* 超级管理员的登录id
*/
public final static int ADMIN_LOGINID = 1;
/**
* 傍晚时间
*/
public final static int NIGHT_TIMES = 3;
/**
* 全天
*/
public final static int DATE_TIMES = 4;
/**
* 上午
*/
public final static int PER_TYPE_FORENOON = 1;
/**
* 晚上
*/
public final static int PER_TYPE_NIGHT = 4;
/**
* 全天
*/
public final static int PER_TYPE_DATE = 7;
/**
* 设备位置点验证开关开启 on 关闭 off
*/
public final static String DEVICE_LOCATION_ONOFF_ON = "on";
public final static int RESPONSE_STATUS_CODE_OK = 200;
public final static int RESPONSE_STATUS_CODE_FOUND = 302;
/**
* remark:绑定标识
*/
public static final String APP_BINDING = "1";
/**
* remark:解绑标识
*/
public static final String APP_UNBINDING = "2";
}
package cn.com.glsx.dj.wechat.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import cn.com.glsx.dj.wechat.config.Privilege;
import cn.com.glsx.dj.wechat.model.WechatConfig;
import cn.com.glsx.dj.wechat.util.CommonUtil;
/**
* @Title: IndexController.java
* @Description:
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Controller
public class IndexController {
@RequestMapping("/")
public String hello(Model model) {
return "redirect:/login";
}
@Privilege(login=false)
@RequestMapping(value = "myerror")
public Object error(HttpServletRequest request)throws Exception{
ModelAndView view = new ModelAndView("common/error");
return view;
}
@Privilege(login=false, wechat = false)
@RequestMapping(value = "subscribe")
public Object subscribe(HttpServletRequest request)throws Exception{
ModelAndView view = new ModelAndView("common/subscribe");
WechatConfig wc = CommonUtil.getWechatConfig();
view.addObject("wechatName", wc.getWechatName());
view.addObject("wechatQrcode", wc.getWechatQrcode());
return view;
}
}
package cn.com.glsx.dj.wechat.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import cn.com.glsx.dj.gop.remote.GopSendSmsRemote;
import cn.com.glsx.dj.gop.request.sms.SmsCheckCodeRequest;
import cn.com.glsx.dj.system.dto.LoginTokenDTO;
import cn.com.glsx.dj.system.dto.UserDTO;
import cn.com.glsx.dj.system.remote.UserRemote;
import cn.com.glsx.dj.wechat.config.Privilege;
import cn.com.glsx.dj.wechat.constant.BaseConstants;
import cn.com.glsx.dj.wechat.enums.WechatUserTypeEnum;
import cn.com.glsx.dj.wechat.exception.BusinessException;
import cn.com.glsx.dj.wechat.model.WechatUserInfo;
import cn.com.glsx.dj.wechat.remote.WechatUserInfoRemote;
import cn.com.glsx.dj.wechat.service.IndexService;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.LoginUser;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.StatusEnum;
/**
* @Title: IndexController.java
* @Description:
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Controller("/")
@Privilege(login=false)
public class LoginController {
private final int LOGIN_TOKEN_EXPIRE_TIME = 5 * 60;
@Autowired
private IndexService indexService;
@Autowired
private WechatUserInfoRemote wechatUserInfoRemote;
@Autowired
private GopSendSmsRemote gopSendSmsRemote;
@Autowired
private UserRemote userRemote;
/**
* 默认使用手机加验证码登录
* @Description:
* @param request
* @return
* @author zhoulm
* @date 2020年1月15日 下午3:55:57
*/
@GetMapping("login")
public ModelAndView index(HttpServletRequest request){
String from = request.getParameter("from");
if(CommonUtil.getLoginUser() != null){
if(StringUtils.isNotBlank(from)){
return new ModelAndView("redirect:" + from);
}
return new ModelAndView("redirect:/system/user/index");
}
ModelAndView view = new ModelAndView("login/login");
view.addObject("from", request.getParameter("from"));
view.addObject("channelConfig", CommonUtil.getChannelConfigByRequest());
CommonUtil.getHttpSession().setAttribute(BaseConstants.SMS_SESSION_CODE, CommonUtil.getHttpSession().getId());
return view;
}
/**
* 账号密码登录
* @Description:
* @param request
* @return
* @author zhoulm
* @date 2020年1月15日 下午3:47:25
*/
@GetMapping("loginByAccount")
public ModelAndView loginByAccount(HttpServletRequest request){
String from = request.getParameter("from");
if(CommonUtil.getLoginUser() != null){
if(StringUtils.isNotBlank(from)){
return new ModelAndView("redirect:" + from);
}
return new ModelAndView("redirect:/system/user/index");
}
ModelAndView view = new ModelAndView("login/index");
view.addObject("from", request.getParameter("from"));
view.addObject("channelConfig", CommonUtil.getChannelConfigByRequest());
return view;
}
@PostMapping("/login")
@ResponseBody
public ResultEntity<LoginUser> loginPost(@RequestParam String phone,@RequestParam String password) {
LoginUser loginUser = indexService.login(phone, password);
return ResultEntity.success(loginUser);
}
@GetMapping("logout")
public ModelAndView logout(HttpServletRequest request){
WechatUserInfo wechatUserInfo = CommonUtil.getWechatUserInfo(CommonUtil.getOpenId());
if(wechatUserInfo != null){
WechatUserInfo logoutWechatUserInfo = new WechatUserInfo();
logoutWechatUserInfo.setUnionId(wechatUserInfo.getUnionId());
logoutWechatUserInfo.setUserType(WechatUserTypeEnum.MERCHANT.getValue());
wechatUserInfoRemote.logout(logoutWechatUserInfo);
}
CommonUtil.removeLoginUser();
return new ModelAndView("redirect:/login");
}
@PostMapping("/checkLoginSmsCode")
@ResponseBody
public ResultEntity<Map<String,Object>> checkLoginSmsCode(@RequestParam String phone,@RequestParam String code) {
SmsCheckCodeRequest request = new SmsCheckCodeRequest();
request.setCheckCode(code);
request.setPhone(phone);
Boolean checkResult = gopSendSmsRemote.checkCode(request).getResult();
if(checkResult != null && checkResult){
Integer channelId = null;
// ChannelConfig cc = CommonUtil.getChannelConfigByRequest();
// if(cc != null){
// channelId = cc.getId();
// }
List<UserDTO> list = userRemote.getByPhone(phone,channelId).getResult();
if(CollectionUtils.isNotEmpty(list)){
list = list.stream().filter(item -> StatusEnum.YES.getValue().equals(item.getEnabledFlag())).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(list)){
throw new BusinessException("该手机号暂未绑定此渠道账号");
}
Map<String,Object> data = new HashMap<String,Object>();
data.put("accountCount", list.size());
if(list.size() == 1){
indexService.loginByUserIdAndToken(list.get(0).getId(), null);
}else{
String token = UUID.randomUUID().toString().replace("-", "");
LoginTokenDTO loginToken = new LoginTokenDTO();
loginToken.setPhone(phone);
loginToken.setToken(token);
loginToken.setExpireTime(LOGIN_TOKEN_EXPIRE_TIME);
RpcResponse<LoginTokenDTO> rpcRes = userRemote.saveLoginToken(loginToken);
if(!rpcRes.hasResult()){
throw new BusinessException("服务器异常");
}
data.put("token", token);
}
return ResultEntity.success(data);
}
throw new BusinessException("验证码错误");
}
@GetMapping("selectAccount")
public ModelAndView selectAccount(HttpServletRequest request,@RequestParam String token){
LoginTokenDTO loginTokenDTO = userRemote.getLoginToken(token).getResult();
if(loginTokenDTO == null || StringUtils.isBlank(loginTokenDTO.getPhone())){
throw new BusinessException("验证码已失效");
}
Integer channelId = null;
// ChannelConfig cc = CommonUtil.getChannelConfigByRequest();
// if(cc != null){
// channelId = cc.getId();
// }
List<UserDTO> list = userRemote.getByPhone(loginTokenDTO.getPhone(),channelId).getResult();
if(CollectionUtils.isNotEmpty(list)){
list = list.stream().filter(item -> StatusEnum.YES.getValue().equals(item.getEnabledFlag())).collect(Collectors.toList());
}
if(CollectionUtils.isEmpty(list)){
throw new BusinessException("该手机号未绑定账号");
}
ModelAndView view = new ModelAndView("login/selectAccount");
view.addObject("accountList", list);
view.addObject("token", token);
view.addObject("from", request.getParameter("from"));
return view;
}
@GetMapping("/loginToken")
public ModelAndView loginByPhoneCode(HttpServletRequest request,@RequestParam Integer userId,@RequestParam String token) {
if(StringUtils.isBlank(token)){
throw new BusinessException("参数错误");
}
indexService.loginByUserIdAndToken(userId, token);
String from = request.getParameter("from");
if(StringUtils.isNotBlank(from)){
return new ModelAndView("redirect:" + from);
}
return new ModelAndView("redirect:/system/user/index");
}
}
package cn.com.glsx.dj.wechat.controller.common;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import cn.com.glsx.dj.gop.response.common.CarInfoResponse;
import cn.com.glsx.dj.wechat.service.common.CarService;
import cn.com.glsx.framework.core.beans.ResultEntity;
/**
* @Title CarController
* @Description 车型接口
* @Author zhaojp
* @Date 2019年06月06日 10:04:09
* @Version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
**/
@RestController
@RequestMapping("car")
public class CarController {
@Autowired
private CarService carService;
/**
* 获取车品牌,车子品牌,车系数据
* @return
*/
@RequestMapping("carBrand")
public ResultEntity<List<CarInfoResponse>> getCarBrandInfoList() {
return ResultEntity.success(carService.getCarBrandInfoList());
}
/**
* 仅获取车品牌
* @return
*/
@RequestMapping("onlyCarBrand")
public ResultEntity<List<CarInfoResponse>> getOnlyCarBrandList() {
return ResultEntity.success(carService.getCarBrandInfo());
}
/**
* 根据车系ID获取车型
* @param carSeriesId 车系ID
* @return
*/
@RequestMapping("carType")
public ResultEntity<List<CarInfoResponse>> getCarTypeByCarSeriesId(@RequestParam Integer carSeriesId){
List<CarInfoResponse> carTypeVoList = carService.getCarTypeByCarSeriesId(carSeriesId);
if(carTypeVoList != null && carTypeVoList.size()>0){
return ResultEntity.success(carTypeVoList);
}
return null;
}
}
package cn.com.glsx.dj.wechat.controller.common;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.oreframework.redis.service.RedisService;
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 cn.com.glsx.dj.gop.remote.GopSendSmsRemote;
import cn.com.glsx.dj.wechat.config.Privilege;
import cn.com.glsx.dj.wechat.constant.BaseConstants;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@Privilege(login=false,wechat=false)
@RestController
@RequestMapping(value = "sms")
@Api(value = "sms", tags = "短信")
public class SmsController {
private final String SMS_CODE_PREFIX = "wechat_sms_code_";
@Autowired
private GopSendSmsRemote gopSendSmsRemote;
@Autowired
private RedisService redisService;
@RequestMapping(value = "sendSmsCode", method = {RequestMethod.GET, RequestMethod.POST})
@ApiOperation(value = "发送短信验证码", notes = "发送短信验证码")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone", value = "登录手机号", dataType = "string", required = true)
})
public ResultEntity<Boolean> sendSmsCode(@RequestParam String phone) {
HttpSession session = CommonUtil.getHttpSession();
Object smsSessionCode = session.getAttribute(BaseConstants.SMS_SESSION_CODE);
if(smsSessionCode == null || !session.getId().equals(smsSessionCode.toString())){
return ResultEntity.error("400", "Bad Request");
}
final String key = SMS_CODE_PREFIX.concat(phone);
String value = redisService.get(key);
if(StringUtils.isNotBlank(value)){
return ResultEntity.success(true);
}
RpcResponse<Boolean> res = gopSendSmsRemote.sendSmsCode(phone);
if(res.hasResult()){
redisService.set(key, CommonUtil.getIpAddr(CommonUtil.getRequest()), 60);
}
return ResultEntity.result(res);
}
}
package cn.com.glsx.dj.wechat.controller.customer;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import cn.com.glsx.dj.customer.dto.CustomerDeviceDTO;
import cn.com.glsx.dj.customer.model.CustomerDevice;
import cn.com.glsx.dj.system.enums.ChannelTypeEnum;
import cn.com.glsx.dj.wechat.service.customer.CustomerDeviceService;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.util.DateUtils;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
@Controller
@RequestMapping(value = "/customer/device/", method = { RequestMethod.GET, RequestMethod.POST })
public class CustomerDeviceController {
@Autowired
private CustomerDeviceService customerDeviceService;
@RequestMapping(value="index")
public ModelAndView myCustomers(HttpServletRequest request) {
ModelAndView view = new ModelAndView("customer/device/index");
view.addObject("shares", CommonUtil.getJsWxConfig());
Integer channelType = CommonUtil.getChannelType();
boolean isXianYu = false;
if(channelType != null && channelType == ChannelTypeEnum.XY.getValue()){
isXianYu = true;
}
view.addObject("isXianYu",isXianYu);
return view;
}
@ResponseBody
@RequestMapping(value="listWithPage")
public ResultEntity<RpcPagination<CustomerDeviceDTO>> listWithPage(HttpServletRequest request,RpcPagination<CustomerDeviceDTO> pagination) {
pagination.setPageSize(10);
if(pagination.getCondition() == null){
CustomerDeviceDTO condition = new CustomerDeviceDTO();
pagination.setCondition(condition);
}
Date now = new Date();
pagination.getCondition().setStartDate(DateUtils.formatDate(DateUtils.setFullPassDay1(now)));
pagination.getCondition().setEndDate(DateUtils.formatDate(DateUtils.setFullPassDay(now)));
return ResultEntity.ok(customerDeviceService.list(pagination));
}
@RequestMapping(value = "add")
@ResponseBody
public ResultEntity<CustomerDevice> bind(HttpServletRequest request, CustomerDevice record) {//@RequestParam
return ResultEntity.ok(customerDeviceService.insert(record));
}
}
package cn.com.glsx.dj.wechat.controller.insure;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.glsx.dj.insure.model.InsuranceAddDeviceConfig;
import cn.com.glsx.dj.insure.remote.InsuranceAddDeviceConfigRemote;
import cn.com.glsx.dj.system.model.Merchant;
import cn.com.glsx.dj.system.remote.MerchantRemote;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.LoginUser;
import cn.com.glsx.framework.core.beans.ResultEntity;
/**
*
* @Title: InsureAddDeviceController.java
* @Description:
* @author zhoulm
* @date 2019年9月12日 下午4:48:33
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Controller
@RequestMapping("/insureAddDevice")
public class InsureAddDeviceController {
@Autowired
private InsuranceAddDeviceConfigRemote insuranceAddDeviceConfigRemote;
@Autowired
private MerchantRemote merchantRemote;
/**
* @param config 需要加装设备数
* @return
*/
@ResponseBody
@PostMapping("getNeedAddDeviceCount")
public ResultEntity<Integer> getNeedAddDeviceCount(@ModelAttribute InsuranceAddDeviceConfig config){
LoginUser userInfo = CommonUtil.getLoginUser();
if(config == null || config.getCarBrandId() == null || config.getCarSeriesId() == null ){
return ResultEntity.success(0);
}
Merchant merchant = merchantRemote.getByMerchantId(userInfo.getMerchantId()).getResult();
if(merchant == null || merchant.getProvinceId() == null){
return ResultEntity.success(0);
}
InsuranceAddDeviceConfig c = insuranceAddDeviceConfigRemote.get(merchant.getProvinceId(), config.getCarBrandId(), config.getCarSeriesId()).getResult();
if(c != null){
return ResultEntity.success(c.getMinDeviceCount().intValue());
}
return ResultEntity.success(0);
}
}
package cn.com.glsx.dj.wechat.controller.insure;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.glsx.dj.insure.model.InsureCard;
import cn.com.glsx.dj.insure.remote.InsureCardRemote;
import cn.com.glsx.framework.core.beans.ResultEntity;
/**
*
* @Title: InsureCard.java
* @Description:
* @author zhoulm
* @date 2019年6月28日 下午4:39:33
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Controller
@RequestMapping(value = "/insureCard")
public class InsureCardController {
@Autowired
private InsureCardRemote insureCardRemote;
@GetMapping("getByCode")
@ResponseBody
public ResultEntity<InsureCard> getByCode(@RequestParam String insuranceCode){
InsureCard insureCard = insureCardRemote.getByCode(insuranceCode).getResult();
if(insureCard != null) {
return ResultEntity.success(insureCard);
}
return ResultEntity.error("-1","序列号不存在");
}
}
package cn.com.glsx.dj.wechat.controller.insure;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import cn.com.glsx.dj.reports.dto.ReportsStatisticsDeviceTypeDTO;
import cn.com.glsx.dj.system.enums.UserTypeEnum;
import cn.com.glsx.dj.wechat.enums.ainichemanage.HomePageEnum;
import cn.com.glsx.dj.wechat.enums.ainichemanage.SortTypeEnum;
import cn.com.glsx.dj.wechat.service.insure.InsureReportService;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.util.DateUtils;
import cn.com.glsx.dj.wechat.vo.LoginUser;
import cn.com.glsx.dj.wechat.vo.insure.ShopDataVO;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
/**
*
* @Title: InsureReportController.java
* @Description:
* @author zhoulm
* @date 2019年9月12日 下午4:48:48
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Controller
@RequestMapping("/insureReport")
public class InsureReportController {
private final static Logger LOGGER = LoggerFactory.getLogger(InsureReportController.class);
@Autowired
private InsureReportService insureReportService;
/**
* 盗抢激活报表
*/
@RequestMapping(value = "activateReport")
public ModelAndView activateReport(HttpServletRequest request) {
ModelAndView view = new ModelAndView("insure/activateReport");
return view;
}
@GetMapping("/incrShopDataList")
@ResponseBody
public ResultEntity<List<ShopDataVO>> incrShopDataList(ReportsStatisticsDeviceTypeDTO condition,String month) {
if(StringUtils.isNotBlank(month)){
Date monthFirstDay = DateUtils.parseDate(month + "-01", "yyyy-MM-dd");
Date montLastDay = DateUtils.addDays(DateUtils.addMonths(monthFirstDay, 1), -1);
condition.setStartDate(DateUtils.formatDate(monthFirstDay,"yyyy-MM-dd"));
condition.setEndDate(DateUtils.formatDate(montLastDay,"yyyy-MM-dd"));
}
LOGGER.debug(condition.toString());
condition.setPageSize(1000);
condition.setCurrentPage(1);
condition = setShopDataQuery(condition);
condition = setShopDataDimensionQuery(condition);
condition = setShopDimensionQuery(condition);
LOGGER.info(condition.getDimension()+"=====Dimension");
LOGGER.info(condition.getProvinceMerchantId()+"=====ProvinceMerchantId");
LOGGER.info(condition.getFactoryMerchantId()+"=====FactoryMerchantId");
RpcPagination<ShopDataVO> rpcPagination = insureReportService.incrShopDataList(condition);
return ResultEntity.ok(rpcPagination.getList());
}
public ReportsStatisticsDeviceTypeDTO setShopDataQuery(ReportsStatisticsDeviceTypeDTO condition) {
condition.setMerchantIds(CommonUtil.getMerchantIds());
Date thisDate = new Date();
if(null == condition.getSortType()) {
condition.setSortType(SortTypeEnum.TDL.getValue());
}
if(null == condition.getPeriod()) {
return condition;
}
if(condition.getPeriod() == HomePageEnum.TIMETYPE_TODAY.getValue()) {
condition.setStartDate(DateUtils.formatDateYmd(thisDate) + " 00:00:00");
condition.setEndDate(DateUtils.formatDateYmd(thisDate) + " 23:59:59");
} else if(condition.getPeriod() == HomePageEnum.TIMETYPE_THISWEEK.getValue()) {
Date weekStart = DateUtils.getWeekMonday(thisDate);
Date weekEnd = DateUtils.getWeekSunday(thisDate);
condition.setStartDate(DateUtils.formatDateYmd(weekStart) + " 00:00:00");
condition.setEndDate(DateUtils.formatDateYmd(weekEnd) + " 23:59:59");
} else if(condition.getPeriod() == HomePageEnum.TIMETYPE_THISMONTH.getValue()) {
Date monthStart = DateUtils.getMonthFirstDay(thisDate);
Date monthEnd = DateUtils.getMonthLastDay(thisDate);
condition.setStartDate(DateUtils.formatDateYmd(monthStart) + " 00:00:00");
condition.setEndDate(DateUtils.formatDateYmd(monthEnd) + " 23:59:59");
}
return condition;
}
public ReportsStatisticsDeviceTypeDTO setShopDataDimensionQuery(ReportsStatisticsDeviceTypeDTO condition) {
LoginUser currLoginUser = CommonUtil.getLoginUser();
Byte userType = currLoginUser.getMerchantUserType();
if(userType == UserTypeEnum.EMPLOYEE.getValue()) {
if(null == condition.getDimension()) {
condition.setDimension(2);
}
} else if(userType == UserTypeEnum.MERCHANT.getValue()) {
if(null == condition.getDimension()) {
condition.setDimension(2);
}
} else if(userType == UserTypeEnum.CITY_AGENCY.getValue()) {
if(null == condition.getDimension()) {
condition.setDimension(2);
}
} else if(userType == UserTypeEnum.PROBINCE_AGENCY.getValue()) {
if(null == condition.getDimension()) {
condition.setDimension(3);
}
} else if(userType == UserTypeEnum.SUSSLIER.getValue()) {
if(null == condition.getDimension()) {
condition.setDimension(3);
}
} else if(userType == UserTypeEnum.FACTORY.getValue()) {
if(null == condition.getDimension()) {
if(currLoginUser.getIsSuper()) {
condition.setDimension(5);
} else {
condition.setDimension(4);
}
}
}
return condition;
}
public ReportsStatisticsDeviceTypeDTO setShopDimensionQuery(ReportsStatisticsDeviceTypeDTO condition) {
if(null != condition.getMerchantId()) {
condition.setDimension(2);
} else if(null != condition.getCityMerchantId()) {
condition.setDimension(2);
} else if(null != condition.getProvinceMerchantId()) {
condition.setDimension(3);
} else if(null != condition.getFactoryMerchantId()) {
condition.setDimension(4);
}
return condition;
}
}
package cn.com.glsx.dj.wechat.controller.marketing;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
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.servlet.ModelAndView;
import cn.com.glsx.dj.marketing.model.AccountGoods;
import cn.com.glsx.dj.marketing.model.MerchantAccountGoods;
import cn.com.glsx.dj.marketing.remote.AccountGoodsRemote;
import cn.com.glsx.dj.marketing.remote.MerchantAccountGoodsRemote;
import cn.com.glsx.dj.wechat.config.Privilege;
import cn.com.glsx.dj.wechat.exception.BusinessException;
/**
*
* @Title: MerchantAccountGoodsController.java
* @Description:
* @author zhoulm
* @date 2019年12月3日 下午3:44:12
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Controller
@RequestMapping(value = "/marketing/merchantAccountGoods/", method = { RequestMethod.GET, RequestMethod.POST })
public class MerchantAccountGoodsController {
@Autowired
private MerchantAccountGoodsRemote merchantAccountGoodsRemote;
@Autowired
private AccountGoodsRemote accountGoodsRemote;
@Autowired
private Environment env;
@GetMapping(value = "selectGoods")
@Privilege(login=false,wechat=false)
public ModelAndView selectGoods(@RequestParam int merchantId,String merchantGoodsCode) {
if(StringUtils.isNotBlank(merchantGoodsCode)){
return new ModelAndView("redirect:/marketing/merchantAccountGoods/goodsDetail?merchantGoodsCode=" + merchantGoodsCode);
}
List<MerchantAccountGoods> list = merchantAccountGoodsRemote.getByMerchantId(merchantId).getResult();
if(CollectionUtils.isEmpty(list)){
throw new BusinessException("商户未配置商品信息,请联系客服");
}
if(list.size() == 1){
return new ModelAndView("redirect:/marketing/merchantAccountGoods/goodsDetail?merchantGoodsCode=" + list.get(0).getCode());
}
List<Object> goodsList = new ArrayList<Object>();
for(MerchantAccountGoods mag:list){
AccountGoods accountGoods = accountGoodsRemote.getByGoodsId(mag.getGoodsId()).getResult();
Map<String,Object> map = new HashMap<String,Object>();
map.put("code", mag.getCode());
map.put("goods", accountGoods);
goodsList.add(map);
}
ModelAndView view = new ModelAndView("marketing/merchantAccountGoods/goodsList");
view.addObject("goodsList", goodsList);
return view;
}
@GetMapping(value = "goodsDetail")
@Privilege(login=false,wechat=false)
public ModelAndView goodsDetail(@RequestParam String merchantGoodsCode) {
ModelAndView view = new ModelAndView("marketing/merchantAccountGoods/goodsDetail");
MerchantAccountGoods merchantAccountGoods = merchantAccountGoodsRemote.getByCode(merchantGoodsCode).getResult();
AccountGoods accountGoods = accountGoodsRemote.getByGoodsId(merchantAccountGoods.getGoodsId()).getResult();
if(merchantAccountGoods == null || accountGoods == null){
throw new BusinessException("未配置商品信息,请联系客服");
}
view.addObject("goods", accountGoods);
view.addObject("merchantGoods", merchantAccountGoods);
return view;
}
@GetMapping(value = "toPay")
@Privilege(login=false,wechat=false)
public String toPay(@RequestParam String merchantGoodsCode) {
String url = MessageFormat.format(env.getProperty("merchant.account.goods.qrcode.url"), merchantGoodsCode);
return "redirect:" + url;
}
}
package cn.com.glsx.dj.wechat.controller.report;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
import springfox.documentation.annotations.ApiIgnore;
import cn.com.glsx.dj.wechat.config.Privilege;
import cn.com.glsx.dj.wechat.constant.BaseConstants;
import cn.com.glsx.dj.wechat.service.report.MonthClueReportService;
import cn.com.glsx.dj.wechat.service.system.MerchantService;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.LoginUser;
import cn.com.glsx.dj.wechat.vo.report.BaseConditionVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyExportConditionVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportCoreFactorsVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportInsuranceVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportLossVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportOverviewVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportRescueVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportStockAddVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantBrandVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantCityVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantVO;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.util.DateUtils;
/**
* @Title: MonthClueReportController.java
* @Description:
* @author Alvin
* @date 2020年8月31日 下午4:41:47
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
@Privilege
@Controller
@RequestMapping("clue/report")
@Api(value = "clue/report", tags = "嘀加线索月报")
public class MonthClueReportController {
@Autowired
private MonthClueReportService monthClueReportService;
@Autowired
private MerchantService merchantService;
@Autowired
private Environment env;
@ApiIgnore
@GetMapping("index")
@Privilege(login = false)
public ModelAndView index(){
ModelAndView mv = new ModelAndView("report/clue/index");
LoginUser userInfo = CommonUtil.getLoginUser();
if(userInfo != null){
mv.addObject("merchantName", StringUtils.defaultIfEmpty(userInfo.getMerchantShortName(), userInfo.getMerchantName()));
mv.addObject("userType", userInfo.getUserType());
mv.addObject("isLogin", true);
}else{
mv.addObject("isLogin", false);
}
String month = DateUtils.formatDate(DateUtils.addDate(new Date(), "month", -1), "M");
mv.addObject("month", month);
mv.addObject("videoUrl", env.getProperty("dj.clues.report.introduce.video.url"));
mv.addObject("videoCoverUrl", env.getProperty("dj.clues.report.introduce.videocover.url"));
mv.addObject("monthlyPermeabilityDefine", env.getProperty("dj.clues.report.monthly.permeability.define"));
return mv;
}
@ApiIgnore
@GetMapping("to/index")
@Privilege
public RedirectView toIndex(){
return new RedirectView("/clue/report/index", true, true);
}
/**
* 跳转导出页面
* @return
* @author Alvin
* @date 2020年9月18日 下午2:46:44
*/
@ApiIgnore
@GetMapping("to/export")
public ModelAndView toExport(){
ModelAndView mv = new ModelAndView("report/clue/export");
Object smsValidateFlag = CommonUtil.getHttpSession().getAttribute(BaseConstants.EXPORT_SMS_VALIDATE_FLAG);
// 未验证手机号,跳转到手机验证页面
if(smsValidateFlag == null || !Boolean.valueOf(smsValidateFlag.toString())){
mv.setView(new RedirectView("/clue/report/to/validate", true, true));
}
return mv;
}
/**
* 跳转验证页面
* @return
* @author Alvin
* @date 2020年9月18日 下午2:47:08
*/
@ApiIgnore
@GetMapping("to/validate")
public ModelAndView downLoadExport(){
ModelAndView mv = new ModelAndView("report/clue/validate");
CommonUtil.getHttpSession().setAttribute(BaseConstants.SMS_SESSION_CODE, CommonUtil.getHttpSession().getId());
if(StringUtils.isEmpty(CommonUtil.getLoginUser().getLoginPhone())){
// 未绑定登录手机则跳转到绑定页面
mv.setViewName("system/user/setPhone");
}
Object smsValidateFlag = CommonUtil.getHttpSession().getAttribute(BaseConstants.EXPORT_SMS_VALIDATE_FLAG);
// 已验证手机号,直接跳转到导出页面
if(smsValidateFlag != null && Boolean.valueOf(smsValidateFlag.toString())){
mv.setViewName("report/clue/export");
}
mv.addObject("wechatName", CommonUtil.getWechatConfig().getWechatName());
return mv;
}
@GetMapping("merchant/city/get")
@ResponseBody
@ApiOperation(value = "获取商户城市列表", notes = "获取商户城市列表")
public ResultEntity<List<MerchantCityVO>> getMerchantCity(){
return monthClueReportService.getMerchantCity(CommonUtil.getAllChildMerchantIds());
}
@GetMapping("merchant/brand/get")
@ResponseBody
@ApiOperation(value = "获取商户车辆品牌列表", notes = "获取商户车辆品牌列表")
public ResultEntity<List<MerchantBrandVO>> getMerchantBrand(){
return monthClueReportService.getMerchantBrand(CommonUtil.getAllChildMerchantIds());
}
/**
* 获取子商户
* @return
* @author Alvin
* @date 2020年9月5日 下午4:47:47
*/
@GetMapping("merchant/sub/get")
@ResponseBody
@ApiOperation(value = "获取子商户列表", notes = "获取子商户列表")
public ResultEntity<List<MerchantVO>> getSubMerchant(){
return monthClueReportService.getSubMerchant(CommonUtil.getMerchantId());
}
/**
* 核心因子线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
@GetMapping("corefactors/collect")
@ResponseBody
@ApiOperation(value = "获取核心因子线索月报汇总", notes = "获取核心因子线索月报汇总")
public ResultEntity<CluesMonthlyReportCoreFactorsVO> getCluesMonthlyReportCoreFactors(BaseConditionVO condition){
return monthClueReportService.getCluesMonthlyReportCoreFactors(condition);
}
/**
* 保险线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
@GetMapping("insurance/collect")
@ResponseBody
@ApiOperation(value = "获取保险线索月报汇总", notes = "获取保险线索月报汇总")
public ResultEntity<CluesMonthlyReportInsuranceVO> getCluesMonthlyReportInsurance(BaseConditionVO condition){
return monthClueReportService.getCluesMonthlyReportInsurance(condition);
}
/**
* 流失线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
@GetMapping("loss/collect")
@ResponseBody
@ApiOperation(value = "获取流失线索月报汇总", notes = "获取流失线索月报汇总")
public ResultEntity<CluesMonthlyReportLossVO> getCluesMonthlyReportLoss(BaseConditionVO condition){
return monthClueReportService.getCluesMonthlyReportLoss(condition);
}
/**
* 数据总览月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
@GetMapping("overview/collect")
@ResponseBody
@ApiOperation(value = "获取数据总览月报汇总", notes = "获取数据总览月报汇总")
public ResultEntity<CluesMonthlyReportOverviewVO> getCluesMonthlyReportOverview(BaseConditionVO condition){
return monthClueReportService.getCluesMonthlyReportOverview(condition);
}
/**
* 碰撞送修线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
@GetMapping("rescue/collect")
@ResponseBody
@ApiOperation(value = "获取碰撞送修线索月报汇总", notes = "获取碰撞送修线索月报汇总")
public ResultEntity<CluesMonthlyReportRescueVO> getCluesMonthlyReportRescue(BaseConditionVO condition){
return monthClueReportService.getCluesMonthlyReportRescue(condition);
}
/**
* 存量增值线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
@GetMapping("stockadd/collect")
@ResponseBody
@ApiOperation(value = "获取存量增值线索月报汇总", notes = "获取存量增值线索月报汇总")
public ResultEntity<CluesMonthlyReportStockAddVO> getCluesMonthlyReportStockAdd(BaseConditionVO condition){
return monthClueReportService.getCluesMonthlyReportStockAdd(condition);
}
/**
* 月线索导出
* @param condition
* @return
* @author Alvin
* @date 2020年9月16日 下午4:08:51
*/
@GetMapping("export")
@ResponseBody
@ApiOperation(value = "月线索导出", notes = "月线索导出")
public ResultEntity<String> export(CluesMonthlyExportConditionVO condition){
return monthClueReportService.export(condition);
}
/**
* 短信验证
* @param phone 登录手机号
* @param code 验证码
* @return
* @author Alvin
* @date 2020年9月16日 下午9:01:09
*/
@GetMapping("checksmscode")
@ResponseBody
@ApiOperation(value = "短信验证", notes = "短信验证")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone", value = "登录手机号", dataType = "string", required = true),
@ApiImplicitParam(name = "code", value = "验证码", dataType = "string", required = true)
})
public ResultEntity<String> checkSmsCode(@RequestParam String phone, @RequestParam String code){
ResultEntity<String> result = monthClueReportService.checkSmsCode(phone, code);
if(ResultEntity.SUCCESS.equals(result.getReturnCode())){
CommonUtil.getHttpSession().setAttribute(BaseConstants.EXPORT_SMS_VALIDATE_FLAG, true);
}
return result;
}
}
package cn.com.glsx.dj.wechat.controller.system;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;
import cn.com.glsx.dj.system.enums.UserTypeEnum;
import cn.com.glsx.dj.system.model.Merchant;
import cn.com.glsx.dj.wechat.constant.BaseConstants;
import cn.com.glsx.dj.wechat.service.system.MerchantService;
import cn.com.glsx.dj.wechat.service.system.UserService;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.LoginUser;
import cn.com.glsx.framework.core.beans.ResultEntity;
/**
*
* @Title: UserController.java
* @Description:
* @author zhoulm
* @date 2019年8月9日 上午10:37:24
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Controller
@RequestMapping(value = "/system/user/", method = { RequestMethod.GET, RequestMethod.POST })
@Api(value = "system/user", tags = "用户管理")
public class UserController {
@Autowired
private MerchantService merchantService;
@Autowired
private UserService userService;
/**
* 个人中心
*/
@GetMapping(value = "index")
@ApiIgnore
public ModelAndView index(HttpServletRequest request) {
ModelAndView view = new ModelAndView("system/user/userCenter");
view.addObject("channelConfig", CommonUtil.getChannelConfigByRequest());
return view;
}
/**
* 账号设置
*/
@RequestMapping(value = "setting")
@ApiIgnore
public ModelAndView setting(HttpServletRequest request) {
ModelAndView view = new ModelAndView("system/user/setting");
LoginUser loginUser = CommonUtil.getLoginUser();
view.addObject("merchantInfo", merchantService.getAllInfoByMerchantId(loginUser.getMerchantId()));
return view;
}
/**
* 密码修改页面
* */
@RequestMapping(value = "setPwd", method = { RequestMethod.GET, RequestMethod.POST })
@ApiIgnore
public ModelAndView updatePwd(HttpServletRequest request) {
ModelAndView view = new ModelAndView("system/user/setPwd");
view.addObject("from", request.getParameter("from"));
return view;
}
@RequestMapping("upatePwd")
@ResponseBody
@ApiIgnore
public ResultEntity<Boolean> upatePwd(@RequestParam String oldPwd,String newPwd){
userService.updatePwd(CommonUtil.getLoginUser().getAccountName(), oldPwd, newPwd);
return ResultEntity.success(true);
}
/**
* 直接下级商户
* @param merchantId
* @return
*/
@RequestMapping("getChildMerchant")
@ResponseBody
@ApiIgnore
public ResultEntity<List<Merchant>> getChildMerchant(Integer merchantId){
if(null == merchantId){
if(CommonUtil.isSuperOfCurUser()){
return ResultEntity.success(merchantService.listByUserType(UserTypeEnum.FACTORY.getValue()));
}
merchantId = CommonUtil.getLoginUser().getMerchantId();
}
return ResultEntity.success(merchantService.getChildMerchant(merchantId));
}
/**
* 绑定登录手机号
* @param phone 登录手机号
* @param code 验证码
* @return
* @author Alvin
* @date 2020年9月16日 下午9:54:57
*/
@PostMapping("setPhone")
@ResponseBody
@ApiOperation(value = "绑定登录手机号", notes = "绑定登录手机号")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone", value = "登录手机号", dataType = "string", required = true),
@ApiImplicitParam(name = "code", value = "验证码", dataType = "string", required = true)
})
public ResultEntity<Boolean> setPhone(@RequestParam String phone, @RequestParam String code){
ResultEntity<Boolean> result = userService.bindLoginPhone(phone, code);
if(ResultEntity.SUCCESS.equals(result.getReturnCode())){
CommonUtil.getHttpSession().setAttribute(BaseConstants.EXPORT_SMS_VALIDATE_FLAG, true);
}
return result;
}
}
package cn.com.glsx.dj.wechat.enums;
import java.util.HashMap;
import java.util.Map;
import cn.com.glsx.framework.core.enums.ErrorEnum;
/**
* @Title: ErrorCodeEnum.java
* @Description:
* @author Alvin
* @date 2020年9月16日 下午9:20:51
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
public enum ErrorCodeEnum implements ErrorEnum {
SERVER_ERROR("-1", "服务器异常"),
SERVICE_ERROR("-2", "业务异常"),
VALIDATE_FAILED("-3", "验签失败"),
DATABASE_ERROR("-4", "数据库异常"),
RPC_ERROR("-5", "其他服务调用失败"),
DATA_NULL("-5001", "数据为空"),
LOGIN_PHONE_IS_NULL("-500101", "未绑定手机号"),
DATA_EXIST("-5002", "数据已存在"),
DATA_NOT_EXIST("-5003", "数据不存在"),
DATA_INVALID("-5004", "数据无效"),
PHONE_DATA_INVALID("-500401", "手机号不匹配"),
SMS_CODE_DATA_INVALID("-500402", "验证码错误"),
PARAMETER_NULL("-5005", "参数为空");
private String value;
private String displayName;
static Map<String, ErrorCodeEnum> enumMap = new HashMap<String, ErrorCodeEnum>();
static{
for(ErrorCodeEnum code:ErrorCodeEnum.values()){
enumMap.put(code.getValue(), code);
}
}
ErrorCodeEnum(String value, String displayName){
this.value = value;
this.displayName = displayName;
}
@Override
public String getValue() {
return value;
}
@Override
public String getDisplayName() {
return displayName;
}
public static ErrorCodeEnum getEnum(String value){
return enumMap.get(value);
}
@Override
public String toString() {
return this.name().concat("[value:").concat(getValue()).concat(", displayName:").concat(getDisplayName()).concat("]");
}
}
package cn.com.glsx.dj.wechat.enums;
/**
*
* @Title: MapTypeEnum.java
* @Description:
* @author zhoulm
* @date 2019年6月6日 下午3:10:44
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public enum MapTypeEnum {
/** 高德地图**/
AMAP((byte)1,"高德地图"),
/** GPS**/
GPS((byte)1,"GPS"),
/** 百度地图**/
BAIDU((byte)1,"百度地图"),
/** 图吧地图**/
MAPBAR((byte)1,"图吧地图"),
;
private byte value;
private String text;
MapTypeEnum(byte value,String text){
this.value = value;
this.text = text;
}
public byte getValue() {
return value;
}
public String getText() {
return text;
}
public static MapTypeEnum get(Byte value){
if(null == value){
return null;
}
for(MapTypeEnum e:MapTypeEnum.values()){
if(e.getValue() == value){
return e;
}
}
return null;
}
}
package cn.com.glsx.dj.wechat.enums.ainichemanage;
/**
* @Title: HomePageEnum.java
* @Description:首页相关枚举类
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-05-30 12:11:16
*/
public enum HomePageEnum {
/**
* 小时开始
*/
HOURSTART(1,"小时开始"),
/**
* 小时结束
*/
HOURSED(25,"小时结束"),
/**
* 今天
*/
TIMETYPE_TODAY(1,"今天"),
/**
* 本周
*/
TIMETYPE_THISWEEK(3,"本周"),
/**
* 本月
*/
TIMETYPE_THISMONTH(5,"本月"),
;
private final int value;
private final String name;
HomePageEnum(int value,String name){
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
public static HomePageEnum get(Integer value){
if(value == null){
return null;
}
for(HomePageEnum e:HomePageEnum.values()){
if(e.getValue() == value){
return e;
}
}
return null;
}
}
package cn.com.glsx.dj.wechat.enums.ainichemanage;
/**
* @Title: ShopTypeEnum.java
* @Description:预警点类型枚举类
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-04
*/
public enum ShopTypeEnum {
/**其他 **/
MRD((byte)0,"其他"),
/** 4S店 **/
GZD((byte)1,"4S店"),
/** 维修店 **/
WXD((byte)2,"维修店"),
/** 美容店 **/
SD((byte)3,"美容店"),
/** 改装店 **/
QT((byte)4,"改装店"),
/** 特许店 **/
TXD((byte)5,"特许店"),
/** 综合店 **/
ZHD((byte)6,"综合店");
private Byte num;
private String name;
ShopTypeEnum(Byte num, String name) {
this.num = num;
this.name = name;
}
public int getValue() {
return num;
}
public static ShopTypeEnum getValue(Byte num){
for (ShopTypeEnum enums : ShopTypeEnum.values()){
if(enums.num.intValue() == num){
return enums;
}
}
return null;
}
public String getName() {
return name;
}
}
package cn.com.glsx.dj.wechat.enums.ainichemanage;
/**
*
* @Title: SortTypeEnum.java
* @Description:
* @author zhoulm
* @date 2019年9月12日 下午4:48:56
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public enum SortTypeEnum {
/**
* 提单总量
*/
TDL(5,"提单总量"),
/**
* 云导航
*/
YDH(4,"云导航"),
/**
* 后视镜
*/
HSJ(3,"后视镜"),
/**
* GPS
*/
GPS(2,"GPS"),
/**
* 记录仪
*/
JLY(1,"记录仪")
;
private final int value;
private final String name;
SortTypeEnum(int value,String name){
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
public static SortTypeEnum get(Integer value){
if(value == null){
return null;
}
for(SortTypeEnum e:SortTypeEnum.values()){
if(e.getValue() == value){
return e;
}
}
return null;
}
}
package cn.com.glsx.dj.wechat.exception;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
/**
*
* @Title: BusinessException.java
* @Description:
* @author zhoulm
* @date 2019年6月6日 下午3:11:44
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public class BusinessException extends RuntimeException {
private static final long serialVersionUID = 1L;
private ResultEntity<Object> resultEntity;
public BusinessException(String message) {
super(message);
this.resultEntity = new ResultEntity<Object>();
this.resultEntity.setReturnCode(DefaultErrorEnum.SERVER_ERROR.getValue());
this.resultEntity.setMessage(message);
}
public BusinessException(String errorCode, String message) {
super(message);
this.resultEntity = new ResultEntity<Object>();
this.resultEntity.setReturnCode(errorCode);
this.resultEntity.setMessage(message);
}
public BusinessException(ResultEntity<Object> resultEntity) {
super(resultEntity.getMessage());
this.resultEntity = resultEntity;
this.resultEntity.setReturnCode(DefaultErrorEnum.SERVER_ERROR.getValue());
}
public ResultEntity<Object> getResultEntity() {
return resultEntity;
}
}
package cn.com.glsx.dj.wechat.exception;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
import com.alibaba.dubbo.rpc.RpcException;
import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.dj.wechat.constant.BaseConstants;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
/**
* @Title: ControllerExceptionHandler.java
* @Description: 控制层异常处理
* @author Alvin
* @date 2019年5月2日 上午11:19:16
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@ControllerAdvice
public class ControllerExceptionHandler {
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* 验证异常处理
* @param e
* @return
* @author Alvin
* @date 2019年5月2日 上午11:47:29
*/
@ExceptionHandler({BindException.class, ConstraintViolationException.class, MethodArgumentNotValidException.class})
public ModelAndView validatorExceptionHandler(HttpServletRequest request,Exception e){
logger.error("validator exception:" + e.getMessage(), e);
if(e instanceof BindException){
BindException exception = (BindException) e;
BindingResult bindingResult = exception.getBindingResult();
if(bindingResult.hasErrors()){
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
StringBuilder sb = new StringBuilder();
fieldErrors.forEach(fieldError -> sb.append(fieldError.getDefaultMessage()).append(","));
String errMsg = sb.deleteCharAt(sb.length() - 1).toString().toLowerCase();
return getResult(request,ResultEntity.error(DefaultErrorEnum.VALIDATE_FAILED.getValue(), errMsg));
}
}else if(e instanceof ConstraintViolationException){
ConstraintViolationException exception = (ConstraintViolationException) e;
Set<ConstraintViolation<?>> constraintViolations = exception.getConstraintViolations();
StringBuilder sb = new StringBuilder();
constraintViolations.forEach(violation -> sb.append(violation.getMessage()).append(","));
String errMsg = sb.deleteCharAt(sb.length() - 1).toString().toLowerCase();
return getResult(request,ResultEntity.error(DefaultErrorEnum.VALIDATE_FAILED.getValue(), errMsg));
}else if(e instanceof MethodArgumentNotValidException){
MethodArgumentNotValidException exception = (MethodArgumentNotValidException)e;
BindingResult bindingResult = exception.getBindingResult();
if(bindingResult.hasErrors()){
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
StringBuilder sb = new StringBuilder();
fieldErrors.forEach(fieldError -> sb.append(fieldError.getDefaultMessage()).append(","));
String errMsg = sb.deleteCharAt(sb.length() - 1).toString().toLowerCase();
return getResult(request,ResultEntity.error(DefaultErrorEnum.VALIDATE_FAILED.getValue(), errMsg));
}
}
return getResult(request,ResultEntity.error(DefaultErrorEnum.SERVER_ERROR.getValue(), DefaultErrorEnum.SERVER_ERROR.getDisplayName()));
}
/**
* dubbo异常处理
* @param e
* @return
* @author Alvin
* @date 2019年5月2日 上午11:47:43
*/
@ExceptionHandler({RpcException.class})
public ModelAndView rpcExceptionHandler(HttpServletRequest request,RpcException e){
logger.error("rpc exception:" + e.getMessage(), e);
return getResult(request,ResultEntity.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage()));
}
/**
* 业务异常处理
* @param e
* @return
*/
@ExceptionHandler({BusinessException.class})
public ModelAndView businessExceptionHandler(HttpServletRequest request,BusinessException e){
logger.error("business exception:"+ e.getMessage(), e);
return getResult(request,e.getResultEntity());
}
private ModelAndView getResult(HttpServletRequest request,ResultEntity<Object> r){
if(CommonUtil.isAjaxRequest(request)){
ModelAndView modelAndView=new ModelAndView(new MappingJackson2JsonView(),(JSONObject)JSONObject.toJSON(r));
return modelAndView;
}
ModelAndView mv = new ModelAndView();
request.getSession().setAttribute(BaseConstants.ERRORMSG, r.getMessage());
mv.setViewName("redirect:" + BaseConstants.ERROR_URL);
return mv;
}
/**
* 系统异常
* @param e
* @return
* @author Alvin
* @date 2019年5月9日 上午1:11:26
*/
@ExceptionHandler
public ModelAndView gobalExceptionHandler(HttpServletRequest request,Exception e){
logger.error("gobal exception:"+ e.getMessage(), e);
return getResult(request,ResultEntity.error(DefaultErrorEnum.SERVER_ERROR.getValue(), e.getMessage()));
}
}
package cn.com.glsx.dj.wechat.exception;
/**
*
* @Title: InsuranceBaseException.java
* @Description:
* @author zhoulm
* @date 2019年6月13日 下午9:07:29
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public class InsuranceBaseException extends BusinessException {
private static final long serialVersionUID = 1L;
public InsuranceBaseException(String errorCode, String message ){
super(errorCode,message);
}
public InsuranceBaseException(InsuranceErrorMessage exception, Object ...args){
super(exception.getCode()+"", String.format(exception.getMessage(), args));
}
public static InsuranceBaseException create(String remoteErrorCode, String remoteMessage){
return new InsuranceBaseException(remoteErrorCode,remoteMessage);
}
}
package cn.com.glsx.dj.wechat.exception;
/**
* @author zhoudan
*/
public enum InsuranceErrorMessage {
/**
* 保单错误字典
*/
ARGS_NULL(1, "参数错误,必传参数 [%s]"),
DEVICE_NOT_FOUND(2, "%s 设备未入库,请更换其他设备,并将设备寄回"),
DEVICE_TYPE_NOT_MATCH(3,"所输入的SN与 %s 不匹配,请重新输入"),
DEVICE_IS_ACTIVE(4,"设备 %s 已经激活,不可重复激活,当前绑定的车辆为:%s"),
VEHICLE_NOT_FOUND(5,"车辆未找到,车辆id:%s"),
DEVICE_NOT_CONNECT(6,"设备当前未连接服务器,请检查设备的安装情况"),
LOCAL_INSURANCE_NOT_FOUND(7,"未查到保单数据 序列号:%s"),
NOT_PRINT_INSURANCE(8,"当前保单不支持打印功能,保险公司保单号:%s"),
INSURANCE_STATUS_ERROR(9, "保单状态错误,%s"),
NOT_SUPPORT_INSURANCE_COMPANY(10, "不支持的保险公司:%s"),
EXIST_EQ_STANDNO_INSURANCE(11, "已经存在相同车架号的保单,车架号为:%s"),
FD_INSURANCE_CANCEL_TIME(12,"富德保险退保时间必须在投保之后的5分钟再进行退保"),
DEVICE_IS_ALREADY_INSURE(13,"该设备已投保,请更换设备"),
NOT_DELETE_INSURANCE_AFTER_7DAYS(14,"保单已经不在系统 7 日退保期限内,如需退保请走线下人工退保流程");
private int code;
private String message;
public InsuranceBaseException exception(Object... args) {
return new InsuranceBaseException(this, args);
}
InsuranceErrorMessage(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.wechat.exception;
/**
*
* @Title: SystemErrorException.java
* @Description:
* @author zhoulm
* @date 2019年6月6日 下午3:11:54
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public class SystemErrorException extends Exception {
public SystemErrorException(String message){
super(message);
}
public SystemErrorException(String message,Throwable cause){
super(message,cause);
}
}
package cn.com.glsx.dj.wechat.manager;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import cn.com.glsx.dj.wechat.config.RopProperty;
import cn.com.glsx.dj.wechat.util.rop.RopUtils;
import cn.com.glsx.dj.wechat.vo.report.BaseConditionVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyExportConditionVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportCoreFactorsVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportInsuranceVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportLossVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportOverviewVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportRescueVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportStockAddVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantBrandVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantCityVO;
/**
* @Title: BigDataCenterManager.java
* @Description:
* @author Alvin
* @date 2020年8月31日 下午5:16:22
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
@Component
public class BigDataCenterManager {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource(name = "bigDataCenterRop")
private RopProperty ropProperty;
@Autowired
private RopUtils ropUtils;
/**
* 获取商户城市列表
* @param merchantIds
* @return
* @author Alvin
* @date 2020年9月5日 下午2:03:27
*/
public List<MerchantCityVO> getMerchantCity(List<Integer> merchantIds){
if(CollectionUtils.isEmpty(merchantIds)){
return null;
}
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(16);
try{
params.add("merchantIds", convertMerchantIds(merchantIds));
return ropUtils.builder(ropProperty).postReturnList(params, "bigdata.center.clues.monthly.report.merchant.city.get", "1.0.0", MerchantCityVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 获取商户车辆品牌
* @param merchantIds
* @return
* @author Alvin
* @date 2020年9月5日 下午2:08:40
*/
public List<MerchantBrandVO> getMerchantBrand(List<Integer> merchantIds){
if(CollectionUtils.isEmpty(merchantIds)){
return null;
}
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(16);
try{
params.add("merchantIds", convertMerchantIds(merchantIds));
return ropUtils.builder(ropProperty).postReturnList(params, "bigdata.center.clues.monthly.report.merchant.brand.get", "1.0.0", MerchantBrandVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 核心因子线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public CluesMonthlyReportCoreFactorsVO getCluesMonthlyReportCoreFactors(BaseConditionVO condition){
MultiValueMap<String, String> params = convertToMap(condition);
try{
return ropUtils.builder(ropProperty).post(params, "bigdata.center.clues.monthly.report.corefactors.collect", "1.0.0", CluesMonthlyReportCoreFactorsVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 保险线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public CluesMonthlyReportInsuranceVO getCluesMonthlyReportInsurance(BaseConditionVO condition){
MultiValueMap<String, String> params = convertToMap(condition);
try{
return ropUtils.builder(ropProperty).post(params, "bigdata.center.clues.monthly.report.insurance.collect", "1.0.0", CluesMonthlyReportInsuranceVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 流失线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public CluesMonthlyReportLossVO getCluesMonthlyReportLoss(BaseConditionVO condition){
MultiValueMap<String, String> params = convertToMap(condition);
try{
return ropUtils.builder(ropProperty).post(params, "bigdata.center.clues.monthly.report.loss.collect", "1.0.0", CluesMonthlyReportLossVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 数据总览月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public CluesMonthlyReportOverviewVO getCluesMonthlyReportOverview(BaseConditionVO condition){
MultiValueMap<String, String> params = convertToMap(condition);
try{
return ropUtils.builder(ropProperty).post(params, "bigdata.center.clues.monthly.report.overview.collect", "1.0.0", CluesMonthlyReportOverviewVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 碰撞送修线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public CluesMonthlyReportRescueVO getCluesMonthlyReportRescue(BaseConditionVO condition){
MultiValueMap<String, String> params = convertToMap(condition);
try{
return ropUtils.builder(ropProperty).post(params, "bigdata.center.clues.monthly.report.rescue.collect", "1.0.0", CluesMonthlyReportRescueVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 存量增值线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public CluesMonthlyReportStockAddVO getCluesMonthlyReportStockAdd(BaseConditionVO condition){
MultiValueMap<String, String> params = convertToMap(condition);
try{
return ropUtils.builder(ropProperty).post(params, "bigdata.center.clues.monthly.report.stockadd.collect", "1.0.0", CluesMonthlyReportStockAddVO.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
/**
* 月线索导出
* @param condition
* @return excel访问链接
* @author Alvin
* @date 2020年9月16日 下午3:55:50
*/
public String export(CluesMonthlyExportConditionVO condition){
MultiValueMap<String, String> params = convertToMap(condition);
try{
return ropUtils.builder(ropProperty).get(params, "bigdata.center.clues.monthly.export", "1.0.0", String.class);
}catch(Exception e){
logger.error(e.getMessage(), e);
}finally{
params = null;
}
return null;
}
private MultiValueMap<String, String> convertToMap(BaseConditionVO condition){
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(16);
if(!CollectionUtils.isEmpty(condition.getMerchantIds())){
params.add("merchantIds", convertMerchantIds(condition.getMerchantIds()));
}
if(condition.getMerchantId() != null){
params.add("merchantId", condition.getMerchantId().toString());
}
if(condition.getBrandId() != null){
params.add("brandId", condition.getBrandId().toString());
}
if(condition.getCityId() != null){
params.add("cityId", condition.getCityId().toString());
}
if(StringUtils.isNotEmpty(condition.getMonth())){
params.add("month", condition.getMonth());
}
return params;
}
private String convertMerchantIds(List<Integer> merchantIdList){
if(CollectionUtils.isEmpty(merchantIdList) || merchantIdList.size() == 0){
return null;
}
StringBuffer merchantIds = new StringBuffer();
for(Integer merchantId:merchantIdList){
merchantIds.append(merchantId.toString()).append(",");
}
return merchantIds.toString().substring(0, merchantIds.lastIndexOf(","));
}
}
package cn.com.glsx.dj.wechat.manager;
import cn.com.glsx.dj.wechat.vo.insure.DeviceVo;
import cn.com.glsx.dj.wechat.vo.insure.PhysicalVo;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
/**
*
* @author zhoudan
* @date 2018/1/17
*/
@Service
public class PhysicalDeviceManager {
private static final Logger logger = LoggerFactory.getLogger(PhysicalDeviceManager.class);
/** GPS**/
public static final int DEVICE_TYPE_GPS = 8;
/** 行车记录仪 **/
private static final int DEVICE_TYPE_TRIPREC = 6;
@Autowired
private Environment env;
@Autowired
private YsInsureDeviceManager ysInsureDeviceManager;
/**
* 根据SN号 获取设备分类(大类)ID
* @param sn
* @return
* @throws RpcServiceException
*/
public Integer getDeviceTypeId(String sn){
PhysicalVo physicalDevice = ysInsureDeviceManager.getDeviceInfoBySn(sn);
if(physicalDevice != null){
return physicalDevice.getTypeId();
}
return null;
}
/**
* 判断是否是GPS设备.0
* @param imei
* @return
* @throws RpcServiceException
*/
public boolean isGps(String imei) throws RpcServiceException{
Integer deviceTypeId = this.getDeviceTypeId(imei);
if(deviceTypeId != null && deviceTypeId == DEVICE_TYPE_GPS){
return true;
}
return false;
}
public boolean isGps(PhysicalVo device) throws RpcServiceException{
if(device != null && device.getTypeId() != null && DEVICE_TYPE_GPS == device.getTypeId()){
return true;
}
return false;
}
/**
* 判断是否是TripREC设备下的子设备
* @param
* @return
* @throws RpcServiceException
*/
public boolean isTripREC(String imei) throws RpcServiceException{
Integer deviceTypeId = this.getDeviceTypeId(imei);
if(deviceTypeId != null && deviceTypeId == DEVICE_TYPE_TRIPREC){
return true;
}
return false;
}
public boolean isTripREC(PhysicalVo device) throws RpcServiceException{
if(device != null && DEVICE_TYPE_TRIPREC == device.getTypeId() && device.getDeviceId() != null &&
env.getProperty("physicalDevice.deviceId").equals(device.getDeviceId().toString())){
return true;
}
return false;
}
/**
* 根据设备ID获取设备分类对象
* @param deviceId
* @return DeviceCategory
* @throws RpcServiceException
*/
public DeviceVo getDeviceCategory(Integer deviceId) throws RpcServiceException{
try {
return ysInsureDeviceManager.getDeviceInfoByDeviceId(deviceId);
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
return null;
}
/**
* 根据imeiOrSn获取设备对象
* @param sn 值为imei号或SN号
* @return PhysicalDevice
* @throws RpcServiceException
*/
public PhysicalVo getPhysicalDeviceByImeiorSn(String sn) throws RpcServiceException{
PhysicalVo physicalDevice = null;
try {
physicalDevice = ysInsureDeviceManager.getDeviceInfoBySn(sn);
}catch (Exception e){
logger.error(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR,"调用PhysicalDeviceService.getPhysicalDeviceForMix("+sn+")异常");
}
if(physicalDevice == null){
throw new RpcServiceException(DefaultErrorEnum.DATA_NOT_EXIST,"设备不存在("+sn+")");
}
return physicalDevice;
}
public PhysicalVo getByImeiOrSn(String sn){
PhysicalVo physicalDevice = null;
try {
physicalDevice = ysInsureDeviceManager.getDeviceInfoBySn(sn);
}catch (Exception e){
logger.error(e.getMessage(),e);
}
return physicalDevice;
}
/**
* 根据嘀嘀号查询
* @param userId
* @return
*/
public PhysicalVo getByUserId(Integer userId){
PhysicalVo physicalDevice = null;
try {
physicalDevice = ysInsureDeviceManager.getDeviceInfoByUserId(userId);
}catch (Exception e){
logger.error(e.getMessage(),e);
}
return physicalDevice;
}
}
package cn.com.glsx.dj.wechat.manager;
import cn.com.glsx.dj.wechat.vo.insure.UserBeanVo;
import cn.com.glsx.framework.core.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 获取嘀嘀号
* @author zhoudan
* @date 2018/1/17
*/
@Service
public class ProtocolManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolManager.class);
@Autowired
private YsInsureDeviceManager ysInsureDeviceManager;
public UserBeanVo getUserByCardId(Integer physicalId){
try {
UserBeanVo user = ysInsureDeviceManager.getUserInfoByPhysicalId(physicalId);
return user;
} catch (ServiceException e) {
LOGGER.error(e.getMessage(),e);
}
return null;
}
}
package cn.com.glsx.dj.wechat.manager;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMethod;
import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.dj.wechat.util.gop.GopUtil;
import cn.com.glsx.dj.wechat.vo.insure.DeviceVo;
import cn.com.glsx.dj.wechat.vo.insure.GpsBsRecordVo;
import cn.com.glsx.dj.wechat.vo.insure.PhysicalVo;
import cn.com.glsx.dj.wechat.vo.insure.UserBeanVo;
/**
*
* @author zhoudan
* @date 2019/7/10
*/
@Service
public class YsInsureDeviceManager {
private static final Logger LOGGER = LoggerFactory.getLogger(YsInsureDeviceManager.class);
private static final String REVERSE_URL_ONE = "glsx.accounts.biz.physical.mix";
private static final String REVERSE_URL_TWO = "glsx.accounts.biz.physical.user.primary";
private static final String REVERSE_URL_THREE = "glsx.accounts.biz.device.primary";
private static final String REVERSE_URL_FOUR = "glsx.accounts.biz.user.physical.primary";
private static final String LOCATION_LATEST_SN = "glsx.accounts.biz.location.latest.sn";
@Autowired
private Environment env;
/**
* 通过sn获取设备信息
* @Description:
* @param sn
* @return
* @author zhoudan
* @date 2019年6月10日 下午3:13:56
*/
public PhysicalVo getDeviceInfoBySn(String sn){
try{
if(StringUtils.isBlank(sn)){
throw new NullPointerException("param sn is not null");
}
MultiValueMap<String, String> params = new LinkedMultiValueMap<String,String>();
params.set("sn", sn);
String result = GopUtil.getRequestResult(params,REVERSE_URL_ONE,RequestMethod.GET);
LOGGER.info("method:{},result:{}",REVERSE_URL_ONE,result);
return convertObject(PhysicalVo.class,result);
}catch(Exception e){
LOGGER.error(e.getMessage(),e);
}
return null;
}
/**
* 通过嘀嘀号获取设备信息
* @param userId
* @return
*/
public PhysicalVo getDeviceInfoByUserId(Integer userId){
try{
if(userId == null){
throw new NullPointerException("param userId is not null");
}
MultiValueMap<String, String> params = new LinkedMultiValueMap<String,String>();
params.set("userId", userId.toString());
String result = GopUtil.getRequestResult(params,REVERSE_URL_TWO,RequestMethod.GET);
LOGGER.info("method:{},result:{}",REVERSE_URL_TWO,result);
return convertObject(PhysicalVo.class,result);
}catch(Exception e){
LOGGER.error(e.getMessage(),e);
}
return null;
}
/**
* 通过主键获取设备信息
* @param deviceId
* @return
*/
public DeviceVo getDeviceInfoByDeviceId(Integer deviceId){
try{
if(deviceId == null){
throw new NullPointerException("param deviceId is not null");
}
MultiValueMap<String, String> params = new LinkedMultiValueMap<String,String>();
params.set("deviceId", deviceId.toString());
String result = GopUtil.getRequestResult(params,REVERSE_URL_THREE,RequestMethod.GET);
LOGGER.info("method:{},result:{}",REVERSE_URL_THREE,result);
return convertObject(DeviceVo.class,result);
}catch(Exception e){
LOGGER.error(e.getMessage(),e);
}
return null;
}
/**
* 通过设备主键获取用户信息
* @param physicalId
* @return
*/
public UserBeanVo getUserInfoByPhysicalId(Integer physicalId){
try{
if(physicalId == null){
throw new NullPointerException("param physicalId is not null");
}
MultiValueMap<String, String> params = new LinkedMultiValueMap<String,String>();
params.set("physicalId", physicalId.toString());
String result = GopUtil.getRequestResult(params,REVERSE_URL_FOUR,RequestMethod.GET);
LOGGER.info("method:{},result:{}",REVERSE_URL_FOUR,result);
return convertObject(UserBeanVo.class,result);
}catch(Exception e){
LOGGER.error(e.getMessage(),e);
}
return null;
}
public GpsBsRecordVo getGPSLastingRecordBySN(String sn){
if(StringUtils.isBlank(sn)){
return null;
}
try{
MultiValueMap<String, String> params = new LinkedMultiValueMap<String,String>();
params.set("sn", sn);
params.set("mapType", "2");//谷歌
String result = GopUtil.getRequestResult(params,LOCATION_LATEST_SN,RequestMethod.GET);
LOGGER.info("method:{},result:{}",LOCATION_LATEST_SN,result);
return convertObject(GpsBsRecordVo.class,result);
}catch(Exception e){
LOGGER.error(e.getMessage(),e);
}
return null;
}
/**
* json转换object
* @param clazz
* @param jsonStr
* @param <T>
* @return
*/
private static <T> T convertObject(Class<T> clazz, String jsonStr){
JSONObject json = JSONObject.parseObject(jsonStr);
if(json.getIntValue("code") == 0){
json = json.getJSONObject("data");
T obj = JSONObject.toJavaObject(json,clazz);
return obj;
}
return null;
}
}
package cn.com.glsx.dj.wechat.service;
import org.springframework.stereotype.Service;
/**
* @Title: DemoService.java
* @Description:
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Service
public class DemoService {
}
package cn.com.glsx.dj.wechat.service;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.system.dto.LoginTokenDTO;
import cn.com.glsx.dj.system.enums.LoginTypeEnum;
import cn.com.glsx.dj.system.model.User;
import cn.com.glsx.dj.system.remote.UserRemote;
import cn.com.glsx.dj.wechat.exception.BusinessException;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.LoginUser;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
*
* @Title: IndexService.java
* @Description:
* @author zhoulm
* @date 2019年6月3日 上午9:57:14
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class IndexService {
@Autowired
private UserRemote userRemote;
public LoginUser login(String accountName,String password){
RpcResponse<User> response = userRemote.login(accountName, password);
if(!response.hasResult()){
throw new BusinessException(response.getMessage());
}
LoginUser loginUser = CommonUtil.saveLoginUser(response.getResult());
CommonUtil.addLoginLog(loginUser.getUserId(),accountName,LoginTypeEnum.PASSWORD_LOGIN);
return loginUser;
}
public LoginUser loginByUserIdAndToken(Integer userId,String token){
User user = userRemote.getByUserId(userId).getResult();
if(null == user || StringUtils.isBlank(user.getPhone())){
throw new BusinessException("账号异常");
}
if(StringUtils.isNotBlank(token)){
LoginTokenDTO loginTokenDTO = userRemote.getLoginTokenAndDel(token).getResult();
if(loginTokenDTO == null || StringUtils.isBlank(loginTokenDTO.getPhone())){
throw new BusinessException("长时间未选择登录账号,验证码已失效");
}
if(!user.getPhone().equals(loginTokenDTO.getPhone())){
throw new BusinessException("账号异常");
}
}
LoginUser loginUser = CommonUtil.saveLoginUser(user);
CommonUtil.addLoginLog(loginUser.getUserId(),loginUser.getAccountName(),LoginTypeEnum.PHONE_CODE);
return loginUser;
}
}
package cn.com.glsx.dj.wechat.service.common;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.gop.remote.GopCarInfoRemote;
import cn.com.glsx.dj.gop.response.common.CarInfoResponse;
/**
*
* @Title: CarService.java
* @Description:
* @author zhoulm
* @date 2019年6月6日 下午3:14:05
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class CarService {
@Autowired
private GopCarInfoRemote gopCarInfoRemote;
/**
* 返回车品牌-子品牌-车系
* @return
*/
public List<CarInfoResponse> getCarBrandInfoList() {
return gopCarInfoRemote.getCarBrandList(true).getResult();
}
public List<CarInfoResponse> getCarBrandInfo(){
return gopCarInfoRemote.getCarBrandList(false).getResult();
}
public List<CarInfoResponse> getCarTypeByCarSeriesId(Integer carSeriesId) {
return gopCarInfoRemote.getCarTypeListByCarSeriesId(carSeriesId).getResult();
}
}
package cn.com.glsx.dj.wechat.service.customer;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.customer.dto.CustomerDeviceDTO;
import cn.com.glsx.dj.customer.enums.CustomerDeviceSourceEnum;
import cn.com.glsx.dj.customer.model.CustomerDevice;
import cn.com.glsx.dj.customer.remote.CustomerDeviceRemote;
import cn.com.glsx.dj.insure.enums.DeviceTypeEnum;
import cn.com.glsx.dj.wechat.exception.BusinessException;
import cn.com.glsx.dj.wechat.manager.PhysicalDeviceManager;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.insure.PhysicalVo;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@Service
public class CustomerDeviceService {
@Autowired
private CustomerDeviceRemote customerDeviceRemote;
@Autowired
private PhysicalDeviceManager physicalDeviceManager;
public RpcPagination<CustomerDeviceDTO> list(RpcPagination<CustomerDeviceDTO> pagination) {
pagination.getCondition().setMerchantIds(CommonUtil.getMerchantIds());
RpcResponse<RpcPagination<CustomerDeviceDTO>> response = customerDeviceRemote.listWithPage(pagination);
return response.getResult();
}
public CustomerDevice insert(CustomerDevice record){
if(StringUtils.isBlank(record.getImei())){
throw new BusinessException("IMEI/SN号不能为空");
}
PhysicalVo vo = physicalDeviceManager.getByImeiOrSn(record.getImei());
if(vo == null){
throw new BusinessException("IMEI/SN号不存在!");
}
if(vo.getTypeId() == null || (vo.getTypeId() != DeviceTypeEnum.OBD.getValue().intValue() &&
vo.getTypeId() != DeviceTypeEnum.TRIPREC.getValue().intValue()
&& vo.getTypeId() != DeviceTypeEnum.DVD.getValue().intValue()
&& vo.getTypeId() != DeviceTypeEnum.CAR_CHARGER.getValue().intValue())){
throw new BusinessException("设备类型不符!");
}
record.setDeviceTypeId(vo.getTypeId());
record.setUserId(CommonUtil.getLoginUserId());
record.setCreatedBy(CommonUtil.getLoginUserName());
record.setSource(CustomerDeviceSourceEnum.SCANNER.getValue());
RpcResponse<CustomerDevice> response = customerDeviceRemote.insert(record);
if(response.hasResult()){
return response.getResult();
}
throw new BusinessException(response.getError().getValue(),response.getMessage());
}
}
package cn.com.glsx.dj.wechat.service.insure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.com.glsx.dj.insure.dto.PdfStampRequestDTO;
import cn.com.glsx.dj.insure.enums.InsuranceCompanyEnum;
import cn.com.glsx.dj.insure.enums.InsuranceStatusEnum;
import cn.com.glsx.dj.insure.model.InsureOrder;
import cn.com.glsx.dj.insure.remote.InsureRemote;
import cn.com.glsx.dj.wechat.exception.BusinessException;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
/**
* pdf 预览服务
* @author zhoudan
*/
@Component
public class InsurancePreviewService {
private final static Logger LOGGER = LoggerFactory.getLogger(InsurancePreviewService.class);
@Autowired
private InsuranceService insuranceService;
@Autowired
private InsureRemote insureRemote;
/**
* pdf 预览
* @param insureRequestDTO
*/
public String preview(Long id){
InsureOrder insureOrder = insuranceService.getById(id);
if(insureOrder == null || !InsuranceStatusEnum.INSURE_SUCEESS.getValue().equals(insureOrder.getInsuranceStatus())){
return null;
}
//根据保险公司生成不同的 pdf 预览
PdfStampRequestDTO pdfRequest = new PdfStampRequestDTO();
InsuranceCompanyEnum insuranceCompanyEnum = InsuranceCompanyEnum.getByDisplayName(insureOrder.getCompanyCode());
pdfRequest.setInsuranceCompany(insuranceCompanyEnum.getValue());
pdfRequest.setChannelCode(insureOrder.getChannelCode());
pdfRequest.setProductCode("000001");
pdfRequest.setFullInsuranceNo(insureOrder.getFullInsuranceNo());
RpcResponse<String> pdfStamp;
try{
pdfStamp = insureRemote.pdfStamp(pdfRequest);
}catch (RpcServiceException e){
LOGGER.info(e.getMessage(),e);
throw new BusinessException(e.getMessage());
}
return pdfStamp.getResult();
}
}
package cn.com.glsx.dj.wechat.service.insure;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.insure.dto.InsureSpecialPromiseDTO;
import cn.com.glsx.dj.insure.model.InsureSpecialPromise;
import cn.com.glsx.dj.insure.model.InsureSpecialPromiseCompany;
import cn.com.glsx.dj.insure.remote.InsureSpecialPromiseCompanyRemote;
import cn.com.glsx.dj.insure.remote.PromiseRemote;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
*
* @author zhoudan
* @date 2019/4/29
*/
@Service
public class SpecialPromiseInfoService {
@Autowired
private PromiseRemote promiseRemote;
@Autowired
private InsureSpecialPromiseCompanyRemote promiseCompanyRemote;
public InsureSpecialPromise getById(Long id){
if(id == null){
return null;
}
return promiseRemote.findById(id).getResult();
}
public RpcPagination<InsureSpecialPromiseDTO> listWithPage(RpcPagination<InsureSpecialPromiseDTO> pagination) {
InsureSpecialPromiseDTO condition = pagination.getCondition();
if (condition == null){
condition = new InsureSpecialPromiseDTO();
pagination.setCondition(condition);
}
RpcResponse<RpcPagination<InsureSpecialPromiseDTO>> rpc = promiseRemote.listWithPage(pagination);
if (rpc.hasResult()) {
List<InsureSpecialPromiseDTO> list = rpc.getResult().getList();
for (InsureSpecialPromiseDTO promise : list) {
RpcResponse<List<InsureSpecialPromiseCompany>> response = promiseCompanyRemote.getBySpId(promise.getId());
promise.setCompanyList(response.getResult());
}
}
return rpc.getResult();
}
public RpcResponse<List<InsureSpecialPromiseDTO>> findAllPromiseList(InsureSpecialPromiseDTO condition){
RpcResponse<List<InsureSpecialPromiseDTO>> result = promiseRemote.findAllPromiseExport(condition);
if(result.hasResult()){
return result;
}
return null;
}
public ResultEntity<InsureSpecialPromiseDTO> addSpecialPromiseInfo(InsureSpecialPromiseDTO insureSpecialPromise){
RpcResponse<InsureSpecialPromiseDTO> rpc = promiseRemote.insertRecord(insureSpecialPromise);
if (rpc != null && rpc.hasResult()) {
return ResultEntity.ok(rpc.getResult());
}
return ResultEntity.error(rpc.getMessage());
}
public List<InsureSpecialPromiseDTO> listPromiseByCompanyCode(String companyCode){
if(StringUtils.isBlank(companyCode)){
return null;
}
InsureSpecialPromiseDTO condition = new InsureSpecialPromiseDTO();
return promiseRemote.findAllPromiseExport(condition).getResult();
}
}
package cn.com.glsx.dj.wechat.service.report;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.com.glsx.dj.gop.remote.GopSendSmsRemote;
import cn.com.glsx.dj.gop.request.sms.SmsCheckCodeRequest;
import cn.com.glsx.dj.system.enums.UserTypeEnum;
import cn.com.glsx.dj.system.model.Merchant;
import cn.com.glsx.dj.wechat.enums.ErrorCodeEnum;
import cn.com.glsx.dj.wechat.manager.BigDataCenterManager;
import cn.com.glsx.dj.wechat.service.system.MerchantService;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.report.BaseConditionVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyExportConditionVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportCoreFactorsVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportInsuranceVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportLossVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportOverviewVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportRescueVO;
import cn.com.glsx.dj.wechat.vo.report.CluesMonthlyReportStockAddVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantBrandVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantCityVO;
import cn.com.glsx.dj.wechat.vo.report.MerchantVO;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.util.DateUtils;
/**
* @Title: MonthClueReportService.java
* @Description:
* @author Alvin
* @date 2020年9月5日 下午1:41:49
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
@Component
public class MonthClueReportService {
@Autowired
private BigDataCenterManager bigDataCenterManager;
@Autowired
private MerchantService merchantService;
@Autowired
private GopSendSmsRemote gopSendSmsRemote;
/**
* 获取商户城市列表
* @param merchantIds
* @return
* @author Alvin
* @date 2020年9月5日 下午2:14:40
*/
public ResultEntity<List<MerchantCityVO>> getMerchantCity(List<Integer> merchantIds){
return ResultEntity.success(bigDataCenterManager.getMerchantCity(merchantIds));
}
/**
* 获取商户车辆品牌列表
* @param merchantIds
* @return
* @author Alvin
* @date 2020年9月5日 下午2:14:40
*/
public ResultEntity<List<MerchantBrandVO>> getMerchantBrand(List<Integer> merchantIds){
return ResultEntity.success(bigDataCenterManager.getMerchantBrand(merchantIds));
}
/**
* 获取子商户
* @return
* @author Alvin
* @date 2020年9月5日 下午4:47:47
*/
public ResultEntity<List<MerchantVO>> getSubMerchant(Integer merchantId){
List<MerchantVO> merchantList = new ArrayList<>();
// List<Merchant> childMerchantList = merchantService.getLevelMerchant(merchantId, UserTypeEnum.MERCHANT);
List<Merchant> childMerchantList = merchantService.getAllChildMerchant(merchantId);
if(CollectionUtils.isNotEmpty(childMerchantList)){
// 排除供应商类型商户
List<Merchant> excludeChildMerchantList = childMerchantList.stream().filter(m -> !m.getUserType().equals(UserTypeEnum.SUSSLIER.getValue())).collect(Collectors.toList());
for(Merchant merchant:excludeChildMerchantList){
merchantList.add(new MerchantVO(merchant.getMerchantId(), merchant.getMerchantName()));
}
}
return ResultEntity.success(merchantList);
}
/**
* 核心因子线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public ResultEntity<CluesMonthlyReportCoreFactorsVO> getCluesMonthlyReportCoreFactors(BaseConditionVO condition){
return ResultEntity.success(bigDataCenterManager.getCluesMonthlyReportCoreFactors(setCondition(condition)));
}
/**
* 保险线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public ResultEntity<CluesMonthlyReportInsuranceVO> getCluesMonthlyReportInsurance(BaseConditionVO condition){
return ResultEntity.success(bigDataCenterManager.getCluesMonthlyReportInsurance(setCondition(condition)));
}
/**
* 流失线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public ResultEntity<CluesMonthlyReportLossVO> getCluesMonthlyReportLoss(BaseConditionVO condition){
return ResultEntity.success(bigDataCenterManager.getCluesMonthlyReportLoss(setCondition(condition)));
}
/**
* 数据总览月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public ResultEntity<CluesMonthlyReportOverviewVO> getCluesMonthlyReportOverview(BaseConditionVO condition){
return ResultEntity.success(bigDataCenterManager.getCluesMonthlyReportOverview(setCondition(condition)));
}
/**
* 碰撞送修线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public ResultEntity<CluesMonthlyReportRescueVO> getCluesMonthlyReportRescue(BaseConditionVO condition){
return ResultEntity.success(bigDataCenterManager.getCluesMonthlyReportRescue(setCondition(condition)));
}
/**
* 存量增值线索月报汇总
* @param condition
* @return
* @author Alvin
* @date 2020年9月5日 下午2:36:50
*/
public ResultEntity<CluesMonthlyReportStockAddVO> getCluesMonthlyReportStockAdd(BaseConditionVO condition){
return ResultEntity.success(bigDataCenterManager.getCluesMonthlyReportStockAdd(setCondition(condition)));
}
/**
* 月线索导出
* @param condition
* @return
* @author Alvin
* @date 2020年9月16日 下午4:06:09
*/
public ResultEntity<String> export(CluesMonthlyExportConditionVO condition){
condition = (CluesMonthlyExportConditionVO) setCondition(condition);
return ResultEntity.success(bigDataCenterManager.export(condition));
}
/**
* 验证短信
* @param phone
* @param code
* @return
* @author Alvin
* @date 2020年9月16日 下午9:02:39
*/
public ResultEntity<String> checkSmsCode(String phone, String code){
if(StringUtils.isEmpty(CommonUtil.getLoginUser().getLoginPhone())){
return ResultEntity.error(ErrorCodeEnum.LOGIN_PHONE_IS_NULL.getValue(), ErrorCodeEnum.LOGIN_PHONE_IS_NULL.getDisplayName());
}
if(!CommonUtil.getLoginUser().getLoginPhone().equals(phone)){
return ResultEntity.error(ErrorCodeEnum.PHONE_DATA_INVALID.getValue(), ErrorCodeEnum.PHONE_DATA_INVALID.getDisplayName());
}
SmsCheckCodeRequest request = new SmsCheckCodeRequest();
request.setCheckCode(code);
request.setPhone(phone);
Boolean checkResult = gopSendSmsRemote.checkCode(request).getResult();
if(checkResult == null || !checkResult){
return ResultEntity.error(ErrorCodeEnum.SMS_CODE_DATA_INVALID.getValue(), ErrorCodeEnum.SMS_CODE_DATA_INVALID.getDisplayName());
}
return ResultEntity.success("success");
}
private BaseConditionVO setCondition(BaseConditionVO condition){
if(condition == null){
condition = new BaseConditionVO();
}
//如果前端传了商户号,则设置单个商户到商户列表(查询下级商户)
if(condition.getMerchantId() != null){
condition.setMerchantIds(Arrays.asList(condition.getMerchantId()));
}else{
condition.setMerchantIds(CommonUtil.getAllChildMerchantIds());
}
//登录商户号覆盖传参商户号
condition.setMerchantId(CommonUtil.getMerchantId());
condition.setMonth(DateUtils.formatDate(DateUtils.addDate(new Date(), "month", -1), DateUtils.DEFAULT_DATE_FORMAT8));
return condition;
}
}
package cn.com.glsx.dj.wechat.service.system;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.system.dto.ChannelConfigDTO;
import cn.com.glsx.dj.system.model.ChannelConfig;
import cn.com.glsx.dj.system.remote.ChannelConfigRemote;
import cn.com.glsx.dj.wechat.exception.BusinessException;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
*
* @Title: ChannelConfigService.java
* @Description:
* @author zhoulm
* @date 2019年6月3日 下午3:44:04
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class ChannelConfigService {
private static final Logger LOGGER = LoggerFactory.getLogger(ChannelConfigService.class);
@Autowired
private ChannelConfigRemote channelConfigRemote;
public RpcPagination<ChannelConfigDTO> listWithPage(RpcPagination<ChannelConfigDTO> pagination){
return channelConfigRemote.listWithPage(pagination).getResult();
}
public ChannelConfig insert(ChannelConfig record){
record.setChannelType(CommonUtil.getChannelConfigByRequest().getChannelType());
record.setCreatedBy(CommonUtil.getLoginUser().getAccountName());
RpcResponse<ChannelConfig> response = channelConfigRemote.insert(record);
if(response.hasResult()){
return response.getResult();
}
LOGGER.warn("exception:{},error:{},message:{},result:{}",response.getException(),response.getError(),response.getMessage(),response.getResult());
throw new BusinessException(response.getMessage());
}
public ChannelConfig update(ChannelConfig record){
record.setChannelType(CommonUtil.getChannelConfigByRequest().getChannelType());
record.setUpdatedBy(CommonUtil.getLoginUser().getAccountName());
RpcResponse<ChannelConfig> response = channelConfigRemote.update(record);
if(response.hasResult()){
return response.getResult();
}
LOGGER.warn("exception:{},error:{},message:{},result:{}",response.getException(),response.getError(),response.getMessage(),response.getResult());
throw new BusinessException(response.getMessage());
}
public ChannelConfig getById(Integer id){
RpcResponse<ChannelConfig> response = channelConfigRemote.getById(id);
if(response.hasResult()){
return response.getResult();
}
LOGGER.warn("exception:{},error:{},message:{},result:{}",response.getException(),response.getError(),response.getMessage(),response.getResult());
return null;
}
public ChannelConfigDTO getByWebUrl(String channelWebUrl){
return channelConfigRemote.getByWebUrl(channelWebUrl).getResult();
}
}
package cn.com.glsx.dj.wechat.service.system;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.system.enums.ConfGroupEnum;
import cn.com.glsx.dj.system.model.Config;
import cn.com.glsx.dj.system.remote.ConfigRemote;
import cn.com.glsx.dj.wechat.util.CommonUtil;
/**
*
* @Title: ConfigService.java
* @Description:
* @author zhoulm
* @date 2019年6月3日 下午3:44:08
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class ConfigService {
@Autowired
private ConfigRemote configRemote;
public List<Config> getListByGroup(String confGroup){
if(StringUtils.isEmpty(confGroup)){
return null;
}
Config config = new Config();
config.setConfGroup(confGroup);
return configRemote.selectList(config).getResult();
}
public List<Config> getListByGroupAndName(String confGroup,String confName){
if(StringUtils.isEmpty(confGroup) || StringUtils.isEmpty(confName)){
return null;
}
Config config = new Config();
config.setConfGroup(confGroup);
config.setConfName(confName);
return configRemote.selectList(config).getResult();
}
public List<Config> getListByGroupAndKey(String confGroup,String confKey){
if(StringUtils.isEmpty(confGroup) || StringUtils.isEmpty(confKey)){
return null;
}
Config config = new Config();
config.setConfGroup(confGroup);
config.setConfKey(confKey);
return configRemote.selectList(config).getResult();
}
public Config getOneByGroupAndName(String confGroup,String confName){
List<Config> list = this.getListByGroupAndName(confGroup, confName);
if(list != null && !list.isEmpty()){
return list.get(0);
}
return null;
}
public String getUserTypeName(Byte userType){
if(userType == null){
return null;
}
Config config = configRemote.get(ConfGroupEnum.USER_TYPE_PREFFIX + CommonUtil.getChannelConfigByRequest().getChannelType(), userType.toString()).getResult();
if(config != null){
return config.getConfValue();
}
return null;
}
public List<Config> getAllUserTypeList(){
Config config = new Config();
config.setConfGroup(ConfGroupEnum.USER_TYPE_PREFFIX + CommonUtil.getChannelConfigByRequest().getChannelType());
return configRemote.selectList(config).getResult();
}
public Config getByGroupAndKey(String confGroup,String confKey){
if(StringUtils.isEmpty(confGroup) || StringUtils.isEmpty(confKey)){
return null;
}
return configRemote.get(confGroup, confKey).getResult();
}
}
package cn.com.glsx.dj.wechat.service.system;
import org.oreframework.web.ui.Pagination;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.system.dto.EmployeeDTO;
import cn.com.glsx.dj.system.model.Employee;
import cn.com.glsx.dj.system.remote.EmployeeRemote;
import cn.com.glsx.dj.system.remote.RoleRemote;
import cn.com.glsx.dj.wechat.exception.BusinessException;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
*
* @Title: EmployeeService.java
* @Description:
* @author zhoulm
* @date 2019年6月3日 下午3:44:11
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class EmployeeService {
private static final Logger LOGGER = LoggerFactory.getLogger(EmployeeService.class);
@Autowired
private EmployeeRemote employeeRemote;
@Autowired
private RoleRemote roleRemote;
public Employee updateSelective(Employee record){
Employee e = employeeRemote.updateSelective(record).getResult();
return e;
}
public RpcPagination<EmployeeDTO> list(Pagination pagination, EmployeeDTO condition) {
RpcPagination<EmployeeDTO> rpcPagination = new RpcPagination<EmployeeDTO>();
rpcPagination.setPageNum(pagination.getCurrentPage());
rpcPagination.setPageSize(pagination.getPageSize());
RpcResponse<RpcPagination<EmployeeDTO>> response = employeeRemote.listWithPage(condition, rpcPagination);
for(EmployeeDTO e:response.getResult().getList()){
if(e.getUserId() != null){
e.setRole(roleRemote.getByUserId(e.getUserId()).getResult());
}
}
return response.getResult();
}
public EmployeeDTO getByEmployeeId(Integer employeeId){
RpcResponse<EmployeeDTO> response = employeeRemote.getByEmployeeId(employeeId);
if(response.hasResult()){
return response.getResult();
}
LOGGER.warn("exception:{},error:{},message:{},result:{}",response.getException(),response.getError(),response.getMessage(),response.getResult());
throw new BusinessException(response.getMessage());
}
}
package cn.com.glsx.dj.wechat.service.system;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.gop.remote.GopSendSmsRemote;
import cn.com.glsx.dj.gop.request.sms.SmsCheckCodeRequest;
import cn.com.glsx.dj.system.dto.UserDTO;
import cn.com.glsx.dj.system.enums.UserTypeEnum;
import cn.com.glsx.dj.system.model.User;
import cn.com.glsx.dj.system.model.UserRole;
import cn.com.glsx.dj.system.remote.MerchantRemote;
import cn.com.glsx.dj.system.remote.UserRemote;
import cn.com.glsx.dj.system.remote.UserRoleRemote;
import cn.com.glsx.dj.wechat.enums.ErrorCodeEnum;
import cn.com.glsx.dj.wechat.exception.BusinessException;
import cn.com.glsx.dj.wechat.service.IndexService;
import cn.com.glsx.dj.wechat.util.CommonUtil;
import cn.com.glsx.dj.wechat.vo.LoginUser;
import cn.com.glsx.framework.core.beans.ResultEntity;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
*
* @Title: UserService.java
* @Description:
* @author zhoulm
* @date 2019年5月31日 上午11:04:47
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class UserService {
@Autowired
private UserRoleRemote userRoleRemote;
@Autowired
private UserRemote userRemote;
@Autowired
private IndexService indexService;
@Autowired
private MerchantRemote merchantRemote;
@Autowired
private GopSendSmsRemote gopSendSmsRemote;
public UserDTO getByEmployee(Integer employeeId){
return userRemote.getByEmployeeId(employeeId).getResult();
}
public User getByMerchantId(Integer merchantId){
return userRemote.getByMerchantId(merchantId).getResult();
}
public UserDTO getByUserId(Integer userId){
return userRemote.getByUserId(userId).getResult();
}
public UserRole getRolesByUserId(int userId) {
return userRoleRemote.getByUserId(userId).getResult();
}
public String resetPwd(Integer userId,String newPwd){
User u = new User();
u.setId(userId);
u.setPassword(newPwd);
u.setUpdatedBy(CommonUtil.getLoginUser().getAccountName());
String password = userRemote.updatePassword(u).getResult();
if(StringUtils.isNotBlank(password)){
return password;
}
throw new BusinessException("修改密码失败");
}
public boolean updatePwd(String accountName,String oldPwd,String newPwd){
if(StringUtils.isBlank(accountName) || StringUtils.isBlank(oldPwd) || StringUtils.isBlank(newPwd)){
throw new BusinessException("密码不能为空");
}
User user = userRemote.getByAccountName(accountName).getResult();
if(user == null){
throw new BusinessException("账号不存在");
}
String loginAccount = accountName;
if(UserTypeEnum.EMPLOYEE.getValue() != user.getUserType()){
//非员工平台只支持商户号登录
loginAccount = String.valueOf(user.getMerchantId());
}
LoginUser loginUser = null;
try{
loginUser = indexService.login(loginAccount, oldPwd);
}catch(Exception e){
}
if(loginUser == null){
throw new BusinessException("原密码错误");
}
resetPwd(user.getId(),newPwd);
return true;
}
public User getUserByAccountName(String accountName){
return userRemote.getByAccountName(accountName).getResult();
}
/**
* 绑定登录手机号
* @param phone
* @param code
* @return
* @author Alvin
* @date 2020年9月17日 上午10:02:33
*/
public ResultEntity<Boolean> bindLoginPhone(String phone, String code){
SmsCheckCodeRequest request = new SmsCheckCodeRequest();
request.setCheckCode(code);
request.setPhone(phone);
Boolean checkResult = gopSendSmsRemote.checkCode(request).getResult();
if(checkResult == null || !checkResult){
return ResultEntity.error(ErrorCodeEnum.SMS_CODE_DATA_INVALID.getValue(), ErrorCodeEnum.SMS_CODE_DATA_INVALID.getDisplayName());
}
User user = new User();
LoginUser loginUser = CommonUtil.getLoginUser();
user.setId(loginUser.getUserId());
user.setPhone(phone);
RpcResponse<User> response = userRemote.update(user);
if(response.isSuccess()){
loginUser.setLoginPhone(phone);
CommonUtil.updateLoginUser(loginUser);
return ResultEntity.success(true);
}
return ResultEntity.error(response.getError().getValue(), response.getMessage());
}
}
package cn.com.glsx.dj.wechat.util;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
/**
*
* @Title: CookieUtils.java
* @Description:
* @author zhoulm
* @date 2019年9月12日 下午4:49:08
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public class CookieUtils {
private final static String DEFAULT_KEY = "+this!club#cookie&helper^_^(*.*)+";
private final static String SPLIT = "&&";
public static void setCookie(HttpServletResponse response, String cookieName, String cookieValue) {
if (cookieValue == null) {
cookieValue = "";
}
setCookie(null, response, cookieName, cookieValue);
}
public static void setCookie(HttpServletRequest request, HttpServletResponse response,
String cookieName, String cookieValue) {
setCookie(request, response, cookieName, cookieValue, -1);
}
private static void setCookie(HttpServletRequest request, HttpServletResponse response,
String cookieName, String cookieValue, int cookieMaxage) {
setCookie(request, response, cookieName, cookieValue, cookieMaxage, false);
}
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, boolean isEncode) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, isEncode);
}
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String cookieName) {
doSetCookie(request, response, cookieName, "", -1, false);
}
public static void deleteCookie(HttpServletResponse response, String cookieName) {
doSetCookie(null, response, cookieName, "", -1, false);
}
private final static void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,
String cookieValue, int cookieMaxage, boolean isEncode) {
try {
if (cookieValue != null && cookieValue.equals("")) {
cookieValue = null;
} else if (isEncode) {
cookieValue = URLEncoder.encode(cookieValue, "utf-8");
}
Cookie cookie = new Cookie(cookieName, cookieValue);
if (cookieMaxage > 0) {
cookie.setMaxAge(cookieMaxage);
} else {
if (cookieValue == null){
cookie.setMaxAge(0);
}
}
if (null != request){
cookie.setDomain(getDomainName(request));
}
cookie.setPath("/");
if (isEncode) {
response.setCharacterEncoding("utf-8");
}
// p3p
response.setHeader("P3P", "CP=CAO PSA OUR");
response.addCookie(cookie);
} catch (Exception e) {
}
}
public static String getCookieValue(HttpServletRequest request, String cookieName, boolean isDecoder) {
Cookie[] cookieList = request.getCookies();
if (cookieList == null || cookieName == null){
return null;
}
String retValue = null;
try {
for (int i = 0; i < cookieList.length; i++) {
if (cookieList[i].getName().equals(cookieName)) {
if (isDecoder) {
retValue = URLDecoder.decode(cookieList[i].getValue(), "utf-8");
} else {
retValue = cookieList[i].getValue();
}
break;
}
}
} catch (UnsupportedEncodingException e) {
}
return retValue;
}
public static final String getDomainName(HttpServletRequest request) {
// String domainName = "";
// if (domainName == null || domainName.equals("")) {
// String serverName = request.getServerName();
// String[] nameSplit = serverName.split("\\.");
// if (nameSplit.length > 2) {
// domainName = "." + nameSplit[1] + "." + nameSplit[2];
// } else if (nameSplit.length == 2) {
// domainName = "." + nameSplit[0] + "." + nameSplit[1];
// } else {
// domainName = nameSplit[0];
// }
// }
String domainName = request.getServerName();
return domainName;
}
public static final void setEncryptionCookie(HttpServletRequest request,HttpServletResponse response, String cookieName,String cookieValue, String key,int cookieMaxage) {
if (StringUtils.isEmpty(key)) {
key = DEFAULT_KEY;
}
String signKey = cookieValue + SPLIT + Md5.convert32(key + cookieValue);
setCookie(request, response, cookieName, signKey, cookieMaxage, true);
}
public static final void setEncryptionCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue) {
setEncryptionCookie(request, response, cookieName, cookieValue,DEFAULT_KEY,-1);
}
public static final void setEncryptionCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue,int cookieMaxage) {
setEncryptionCookie(request, response, cookieName, cookieValue,DEFAULT_KEY,cookieMaxage);
}
public static final String getEncryptionCookie(HttpServletRequest request,
String cookieName, String key) {
if (StringUtils.isEmpty(key)) {
key = DEFAULT_KEY;
}
String cookieValue = getCookieValue(request, cookieName, true);
if (cookieValue != null) {
String[] valueSplit = cookieValue.split(SPLIT);
final int valueLenth = 2;
if (valueSplit.length < valueLenth) {
return null;
}
String signKey = valueSplit[0] + SPLIT
+ Md5.convert32(key + valueSplit[0]);
if (signKey.equals(cookieValue)) {
return valueSplit[0];
}
}
return null;
}
public static final String getEncryptionCookie(HttpServletRequest request,
String cookieName) {
return getEncryptionCookie(request, cookieName, DEFAULT_KEY);
}
}
package cn.com.glsx.dj.wechat.util;
import java.security.*;
/**
*
* @Title: MD5.java
* @Description:
* @author zhoulm
* @date 2019年6月6日 下午3:19:12
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public class Md5 {
public static String convert32(String s){
char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
try {
byte[] bytes = s.getBytes();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(bytes);
bytes = md.digest();
int j = bytes.length;
char[] chars = new char[j * 2];
int k = 0;
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
chars[k++] = hexChars[b >>> 4 & 0xf];
chars[k++] = hexChars[b & 0xf];
}
return new String(chars);
}
catch (Exception e){
return null;
}
}
public static String convert16(String s){
char hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
try {
byte[] bytes = s.getBytes();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(bytes);
bytes = md.digest();
int j = bytes.length;
char[] chars = new char[j * 2];
int k = 0;
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
chars[k++] = hexChars[b >>> 4 & 0xf];
chars[k++] = hexChars[b & 0xf];
}
return new String(chars).substring(8, 24);
}
catch (Exception e){
return null;
}
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.wechat.util;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
/**
*
* @Title: NumberUtils.java
* @Description:
* @author zhoulm
* @date 2019年6月13日 下午9:06:43
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
public class NumberUtils {
/**
* remark:计算百分比
*
* @param num1
* @param num2
*/
public static String calculateRate(int num1, int num2) {
if (num2 > 0) {
Double d1 = new Double(num1);
Double d2 = new Double(num2);
double percent = d1 / d2;
NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(2);
return nt.format(percent);
}
return "0.0";
}
/**
* remark:计算百分比
*
* @param num1
* @param num2
*/
public static String calculateRate3(int num1, int num2) {
if (num2 > 0) {
Double d1 = new Double(num1);
Double d2 = new Double(num2);
double percent = d1 / d2;
NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(0);
return nt.format(percent);
}
return "0%";
}
/**
* remark:计算百分比
*
* @param num1
* @param num2
*/
public static String calculateRate5(int num1, int num2,int rate) {
if (num2 > 0) {
Double d1 = new Double(num1);
Double d2 = new Double(num2);
double percent = d1 / d2;
NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(rate);
return nt.format(percent);
}
return "0%";
}
/**
* remark:计算百分比
*
* @param num1
* @param num2
*/
public static String calculateRate4(int num1, int num2) {
if (num2 > 0) {
Double d1 = new Double(num1);
Double d2 = new Double(num2);
double percent = d1 / d2;
DecimalFormat df = new DecimalFormat("#.####");
return df.format(percent);
}
return "0.0000";
}
/**
* remark:保留小数点
*
* @param double num
* @param int rate
*/
public static String deRate2(double num,int rate) {
NumberFormat nt = NumberFormat.getPercentInstance();
nt.setMinimumFractionDigits(rate);
return nt.format(num);
}
/**
* remark:保留小数点
*
* @param double num
* @param int rate
*/
public static String bigDecimalRate(double num,int rate) {
BigDecimal bg = new BigDecimal(num);
double f1 = bg.setScale(rate, BigDecimal.ROUND_HALF_UP).doubleValue();
return f1+"";
}
public static void main(String[] args) {
System.out.println(deRate2(20,2));
}
}
No preview for this file type
This diff could not be displayed because it is too large.
No preview for this file type
This diff could not be displayed because it is too large.
No preview for this file type
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!