From bb3fb7f0bdc1092c40f0c5674960f4b317c6654c Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Mon, 10 May 2021 12:19:44 +0800 Subject: [PATCH] fix neupos --- mallinkNeuPosAdmin/pom.xml | 154 ++++++++ .../com/iformall/NeuPosAdminApplication.java | 75 ++++ .../com/iformall/annotation/AuthIgnore.java | 16 + .../com/iformall/annotation/LoginUser.java | 19 + .../com/iformall/annotation/TenantIgnore.java | 16 + .../iformall/config/MyBatisConfiguration.java | 14 + .../java/com/iformall/config/RedisConfig.java | 335 ++++++++++++++++++ .../com/iformall/config/Swagger2Config.java | 61 ++++ .../com/iformall/config/WebMvcConfig.java | 110 ++++++ .../iformall/controller/BaseController.java | 289 +++++++++++++++ .../controller/NeuPosAdminController.java | 76 ++++ .../BodyReaderHttpServletRequestWrapper.java | 76 ++++ .../HttpServletRequestWrapperFilter.java | 70 ++++ .../interceptor/RequestInterceptor.java | 123 +++++++ .../XssHttpServletRequestWrapper.java | 125 +++++++ ...oginUserHandlerMethodArgumentResolver.java | 48 +++ .../com/iformall/tenant/TenantInfoImpl.java | 151 ++++++++ .../java/com/iformall/utils/ImgIdeaUtil.java | 175 +++++++++ .../java/com/iformall/utils/UrlCheck.java | 14 + .../src/main/resources/application-dev.yml | 184 ++++++++++ .../src/main/resources/application-prod.yml | 139 ++++++++ .../src/main/resources/application.yml | 54 +++ .../src/main/resources/logback-spring.xml | 100 ++++++ .../domain/po/NeuPosOrderMasterExt.java | 5 - .../iformall/service/NeuPosOrderService.java | 17 +- .../service/impl/NeuPosOrderServiceImpl.java | 10 +- .../mapper/NeuPosOrderMasterExtMapper.xml | 2 +- pom.xml | 1 + 28 files changed, 2446 insertions(+), 13 deletions(-) create mode 100644 mallinkNeuPosAdmin/pom.xml create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/NeuPosAdminApplication.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/AuthIgnore.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/LoginUser.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/TenantIgnore.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/config/RedisConfig.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/config/Swagger2Config.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/config/WebMvcConfig.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/controller/BaseController.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/controller/NeuPosAdminController.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/BodyReaderHttpServletRequestWrapper.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/HttpServletRequestWrapperFilter.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/RequestInterceptor.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/XssHttpServletRequestWrapper.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/resolver/LoginUserHandlerMethodArgumentResolver.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/utils/ImgIdeaUtil.java create mode 100644 mallinkNeuPosAdmin/src/main/java/com/iformall/utils/UrlCheck.java create mode 100644 mallinkNeuPosAdmin/src/main/resources/application-dev.yml create mode 100644 mallinkNeuPosAdmin/src/main/resources/application-prod.yml create mode 100644 mallinkNeuPosAdmin/src/main/resources/application.yml create mode 100644 mallinkNeuPosAdmin/src/main/resources/logback-spring.xml diff --git a/mallinkNeuPosAdmin/pom.xml b/mallinkNeuPosAdmin/pom.xml new file mode 100644 index 000000000..3243a872b --- /dev/null +++ b/mallinkNeuPosAdmin/pom.xml @@ -0,0 +1,154 @@ + + + 4.0.0 + + mallink + com.iformall + 1.0 + + + mallinkNeuPosAdmin + + + + com.iformall + mallinkService + 1.0 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + ZIP + + antlr, + cn.afterturn, + ch.qos.logback, + com.alibaba, + com.amazonaws, + com.baomidou, + com.mchange, + com.fasterxml.jackson.core, + com.fasterxml.jackson.dataformat, + com.fasterxml.jackson.datatype, + com.fasterxml.jackson.module, + com.fasterxml.uuid, + com.fasterxml, + com.github.axet, + com.github.jsqlparser, + com.github.pagehelper, + com.github.ulisesbocchio, + com.github.virtuald, + com.google.code.findbugs, + com.google.code.gson, + com.google.errorprone, + com.google.guava, + com.google.protobuf, + com.google.zxing, + com.jayway.jsonpath, + com.jhlabs, + com.puppycrawl.tools, + com.rabbitmq, + com.squareup.okhttp3, + com.squareup.okio, + com.sun, + com.sun.mail, + com.thoughtworks.xstream, + com.zaxxer, + commons-beanutils, + commons-cli, + commons-codec, + commons-collections, + commons-fileupload, + commons-io, + commons-logging, + io.lettuce, + io.netty, + io.projectreactor, + io.springfox, + io.swagger, + io.undertow, + javax.activation, + javax.annotation, + javax.mail, + javax.persistence, + javax.servlet, + javax.validation, + javax.xml.bind, + javax.xml.soap, + javax.xml.ws, + joda-time, + junit, + mysql, + net.bytebuddy, + net.minidev, + net.sf.dozer, + net.sf.saxon, + ognl, + org.antlr, + org.apache.commons, + org.apache.httpcomponents, + org.apache.logging.log4j, + org.apache.poi, + org.apache.poi.wso2, + org.apache.rocketmq, + org.apache.shiro, + org.apache.tomcat.embed, + org.apache.xmlbeans, + org.aspectj, + org.assertj, + org.bouncycastle, + org.checkerframework, + org.codehaus.mojo, + org.crazycake, + org.dom4j, + org.flowable, + org.flywaydb, + org.glassfish, + org.hibernate.validator, + org.jasypt, + org.javassist, + org.jboss.logging, + org.jboss.spec.javax.annotation, + org.jboss.spec.javax.websocket, + org.jboss.xnio, + org.jdom, + org.jodd, + org.jvnet.mimepull, + org.jvnet.staxex, + org.mapstruct, + org.mockito, + org.mybatis, + org.mybatis.generator, + org.mybatis.spring.boot, + org.ow2.asm, + org.projectlombok, + org.quartz-scheduler, + org.reactivestreams, + org.reflections, + org.rocketmq.spring.boot, + org.slf4j, + org.springframework, + org.springframework.amqp, + org.springframework.boot, + org.springframework.data, + org.springframework.retry, + org.springframework.ws, + org.yaml, + redis.clients, + software.amazon.ion, + tk.mybatis, + xmlpull, + xpp3 + + + + + + \ No newline at end of file diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/NeuPosAdminApplication.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/NeuPosAdminApplication.java new file mode 100644 index 000000000..405397ab8 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/NeuPosAdminApplication.java @@ -0,0 +1,75 @@ +package com.iformall; + +import org.mybatis.spring.annotation.MapperScan; +import org.rocketmq.starter.annotation.EnableRocketMQ; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.EnableAspectJAutoProxy; + +import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; + +/** + * @author chenkx + * @date 2017-12-26 + */ +@SpringBootApplication +@MapperScan(basePackages = {"com.iformall.mapper"}) +@EnableEncryptableProperties +@EnableRocketMQ +@EnableAspectJAutoProxy(exposeProxy = true) +public class NeuPosAdminApplication { + + @Value("${fm.exception}") + private boolean fmException; + + @Value("${fm.exception_emails}") + private String fmExceptionEmails; + + @Value("${fm.open}") + private boolean fmOpen; + + @Value("${fm.upload_dir}") + private String uploadDir; + + @Value("${fm.ocr_data}") + private String ocrData; + + @Value("${fm.videoType}") + private String videoType; + + @Bean + public boolean isFmException() { + return fmException; + } + + @Bean + public String fmExceptionEmails() { + return fmExceptionEmails; + } + + @Bean + public boolean isFmOpen() { + return fmOpen; + } + + @Bean + public String fmUploadDir() { + return uploadDir; + } + + @Bean + public String ocrData() { + return ocrData; + } + + @Bean + public String videoType() { + return videoType; + } + + public static void main(String[] args) { + SpringApplication.run(NeuPosAdminApplication.class, args); + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/AuthIgnore.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/AuthIgnore.java new file mode 100644 index 000000000..f8d88a5a2 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/AuthIgnore.java @@ -0,0 +1,16 @@ +package com.iformall.annotation; + +import java.lang.annotation.*; + +/** + * api接口,忽略Token验证 + * @author stormeye.wu + * @email wuguoqiang@iformall.com + * @date 2017-03-23 15:44 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface AuthIgnore { + +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/LoginUser.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/LoginUser.java new file mode 100644 index 000000000..c5dc1646c --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/LoginUser.java @@ -0,0 +1,19 @@ +package com.iformall.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 登录用户信息 + * + * @author stormeye.wu + * @email wuguoqiang@iformall.com + * @date 2017-03-23 20:39 + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface LoginUser { + +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/TenantIgnore.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/TenantIgnore.java new file mode 100644 index 000000000..2623b71e2 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/annotation/TenantIgnore.java @@ -0,0 +1,16 @@ +package com.iformall.annotation; + +import java.lang.annotation.*; + +/** + * api接口,忽略Token验证 + * @author stormeye.wu + * @email wuguoqiang@iformall.com + * @date 2017-03-23 15:44 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface TenantIgnore { + +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java new file mode 100644 index 000000000..af4d6009a --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/MyBatisConfiguration.java @@ -0,0 +1,14 @@ +package com.iformall.config; + +import com.iformall.plugin.MyBatisItercepters; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MyBatisConfiguration extends BaseMyBatisConfiguration { + + @Bean + public MyBatisItercepters intercepters() { + return allIntercepters(); + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/config/RedisConfig.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/RedisConfig.java new file mode 100644 index 000000000..02e61114a --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/RedisConfig.java @@ -0,0 +1,335 @@ +package com.iformall.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.*; +import com.iformall.domain.po.base.BaseCUserEntity; +import com.iformall.domain.vo.WxCouponCVo; +import com.iformall.domain.vo.WxCouponChannelVo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.cache.RedisCacheConfiguration; +import org.springframework.data.redis.cache.RedisCacheManager; +import org.springframework.data.redis.cache.RedisCacheWriter; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by Stormeye on 2018/10/1. + */ +@Configuration +@EnableCaching +public class RedisConfig extends CachingConfigurerSupport { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + //缓存管理器 + @Bean + public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { + //user信息缓存配置 + RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); + Map redisCacheConfigurationMap = new HashMap<>(); + redisCacheConfigurationMap.put("user", userCacheConfiguration); + //初始化一个RedisCacheWriter + RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); + // 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 + // ClassLoader loader = this.getClass().getClassLoader(); + // JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); + // RedisSerializationContext.SerializationPair pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); + // RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); + RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); + //设置默认超过期时间是30秒 + defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); + //初始化RedisCacheManager + RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); + return cacheManager; + } + + @Bean("pushLimitRedisTemplate") + public RedisTemplate getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PushLimit.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("scoreRuleRedisTemplate") + public RedisTemplate getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxScoreRules.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("cuserTokenRedisTemplate") + public RedisTemplate getCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxCUser.class); + + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("baseCUserTokenRedisTemplate") + public RedisTemplate getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(BaseCUserEntity.class); + + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("cUserBasicInfoRedisTemplate") + public RedisTemplate getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxCUserBasicInfo.class); + + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("mallRedisTemplate") + public RedisTemplate getMallRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxMall.class); + + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("subMallListRedisTemplate") + public RedisTemplate> getSubMallListRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate>(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(List.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("couponDetailRedisTemplate") + public RedisTemplate getCouponDetailRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxCouponCVo.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("buserTokenRedisTemplate") + public RedisTemplate getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxBuser.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("pressOrderRedisTemplate") + public RedisTemplate getPressOrderRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(WxOrder.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + + return template; + } + + @Bean("stringValueOperations") + public ValueOperations getStringValueOperations(RedisConnectionFactory connectionFactory) { + StringRedisTemplate template = new StringRedisTemplate(); + template.setConnectionFactory(connectionFactory); + template.afterPropertiesSet(); + return template.opsForValue(); + } + + @Bean("objectCommonRedisTemplate") + public RedisTemplate getObjectValueOperations(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(Object.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + j.setObjectMapper(om); + + // value值的序列化 + template.setValueSerializer(j); + template.setHashValueSerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + template.afterPropertiesSet(); + return template; + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/config/Swagger2Config.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/Swagger2Config.java new file mode 100644 index 000000000..2118b9dbd --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/Swagger2Config.java @@ -0,0 +1,61 @@ +package com.iformall.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.ParameterBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Parameter; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.paths.RelativePathProvider; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import javax.servlet.ServletContext; +import java.util.ArrayList; +import java.util.List; + +//参考:http://blog.csdn.net/catoop/article/details/50668896 +@Configuration +@EnableSwagger2 +public class Swagger2Config { + + @Autowired + private ServletContext servletContext; + + @Bean + public Docket createRestApi() { + ParameterBuilder tokenPar = new ParameterBuilder(); + List pars = new ArrayList(); + //增加一个request的header参数 + tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); + pars.add(tokenPar.build()); + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) + .paths(PathSelectors.any()) + .build() + .globalOperationParameters(pars) + .pathProvider(new RelativePathProvider(servletContext) { + @Override + public String getApplicationBasePath() { + return "/api"; + } + }); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("c端 api") + .description("c api") + .termsOfServiceUrl("http://localhost:7000") + .version("2.0") + .build(); + } + +} \ No newline at end of file diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/config/WebMvcConfig.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/WebMvcConfig.java new file mode 100644 index 000000000..d84dd05ea --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/config/WebMvcConfig.java @@ -0,0 +1,110 @@ +package com.iformall.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationConfig; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.iformall.interceptor.HttpServletRequestWrapperFilter; +import com.iformall.interceptor.RequestInterceptor; +import com.iformall.resolver.LoginUserHandlerMethodArgumentResolver; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.*; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.text.SimpleDateFormat; +import java.util.List; + +/** + * MVC配置 + * + * @author stormeye.wu + * @email wugq@mippoint.com + * @date 2017-04-20 22:30 + */ +@Configuration +@EnableWebMvc +public class WebMvcConfig implements WebMvcConfigurer { + @Autowired + private RequestInterceptor requestInterceptor; + @Autowired + private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(requestInterceptor).addPathPatterns("/api/**"); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + argumentResolvers.add(loginUserHandlerMethodArgumentResolver); + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + //registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/"); + + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/api/**") + .allowedOrigins("*") + .allowCredentials(true) + .allowedMethods("GET", "POST", "DELETE", "PUT") + .maxAge(3600); + } + + @Override + public void configureMessageConverters(List> converters) { + MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); + //ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 + ObjectMapper objectMapper = new ObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); + + //不显示为null的字段 + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + + DeserializationConfig dc = objectMapper.getDeserializationConfig(); + // 设置反序列化日期格式、忽略不存在get、set的属性 + objectMapper.setConfig( + dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) + .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + ); + //序列化将Long转String类型 + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + SimpleModule bigIntegerModule = new SimpleModule(); + //序列化将BigInteger转String类型 + bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); + SimpleModule bigDecimalModule = new SimpleModule(); + //序列化将BigDecimal转String类型 + bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + objectMapper.registerModule(bigDecimalModule); + objectMapper.registerModule(bigIntegerModule); + jackson2HttpMessageConverter.setObjectMapper(objectMapper); + converters.add(jackson2HttpMessageConverter); + } + + @Bean + public FilterRegistrationBean Filters() { + FilterRegistrationBean registrationBean = new FilterRegistrationBean(); + registrationBean.setFilter(new HttpServletRequestWrapperFilter()); + registrationBean.addUrlPatterns("/*"); + registrationBean.setName("koalaSignFilter"); + return registrationBean; + } +} \ No newline at end of file diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/controller/BaseController.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/controller/BaseController.java new file mode 100644 index 000000000..24d20038b --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/controller/BaseController.java @@ -0,0 +1,289 @@ +package com.iformall.controller; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import com.iformall.common.ErrorCode; +import com.iformall.common.IdWorker; +import com.iformall.domain.po.WxCUserBasicChild; +import com.iformall.domain.po.base.BaseCUserEntity; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.po.WxAppinfo; +import com.iformall.domain.po.WxCUser; +import com.iformall.domain.po.WxCUserBasicInfo; +import com.iformall.exception.MallinkException; +import com.iformall.service.CUserTokenService; +import com.iformall.service.WxAppinfoService; +import com.iformall.service.WxCUserBasicChildService; +import com.iformall.service.WxCUserBasicInfoService; +import com.iformall.service.wechat.FmOpenService; +import com.iformall.utils.Constant; +import com.iformall.utils.IPUtil; +import com.iformall.utils.MaUtil; +import com.iformall.utils.RedisCacheUtils; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.beans.PropertyEditorSupport; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +@RestController +public class BaseController { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private boolean isFmOpen; + + @Autowired + private WxAppinfoService wxAppinfoService; + + @Autowired + private FmOpenService openService; + + @Autowired + private WxCUserBasicInfoService wxCUserBasicInfoService; + + @Autowired + private WxCUserBasicChildService wxCUserBasicChildService; + + @Autowired + private CUserTokenService cUserTokenService; + + @Autowired + @Qualifier("objectCommonRedisTemplate") + RedisTemplate objectCommonRedisTemplate; + + @InitBinder + public void InitBinder(WebDataBinder dataBinder) { + dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { + public void setAsText(String value) { + try { + setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); + } catch (ParseException e) { + try { + setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); + } catch (ParseException e1) { + setValue(null); + } + } + } + + public String getAsText() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); + } + + }); + } + + @Deprecated + public String getTenantId() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String tenantId = (String) request.getAttribute(Constant.TENANT_ID); + return tenantId; + } + + public TenantEntity getTenantInfo() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String tenantId = (String) request.getAttribute(Constant.TENANT_ID); + String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID); + TenantEntity tenantEntity = new TenantEntity() ; + tenantEntity.setTenantId(tenantId); + tenantEntity.setParentTenantId(parentTenantId); + return tenantEntity; + } + + public String getFinalTenantId() { + TenantEntity tenantEntity = getTenantInfo(); + return tenantEntity.getFinalTenantId(); + } + + public Long getMemberId() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + Long memberId = (Long) request.getAttribute(Constant.LOGIN_MEMBER_KEY); + if(memberId == null){ + throw new MallinkException(ErrorCode.USER_IS_NOT_MEMBER); + } + return memberId; + } + + /** + * 微信端获取当前用户 wx_c_user,非会员 + * 请尽量多用getTenantId, getUserId + */ + public WxCUser getWxCUser() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY); + + if (baseuser == null) { + throw new MallinkException(ErrorCode.USER_IS_EMPTY); + } + if (baseuser.getRealUser() == null) { + throw new MallinkException(ErrorCode.USER_IS_EMPTY); + } + WxCUser user = RedisCacheUtils.getFieldObject(baseuser, "realUser", WxCUser.class); + TenantEntity tenantEntity = getTenantInfo(); + if (user.getTenantId() == null) { + user.setTenantId(tenantEntity.getTenantId()); + } + if (user.getParentTenantId() == null) { + user.setParentTenantId(tenantEntity.getParentTenantId()); + } + return user; + } + + public void removeCacheCUser() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY); + cUserTokenService.removeTokenCache(baseuser.getToken()); + } + + public void updateCacheCUser(String token,Object cuser) { + cUserTokenService.updateTokenCache(token, cuser); + } + + private WxCUserBasicInfo getCacheMember(Long memberId,String finalTenantId,String key,long seconds) throws MallinkException { + // 缓存 + WxCUserBasicInfo member = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, key, WxCUserBasicInfo.class); + if(null == member) { + member = wxCUserBasicInfoService.getById(memberId,finalTenantId); + if (member == null) { + throw new MallinkException(ErrorCode.USER_IS_EMPTY); + } + setCUserBasicChild(member); + + RedisCacheUtils.cache(objectCommonRedisTemplate, key, member, seconds); + } + return member; + } + + public WxCUserBasicInfo getCacheMember() throws MallinkException { + Long memberId = getMemberId(); + String key = "webapp:member:"+memberId; + return getCacheMember(memberId,getFinalTenantId(), key, 3600*24*3); + } + + /*此处缓存短暂时间,因为积分、成长值记录*/ + public WxCUserBasicInfo getShortCacheMember(Long memberId,String finalTenantId) throws Exception { + String key = "webapp:short:member:"+memberId; + return getCacheMember(memberId,finalTenantId, key, 100); + } + + public void removeCacheMember(Long memberId) { + String key = "webapp:member:"+memberId; + RedisCacheUtils.removeCache(objectCommonRedisTemplate, key); + String shortKey = "webapp:short:member:"+memberId; + RedisCacheUtils.removeCache(objectCommonRedisTemplate, shortKey); + } + + public WxAppinfo getAppInfo(String appId) { + return wxAppinfoService.getByAppId(appId); + } + + public WxMaService getWeappService(String appId) { + if(isFmOpen) { + return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); + } else { + WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); + if (appinfo == null) { + return null; + } + WxMaService service = MaUtil.getWeappService(appinfo); + return service; + } + + } + + public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { + if(!isFmOpen) { + WxMaService service = MaUtil.getWeappService(appinfo); + return service; + } + return null; + } + + + public Long saveToBasicInfoByCUser(String userPhone,String userName,String avatarUrl,Integer sex,Long userId) { + TenantEntity tenantEntity = getTenantInfo(); + if (StringUtils.isBlank(userPhone)) + return null; + + WxCUserBasicInfo byId = null; + if (null != userId) { + byId = wxCUserBasicInfoService.getById(userId,getFinalTenantId()); + } + + WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(tenantEntity, userPhone); + + if (basicInfo != null) { + if (byId != null) { + if (!byId.getId().equals(basicInfo.getId())) { + //数据库存在此手机号的会员,并且当前微信存在另一手机号会员 + logger.error("会员" + userId + "更换手机号时,当前手机号会员表已存在:" + userPhone); + return Long.valueOf(-1); + } + } + if (!basicInfo.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { + basicInfo.setTenantId(basicInfo.getTenantId() + tenantEntity.getTenantId() + ","); + } + basicInfo.setNickName(userName); + basicInfo.setAvatarUrl(avatarUrl); + basicInfo.setSex(sex); + wxCUserBasicInfoService.update(basicInfo); + removeCacheMember(basicInfo.getId()); + return basicInfo.getId(); + } else { + if (byId != null) { + if (!byId.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { + byId.setTenantId(byId.getTenantId() + tenantEntity.getTenantId() + ","); + } + byId.setPhone(userPhone); + byId.setNickName(userName); + byId.setAvatarUrl(avatarUrl); + byId.setSex(sex); + wxCUserBasicInfoService.update(byId); + removeCacheMember(basicInfo.getId()); + return byId.getId(); + } else { + basicInfo = new WxCUserBasicInfo(); + basicInfo.setTenantId("," + tenantEntity.getTenantId() + ","); + basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId()); + basicInfo.setPhone(userPhone); + basicInfo.setNickName(userName); + basicInfo.setAvatarUrl(avatarUrl); + basicInfo.setSex(sex); + wxCUserBasicInfoService.save(basicInfo); + removeCacheMember(basicInfo.getId()); + return basicInfo.getId(); + } + } + } + + public String getIpAddr() { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String ipaddress = IPUtil.getIpAddr(request); + return ipaddress; + } + + private void setCUserBasicChild(WxCUserBasicInfo basicInfo){ + WxCUserBasicChild child = new WxCUserBasicChild(); + child.setCUserId(basicInfo.getId()); + child.setTenantId(basicInfo.getFinalTenantId()); + List list = wxCUserBasicChildService.findList(child); + basicInfo.setChildrenList(list); + } + + +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/controller/NeuPosAdminController.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/controller/NeuPosAdminController.java new file mode 100644 index 000000000..426ff4dfe --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/controller/NeuPosAdminController.java @@ -0,0 +1,76 @@ +package com.iformall.controller; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.po.NeuPosOrderMasterExt; +import com.iformall.domain.po.WxActivity; +import com.iformall.service.NeuPosOrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * @author gongbiao + */ +@RestController +@RequestMapping("/api/trade") +@Api(description = "活动") +public class NeuPosAdminController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private NeuPosOrderService neuPosOrderService; + + + @ApiOperation("查询门店") + @GetMapping("shoplist") + public ResultData shoplist() { + List maplist = neuPosOrderService.selectShopList(24); + return new ResultData(maplist); + } + + @ApiOperation("查询支付类型") + @GetMapping("payTypelist") + public ResultData payTypelist() { + List maplist = neuPosOrderService.selectPayTypeList(); + return new ResultData(maplist); + } + + @ApiOperation("集团类型流水") + @GetMapping("payTypeOrderlist") + public ResultData payTypeOrderlist(@ModelAttribute NeuPosOrderMasterExt example) { + example.setOrgId(24); + List maplist = neuPosOrderService.queryShopPayOrderList(example); + return new ResultData(maplist); + } + + @ApiOperation("门店流水") + @GetMapping("shopOrderlist") + public ResultData shopOrderlist(@ModelAttribute NeuPosOrderMasterExt example) { + example.setOrgId(24); + List maplist = neuPosOrderService.queryShopPayTypeTradeList(example); + return new ResultData(maplist); + } + + @ApiOperation("流水记录") + @GetMapping("orderlist") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData orderlist(@ModelAttribute NeuPosOrderMasterExt example, Integer pageNum, Integer pageSize) { + example.setOrgId(24); + PageInfo> maplist = neuPosOrderService.queryOrderList(example,pageNum,pageSize); + return new ResultData(maplist); + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/BodyReaderHttpServletRequestWrapper.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/BodyReaderHttpServletRequestWrapper.java new file mode 100644 index 000000000..38aec3039 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/BodyReaderHttpServletRequestWrapper.java @@ -0,0 +1,76 @@ +package com.iformall.interceptor; + +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import java.io.*; + +public class BodyReaderHttpServletRequestWrapper extends XssHttpServletRequestWrapper { + private final String body; + + public BodyReaderHttpServletRequestWrapper(HttpServletRequest request) throws IOException { + super(request); + StringBuilder stringBuilder = new StringBuilder(); + BufferedReader bufferedReader = null; + try { + InputStream inputStream = request.getInputStream(); + if (inputStream != null) { + bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"utf-8")); + char[] charBuffer = new char[1024]; + int bytesRead = -1; + while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { + stringBuilder.append(charBuffer, 0, bytesRead); + } + } else { + stringBuilder.append(""); + } + } catch (IOException ex) { + throw ex; + } finally { + if (bufferedReader != null) { + try { + bufferedReader.close(); + } catch (IOException ex) { + throw ex; + } + } + } + body = stringBuilder.toString(); + } + + @Override + public ServletInputStream getInputStream() throws IOException { + final ByteArrayInputStream byteArrayInputStream = + new ByteArrayInputStream(body.getBytes("utf-8")); + return new ServletInputStream() { + @Override + public boolean isFinished() { + return false; + } + + @Override + public boolean isReady() { + return false; + } + + @Override + public void setReadListener(ReadListener readListener) { + + } + + @Override + public int read() throws IOException { + return byteArrayInputStream.read(); + } + }; + } + + @Override + public BufferedReader getReader() throws IOException { + return new BufferedReader(new InputStreamReader(this.getInputStream())); + } + + public String getBody() { + return this.body; + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/HttpServletRequestWrapperFilter.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/HttpServletRequestWrapperFilter.java new file mode 100644 index 000000000..ec4e7cb7d --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/HttpServletRequestWrapperFilter.java @@ -0,0 +1,70 @@ +package com.iformall.interceptor; + +import com.iformall.utils.UrlCheck; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +public class HttpServletRequestWrapperFilter implements Filter { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + // 多个跨域域名设置 + // public static final String[] ALLOW_DOMAIN = {"https://admin.malls.iformall.com"}; + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + logger.debug("doFilter start"); + long start = System.currentTimeMillis(); + ServletRequest requestWrapper = null; + + /* // 跨域访问 + HttpServletRequest req = (HttpServletRequest) request; + HttpServletResponse res = (HttpServletResponse) response; + String originHeader = req.getHeader("Origin"); + + if (Arrays.asList(ALLOW_DOMAIN).contains(originHeader)) { + //通过在响应 header 中设置 ‘*’ 来允许来自所有域的跨域请求访问。 + res.setHeader("Access-Control-Allow-Origin", originHeader); + //通过对 Credentials 参数的设置,就可以保持跨域 Ajax 时的 Cookie + //设置了Allow-Credentials,Allow-Origin就不能为*,需要指明具体的url域 + res.setHeader("Access-Control-Allow-Credentials", "true"); + //请求方式 + res.setHeader("Access-Control-Allow-Methods", "*"); + //(预检请求)的返回结果(即 Access-Control-Allow-Methods 和Access-Control-Allow-Headers 提供的信息) 可以被缓存多久 + res.setHeader("Access-Control-Max-Age", "86400"); + //首部字段用于预检请求的响应。其指明了实际请求中允许携带的首部字段 + //res.setHeader("Access-Control-Allow-Headers", "*"); + res.setHeader("Access-Control-Allow-Headers", + "Timestamp,Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token,Access-Control-Allow-Headers"); + } + */ + + //sql,xss过滤 + XssHttpServletRequestWrapper xssHttpServletRequestWrapper = new XssHttpServletRequestWrapper((HttpServletRequest)request); + String url = ""; + if (request instanceof HttpServletRequest) { + url = ((HttpServletRequest) request).getRequestURI(); + if (!UrlCheck.checkUrl(url)) { + requestWrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request); + } + } + if (null == requestWrapper) { + chain.doFilter(xssHttpServletRequestWrapper, response); + } else { + chain.doFilter(requestWrapper, response); + } + logger.debug("doFilter end: " + url + " "+ (System.currentTimeMillis()- start) + "ms"); + } + + @Override + public void destroy() { + + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/RequestInterceptor.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/RequestInterceptor.java new file mode 100644 index 000000000..ff7e81880 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/RequestInterceptor.java @@ -0,0 +1,123 @@ +package com.iformall.interceptor; + +import com.iformall.common.ErrorCode; +import com.iformall.exception.MallinkException; +import com.iformall.utils.HashUtil; +import com.iformall.utils.IPUtil; +import com.iformall.utils.UrlCheck; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.dao.DataAccessException; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import redis.clients.jedis.Protocol; +import redis.clients.jedis.util.SafeEncoder; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.Enumeration; +import java.util.concurrent.TimeUnit; + +/** + * 幂等检查 + * @author stormeye.wu + * @email wuguoqiang@iformall.com + * @date 2017-03-23 15:38 + */ +@Component +public class RequestInterceptor extends HandlerInterceptorAdapter { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Resource + private RedisTemplate redisTemplate; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + logger.debug("preHandle start"); + if ("GET".equalsIgnoreCase(request.getMethod())) { + // 获取不检查幂等 + logger.debug("preHandle start 1"); + return true; + } + String ipaddress = IPUtil.getIpAddr(request); + String url = request.getRequestURL().toString(); + if (UrlCheck.checkUrl(url)) { + // pvlog不检查幂等 + // awsFileUpload不检查幂等 + // stopFee + return true; + } + StringBuilder sb = new StringBuilder(); + + sb.append(url); + + sb.append("method=").append(request.getMethod()).append("&"); + + sb.append("ip=").append(ipaddress).append("&"); + + final Enumeration parameterNames = request.getParameterNames(); + while (parameterNames.hasMoreElements()) { + String key = (String) parameterNames.nextElement(); + if(key.equalsIgnoreCase("ran")) // 跳过ran + continue; + String parameter = request.getParameter(key); + sb.append(key).append("=").append(parameter).append("&"); + } + + InputStream inStream = request.getInputStream(); + ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = inStream.read(buffer)) != -1) { + outSteam.write(buffer, 0, len); + } + String resultBody = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); + inStream.close(); + outSteam.close(); + + sb.append(resultBody); + + String key = "request:C:" + HashUtil.md5(sb.toString()); + Boolean isAbsent = redisTemplate.execute(new RedisCallback() { + @Override + public Boolean doInRedis(RedisConnection connection) throws DataAccessException { + RedisSerializer valueSerializer = redisTemplate.getValueSerializer(); + RedisSerializer keySerializer = redisTemplate.getKeySerializer(); + Object obj = connection.execute("set", keySerializer.serialize(key), + valueSerializer.serialize(key), + SafeEncoder.encode("NX"), + SafeEncoder.encode("EX"), + Protocol.toByteArray(3)); // 3s + return obj != null; + } + }); + if (isAbsent) { + logger.info(key + ": 第一次提交"); + logger.debug("preHandle start 2"); + return true; + } + logger.info(key + ": 第二次提交"); + logger.debug("preHandle start 3"); + throw new MallinkException(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + logger.debug("postHandle"); + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + logger.debug("afterCompletion"); + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/XssHttpServletRequestWrapper.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/XssHttpServletRequestWrapper.java new file mode 100644 index 000000000..1d954d163 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/interceptor/XssHttpServletRequestWrapper.java @@ -0,0 +1,125 @@ +package com.iformall.interceptor; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * 防止sql注入,xss攻击 + * 前端可以对输入信息做预处理,后端也可以做处理。 + */ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { + private final Logger log = LoggerFactory.getLogger(getClass()); + private static String key = "and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare|;|or|-|+"; + private static Set notAllowedKeyWords = new HashSet(0); + private static String replacedString="INVALID"; + static { + String keyStr[] = key.split("\\|"); + for (String str : keyStr) { + notAllowedKeyWords.add(str); + } + } + + private String currentUrl; + + public XssHttpServletRequestWrapper(HttpServletRequest servletRequest) { + super(servletRequest); + currentUrl = servletRequest.getRequestURI(); + } + + + /**覆盖getParameter方法,将参数名和参数值都做xss过滤。 + * 如果需要获得原始的值,则通过super.getParameterValues(name)来获取 + * getParameterNames,getParameterValues和getParameterMap也可能需要覆盖 + */ + @Override + public String getParameter(String parameter) { + String value = super.getParameter(parameter); + if (value == null) { + return null; + } + return cleanXSS(value); + } + @Override + public String[] getParameterValues(String parameter) { + String[] values = super.getParameterValues(parameter); + if (values == null) { + return null; + } + int count = values.length; + String[] encodedValues = new String[count]; + for (int i = 0; i < count; i++) { + encodedValues[i] = cleanXSS(values[i]); + } + return encodedValues; + } + @Override + public Map getParameterMap(){ + Map values=super.getParameterMap(); + if (values == null) { + return null; + } + Map result=new HashMap<>(); + for(String key:values.keySet()){ + String encodedKey=cleanXSS(key); + int count=values.get(key).length; + String[] encodedValues = new String[count]; + for (int i = 0; i < count; i++){ + encodedValues[i]=cleanXSS(values.get(key)[i]); + } + result.put(encodedKey,encodedValues); + } + return result; + } + /** + * 覆盖getHeader方法,将参数名和参数值都做xss过滤。 + * 如果需要获得原始的值,则通过super.getHeaders(name)来获取 + * getHeaderNames 也可能需要覆盖 + */ + @Override + public String getHeader(String name) { + if(name.equalsIgnoreCase("user-agent")) { + return super.getHeader(name); + } + String value = super.getHeader(name); + if (value == null) { + return null; + } + return cleanXSS(value); + } + + private String cleanXSS(String valueP) { + // You'll need to remove the spaces from the html entities below + String value = valueP.replaceAll("<", "<").replaceAll(">", ">"); + value = value.replaceAll("<", "& lt;").replaceAll(">", "& gt;"); + value = value.replaceAll("\\(", "& #40;").replaceAll("\\)", "& #41;"); + value = value.replaceAll("'", "& #39;"); + value = value.replaceAll("eval\\((.*)\\)", ""); + value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\""); + value = value.replaceAll("script", ""); + value = cleanSqlKeyWords(value); + return value; + } + + private String cleanSqlKeyWords(String value) { + String paramValue = value; + for (String keyword : notAllowedKeyWords) { + if (paramValue.length() > keyword.length() + 4 + && (paramValue.contains(" "+keyword)||paramValue.contains(keyword+" ")||paramValue.contains(" "+keyword+" "))) { + paramValue = StringUtils.replace(paramValue, keyword, replacedString); + log.error(this.currentUrl + "已被过滤,因为参数中包含不允许sql的关键词(" + keyword + + ")"+";参数:"+value+";过滤后的参数:"+paramValue); + } + } + return paramValue; + } + +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/resolver/LoginUserHandlerMethodArgumentResolver.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/resolver/LoginUserHandlerMethodArgumentResolver.java new file mode 100644 index 000000000..db7f5b15a --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/resolver/LoginUserHandlerMethodArgumentResolver.java @@ -0,0 +1,48 @@ +package com.iformall.resolver; + +import com.iformall.annotation.LoginUser; +import com.iformall.domain.po.WxCUserBasicInfo; +import com.iformall.domain.po.base.BaseCUserEntity; +import com.iformall.service.CUserTokenService; +import com.iformall.service.WxCUserBasicInfoService; +import com.iformall.utils.Constant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +/** + * 有@LoginUser注解的方法参数,注入当前登录用户 + * @author stormeye.wu + * @email wugq@mippoint.com + * @date 2017-03-23 22:02 + */ +@Component +public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { + + @Autowired + private WxCUserBasicInfoService wxCUserBasicInfoService; + + @Override + public boolean supportsParameter(MethodParameter parameter) { + return parameter.getParameterType().isAssignableFrom(BaseCUserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class); + } + + @Override + public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container, + NativeWebRequest request, WebDataBinderFactory factory) throws Exception { +// //获取会员ID +// Object object = request.getAttribute(Constant.LOGIN_MEMBER_KEY, RequestAttributes.SCOPE_REQUEST); +// if(object == null){ +// return null; +// } +// +// //WxCUserBasicInfo user = wxCUserBasicInfoService.getById((Long) object); +// return user; + return null; + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java new file mode 100644 index 000000000..9c72c528c --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java @@ -0,0 +1,151 @@ +package com.iformall.tenant; + +import com.iformall.common.TenantThreadLocal; +import com.iformall.plugin.autoTenantId.TenantInfo; +import com.iformall.utils.Constant; +import org.apache.ibatis.mapping.MappedStatement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import java.util.Arrays; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +public class TenantInfoImpl implements TenantInfo { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private static String[] filterTables = new String[] { + "wx_mall", + "mall_permission", + "mall_sale_type", + "mall_user_role", + "wx_channel", + "wx_business", + "wx_coupon_type", + "wx_game_template", + "wx_group", + "wx_mall_apply", + "wx_tags", + "wx_tags_group", + "wx_tags_type", + "wx_user_channel", + "wx_score_rules", + "wx_level_config", + "wx_c_user_basic_info", + "wx_c_user_basic_child", + "wx_c_user_basic_sign", + "wx_credit_history", + "wx_score_history", + "wx_c_user_tags", + "wx_weapp_ext_set", + "wx_msg_validationcode_model", + "wx_component_verify_ticket", + "wx_opinion", + "wx_question_oneself", + "wx_question_oneself_log", + "wx_question_oneself_topic", + "wx_question_oneself_user", + }; + + private static String[] filterSubTables = new String[] { + "wx_mall", + "wx_appinfo", + "wx_authorizer_info", + "wx_c_user", + "wx_c_user_basic_info", + "wx_c_user_basic_child", + "wx_c_user_basic_sign", + "wx_c_user_car", + "wx_c_user_from_b", + "wx_c_user_tags", + "wx_cuser_floating_layer", + "wx_floating_layer", + "wx_question", + "wx_question_config", + "wx_question_log", + "wx_user_visit", + "wx_level_config", + "wx_score_rules", + "view_coupon_data", + "view_touch_user", + "wx_weapp_audit_status", + "wx_weapp_code_status", + "wx_weapp_release_status", + "mem_coupon_from_dsp", + "wx_component_verify_ticket", + "wx_opinion", + "wx_question_oneself", + "wx_question_oneself_log", + "wx_question_oneself_topic", + "wx_question_oneself_user", + }; + + + @Override + public String getTenantId() { + String tenantId = null; + try { + //HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + //tenantId = (String) request.getAttribute(Constant.TENANT_ID); + tenantId = TenantThreadLocal.getTenantId(); + return tenantId; + } catch (Exception e) { + logger.error(e.getMessage()); + } + return tenantId; + } + + @Override + public String getParentTenantId() { + String parentTenantId = null; + try { + //HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + //parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID); + parentTenantId = TenantThreadLocal.getParentTenantId(); + return parentTenantId; + } catch (Exception e) { + logger.error(e.getMessage()); + } + return parentTenantId; + } + + @Override + public boolean doTableFilter(String tableName) { + List list = filterTables(); + if (list.contains(tableName)) { + return true; + } + return false; + } + + @Override + public boolean doTableFilterSub(String tableName) { + List list = filterSubTables(); + if (list.contains(tableName)) { + return true; + } + return false; + } + + @Override + public boolean doMappedStatementFIlter(MappedStatement ms) { + if ("com.iformall.mapper.WxCUserMapper.getByToken".equals(ms.getId())) + return true; + if ("com.iformall.mapper.WxCouponActionLogMapper.getCountByUserAndCoupon".equals(ms.getId())) + return true; + return false; + } + + @Override + public List filterTables() { + return Arrays.asList(filterTables); + } + + @Override + public List filterSubTables() { + return Arrays.asList(filterSubTables); + } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/utils/ImgIdeaUtil.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/utils/ImgIdeaUtil.java new file mode 100644 index 000000000..16ebb8d46 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/utils/ImgIdeaUtil.java @@ -0,0 +1,175 @@ +package com.iformall.utils; + +import net.sourceforge.pinyin4j.PinyinHelper; +import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; +import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; +import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; +import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; +import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.ResourceUtils; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.InputStream; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Locale; + +public class ImgIdeaUtil { + + private static final Logger logger = LoggerFactory.getLogger(ImgIdeaUtil.class); + + //模板图片 + private static final String imgTempPath = "imgTemp/gertificate.jpg"; + //字体路径 + private static final String fontPath = "opt/HWLS.TTF"; + + /** + * 生成图片证书 + * @return + */ + public static byte[] imgGertificate(String name, String englishName, LocalDateTime date){ + if(StringUtils.isBlank(name)){ + logger.error("名字为空,无法生成证书"); + return null; + } + if(name.length() == 2){ + name = name.replaceAll("(\\S)", "$0 "); + } + if(StringUtils.isBlank(englishName)){ + englishName = getUpEname(name); + } + if(date == null){ + date = LocalDateTime.now(); + } + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dMMM yyyy", Locale.UK); + String dateFormat = date.format(formatter); + + try { + + InputStream backImgUrl = ClassLoader.getSystemResourceAsStream(imgTempPath); + //InputStream backImgUrl = ImgIdeaUtil.class.getClassLoader().getResourceAsStream(imgTempPath); + + Font font = Font.createFont(Font.TRUETYPE_FONT, ResourceUtils.getFile("classpath:"+fontPath)); + BufferedImage backImg = ImageIO.read(backImgUrl); + Graphics g = backImg.getGraphics(); + + //图片加中文名 + Font fTxtBottomName = font.deriveFont(Font.PLAIN, 170); + //Font fTxtBottomName = new Font("华文隶书", Font.PLAIN, 170); + FontMetrics metricsName = g.getFontMetrics(fTxtBottomName); + int xName = (backImg.getWidth() - metricsName.stringWidth(name)) / 2; + Color myColorTxtBottomName = Color.BLACK; //颜色 + g.setColor(myColorTxtBottomName); + g.setFont(fTxtBottomName); + g.drawString(name, xName , 1150);//g.drawString(文字, x 位置, y 位置); + + //图片加英文名 + Font fTxtBottomEname = font.deriveFont(Font.PLAIN, 120); + //Font fTxtBottomEname = new Font("华文隶书", Font.PLAIN, 120); + FontMetrics metricsEname = g.getFontMetrics(fTxtBottomEname); + int xEname = (backImg.getWidth() - metricsEname.stringWidth(englishName)) / 2; + Color myColorTxtBottomEname = Color.BLACK; + g.setColor(myColorTxtBottomEname); + g.setFont(fTxtBottomEname); + g.drawString(englishName, xEname, 1300); + + //图片加日期 + Font fTxtBottomDate = font.deriveFont(Font.PLAIN, 90); + //Font fTxtBottomDate = new Font("华文隶书", Font.PLAIN, 90); + Color myColorTxtBottomDate = Color.BLACK; + g.setColor(myColorTxtBottomDate); + g.setFont(fTxtBottomDate); + g.drawString(dateFormat, 440, 2100); + + //调这个方法就是开始这个整合 (可以多张图片,多个文字整合成一张图片,只有把他们放在这方法里面就行) + g.dispose(); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ImageIO.write(backImg, "png", out); + + return out.toByteArray(); + } catch (Exception e) { + e.printStackTrace(); + logger.error("生成证书异常", e.getMessage()); + } + return null; + } + + /** + * //姓、名的第一个字母需要为大写 + * @param name + * @return + */ + public static String getUpEname(String name) { + char[] strs = name.toCharArray(); + String newname = null; + + if (strs.length == 2) { + newname = toUpCase(getEname("" + strs[0])) + " " + toUpCase(getEname("" + strs[1])); + } else if (strs.length == 3){ + newname = toUpCase(getEname("" + strs[0])) + " " + + toUpCase(getEname("" + strs[1] + strs[2])); + }else if (strs.length == 4){ + newname = toUpCase(getEname("" + strs[0] + strs[1])) + " " + + toUpCase(getEname("" + strs[2] + strs[3])); + } else{ + newname = toUpCase(getEname(name)); + } + return newname; + } + + + /** + * //将中文转换为英文 + * @param name + * @return + */ + public static String getEname(String name){ + HanyuPinyinOutputFormat pyFormat = new HanyuPinyinOutputFormat(); + pyFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); + pyFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); + pyFormat.setVCharType(HanyuPinyinVCharType.WITH_V); + String s = ""; + try { + s = PinyinHelper.toHanyuPinyinString(name, pyFormat, ""); + } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { + badHanyuPinyinOutputFormatCombination.printStackTrace(); + } + return s; + } + /** + * 首字母大写 + * @param str + * @return + */ + private static String toUpCase(String str) { + StringBuffer newstr = new StringBuffer(); + newstr.append((str.substring(0, 1)).toUpperCase()).append( + str.substring(1, str.length())); + return newstr.toString(); + } + + +// public static void main(String[] args) { +// String serverUploadImgUrl = "C:/Users/xiaohu/Desktop/img"; // 图片保存路径 +// try { +// byte[] bytes = imgGertificate("郑方元", null, null); +// ByteArrayInputStream bais = new ByteArrayInputStream(bytes); +// BufferedImage bi1 =ImageIO.read(bais); +// +// ImageIO.write(bi1, "png", new File(serverUploadImgUrl+"/0.png")); +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// System.out.println("结束"); +// } +} diff --git a/mallinkNeuPosAdmin/src/main/java/com/iformall/utils/UrlCheck.java b/mallinkNeuPosAdmin/src/main/java/com/iformall/utils/UrlCheck.java new file mode 100644 index 000000000..e3961ad71 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/java/com/iformall/utils/UrlCheck.java @@ -0,0 +1,14 @@ +package com.iformall.utils; + +/** + * @author gongbiao + */ +public class UrlCheck { + + public static boolean checkUrl(String url) { + return url.contains("awsFileUpload") + || url.contains("awsFilesUpload") + || url.contains("getCarStopFee"); + } + +} diff --git a/mallinkNeuPosAdmin/src/main/resources/application-dev.yml b/mallinkNeuPosAdmin/src/main/resources/application-dev.yml new file mode 100644 index 000000000..a909bab7c --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/resources/application-dev.yml @@ -0,0 +1,184 @@ +spring: + profiles: + #include: aliyunRocketMQ + include: rabbitMQ + # JDBC + datasource: + url: jdbc:mysql://rm-2zen3rya8g4zur77cco.mysql.rds.aliyuncs.com:3306/smart_pos_platform_catering_db?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true + username: fmposdb + password: fmposdb@2021User + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + filters: stat + maxActive: 20 + initialSize: 1 + maxWait: 60000 + minIdle: 1 + timeBetweenEvictionRunsMillis: 28000 + minEvictableIdleTimeMillis: 28000 + validationQuery: select 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxOpenPreparedStatements: 20 + #jackson: + #date-format: yyyy-MM-dd HH:mm:ss + + # REDIS + redis: + host: 101.200.130.134 + port: 6379 + password: iF0rm@2l2ol9 + timeout: 3600 + expire: 1800 #30分钟 + database: 5 + jedis: + pool: + max-active: 200 + max-idle: 100 + max-wait: -1 + min-idle: 0 + + # SMS + aliyun: + sms: + accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V + accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry + product: Dysmsapi + domain: dysmsapi.aliyuncs.com + regionId: cn-hangzhou + dateFormat: yyyyMMdd + endpointName: cn-hangzhou + + oss: + endpoint: oss-cn-beijing.aliyuncs.com + keyid: LTAI4G7ixY4AhvM35F8o3W3V + keysecret: VfWqGb83qIQrS9us45utskl8itd7ry + bucketname: formall + filehost: malinkcapi + filedomain: https://formall.oss-accelerate.aliyuncs.com + + # EMAIL + mail: + host: smtp.exmail.qq.com + username: service@iformall.com + password: jGvApygXN7wc5SzN # 授权密码 + properties: + mail: + smtp: + auth: true + starttls: + enable: true + socketFactory: + port: 465 + class: javax.net.ssl.SSLSocketFactory + # ROCKETMQ + rocketmq: + nameServer: 127.0.0.1:9876 + producer: + retry-times-when-send-async-failed: 0 + send-msg-timeout: 300000 + compress-msg-body-over-howmuch: 4096 + max-message-size: 4194304 + retry-another-broker-when-not-store-ok: false + retry-times-when-send-failed: 2 + # RABBITMQ + rabbitmq: + host: 101.200.130.134 + port: 5672 + username: fumao + password: f9l98 + publisher-confirms: true + publisher-returns: false + virtual-host: / + aliyunRocketmq: + accessKeyId: "LTAI4G7ixY4AhvM35F8o3W3V" + accessKeySecret: "VfWqGb83qIQrS9us45utskl8itd7ry" + groupId: "GID_P_1" + namesrvAddr: "http://MQ_INST_1796289517488555_Bcqaq2is.cn-beijing.mq-internal.aliyuncs.com:8080" + +aws: + clientRegion: cn-northwest-1 + bucketName: iformall-net + access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) + secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) + +#wechat: +# open: +# componentAppId: "wxdfc8fb4e62d6b52b" +# componentSecret: "98daa62b316dd6feabaad708327ce233" +# componentToken: "formall2018" +# componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" +# redis: +# host: 101.201.103.81 +# port: 6379 +# password: ENC(xPFDlgd6v8zUhJMbcKc0KmmQiqs9qHtk) +# timeout: 3600 +# expire: 1800 #30分钟 +# database: 2 +# defaultExpiration: 2592000 # 默认生命周期30天 +# jedis: +# pool: +# max-active: 100 +# max-idle: 500 +# max-wait: -1 +# min-idle: 10 + +wechat: + web: + appId: "wx091907dd0bfd3f6b" + secret: "2a2ca10738998b9ef92c1fe8a4d366a6" + url: "https://admintest.malls.iformall.com" + open: + componentAppId: wxdfc8fb4e62d6b52b + componentSecret: 98daa62b316dd6feabaad708327ce233 + componentToken: formall2018 + componentAesKey: htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN + redis: + host: 101.200.130.134 + port: 6379 + password: iF0rm@2l2ol9 + timeout: 3600 + expire: 1800 #30分钟 + database: 2 + defaultExpiration: 2592000 # 默认生命周期30天 + jedis: + pool: + max-active: 100 + max-idle: 100 + max-wait: -1 + min-idle: 10 + +alipay: + open: + appId: 2021002137663024 + appPrivateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCUfymV5J73QQMG52PVIGUbowkloYCO4B7TQoKbrTZf2YeYsg/To/o4PiXPMNwEUfEUU8NYQ6WwNhCd2fa1ei8WFXJUf3bfgswtBk1aOmHLeY9yoXFxIKMTQ9RcobnmBzKQZlaAPMTSr7t1QtKZKPuc2gEHGRFYKO/ZuL8gIpnsVidVtmi52yd7hzao/pI3ThLA0lreg4L3rYP5ESQZRytxIPgUQ4KI11pZxFgbe+uy28AGDYIQscSIb+SWOHPYKLvOEqqepIZ8M18w/U0lZzpzepzi/V/llekvXJ6UEf1lzl7x/4UIA3WPN1B40+NzbD/OxEGTuM0UctOG6ZTd4Te9AgMBAAECggEAPYksnHbvARspu/SrRCh2fatkIPn6Ijrxyy3mnch7neCw9i/jqxpqmF/4nxFqO0gRlRDZBHyT7p+Y5zDpsW5+kLI2fJmNkzXKkmXoLBnBaOZo8WHBdtXFfjg/iltig9Y7t+cQtXd5QK2eCwuz5dA75FXa0ywqKdRdAGY0nYZ5LpwrHVU8RXheUDCJyhKNj2+W6lIaSKDxLZU3laO1oBrv1agcy7Crd5E2ndb8O3Enga+z7wSz2h7A1BasC/Yl/Ro0Y21wLCH3s/R6qA0Paq12+WEF+xdodM7SrP43CCTVFGbC1TfEOdanJfixop8QuYsIp7pHrL925+vP4eY9RfckgQKBgQDQqLdpDzzU7Ot/L9Vc/r8d4iwXXbX8+HwVFV4oBuausgFyv8eJJpfrI+IlEoB1ubJcPpJBFqfmeYTW6/v6ioFljJAlWfFvesUVt/HszBMIOsU0Bzt7ex6WlwKOagb0q0ZPA4T0OY0K0lg0loaaaR8ZTr4ivDymaGBtTBYhslpc7QKBgQC2MBznGEc5r2dhyENvdPOR20PnXQcevGnPdqSus8m0VmDcHE72RVcckcZtwczsb3NaLSqmjAcWTn51/VFmlvhB3F34FcFTPZGq6sj7fWK8HuFq7l7mu5OzYuVr73zy9ggsUuaw10IqvvwIVxszNAF0hiRnSGH3z27CoRmz3s+8EQKBgQCK3o7atBJ3X4rIJiypbL4DhIB1uJ+jUjk6yvLUTut+fufp1+tTw0S+cS5UIAEw2Lr1G4u5F/v8rwmTBJG6SC4gSLGyui6uVBYRA1BWmedcxchzfRDAeMt9y9kesUAZ3Fe5xIzbAeZ1ulKMBVZmM+pHrJlsgr0Wv0bV1xqvqITtbQKBgBIsIGXopQoa9dvqBtfyOW1eCprkS5aEQqWf9vM6Ga90QjsSU8n6xqKh48IE57TZtQ7UnIF6TCasc66/MsRh4KdpHLJnMR5lcMc0nhF/wz5ychehaTPol+X3wlyOyc7OPah2KG6ROhdbb3ZBggQMduyxiKYIsUTvmuOtAAxR+DSRAoGADtuDzGQDOJYWiO2uuP6FpA5IJaiwlSfu3xncJVfhO8SVr6VBJFg88igbIB3w6nk/sv7j9VTXqXre9HMvp1flxaaLsdxM4HcTSALS9q6t/ajaveqte6S5kAtWx0WW8C6PtgWXHbxcD7LXARSsKLoEl2JXXyUVS/m2l/RzHBQ8GJI= + appPublicKeyCertPath: /opt/iformall/service/alipay/appCertPublicKey_2021002137663024.crt + alipayCertPath: /opt/iformall/service/alipay/alipayCertPublicKey_RSA2.crt + alipayRootCertPath: /opt/iformall/service/alipay/alipayRootCert.crt + callback: https://callbacktest.malls.iformall.com/api/alipay/notify/callback + +video: + aliyun: + accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V + accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry + regionId: cn-beijing + +jasypt: + encryptor: + password: oRqdnDbK5pj3eMmB + +fm: + exception: true + exception_emails: xuxiaohu@iformall.com + deploy: 1 + open: true + upload_dir: /home/test/server/uploads/ + ocr_data: /root/ocr_data/ + videoType: aliyun + +logging: + level: + com.iformall: debug + path: ./logs/c \ No newline at end of file diff --git a/mallinkNeuPosAdmin/src/main/resources/application-prod.yml b/mallinkNeuPosAdmin/src/main/resources/application-prod.yml new file mode 100644 index 000000000..0ab8176b1 --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/resources/application-prod.yml @@ -0,0 +1,139 @@ +spring: + profiles: + include: aliyunRocketMQ + # JDBC + datasource: + url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true + username: ENC(nUefcxWYlMS/1cDxikIKwA==) + password: ENC(neToS+hzeFjgSFB/7UEl5qYnW2rUjrPq) + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + filters: stat + maxActive: 20 + initialSize: 1 + maxWait: 60000 + minIdle: 1 + timeBetweenEvictionRunsMillis: 28000 + minEvictableIdleTimeMillis: 28000 + validationQuery: select 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxOpenPreparedStatements: 20 + # REDIS + redis: + host: r-2zeaglwf13qqmnllj5.redis.rds.aliyuncs.com + port: 6379 + password: mallone:iF0rm@2l2ol9 + timeout: 3600 + expire: 1800 #30分钟 + database: 1 + defaultExpiration: 2592000 # 默认生命周期30天 + jedis: + pool: + max-active: 100 + max-idle: 100 + max-wait: -1 + min-idle: 10 + # SMS + aliyun: + sms: + accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V + accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry + product: Dysmsapi + domain: dysmsapi.aliyuncs.com + regionId: cn-hangzhou + dateFormat: yyyyMMdd + endpointName: cn-hangzhou + oss: + endpoint: oss-cn-beijing.aliyuncs.com + keyid: LTAI4G7ixY4AhvM35F8o3W3V + keysecret: VfWqGb83qIQrS9us45utskl8itd7ry + bucketname: formall + filehost: malinkadmin + filedomain: https://formall.oss-accelerate.aliyuncs.com + + # EMAIL + mail: + host: smtp.exmail.qq.com + username: sysadministor@iformall.com # 登陆密码sysAd1231 + password: SWqPekCEmhUYuYCd # 授权密码 + properties: + mail: + smtp: + auth: true + starttls: + enable: true + socketFactory: + port: 465 + class: javax.net.ssl.SSLSocketFactory + # RABBITMQ + rabbitmq: + host: localhost + port: 5672 + username: ENC(lRmLd6EzgeY1RT5ktcHv9g==) + password: ENC(gBI8mCjr3OC0v57jcnSb660Ux7mW03K2oePgvohhg7w=) + publisher-confirms: true + publisher-returns: false + virtual-host: / + aliyunRocketmq: + accessKeyId: "LTAI4G7ixY4AhvM35F8o3W3V" + accessKeySecret: "VfWqGb83qIQrS9us45utskl8itd7ry" + groupId: "GID_P_1" + namesrvAddr: "http://MQ_INST_1796289517488555_Bcqaq2is.cn-beijing.mq-internal.aliyuncs.com:8080" +aws: + clientRegion: cn-northwest-1 + bucketName: iformall-net + access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) + secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) + +wechat: + open: + componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) + componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) + componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) + componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) + redis: + host: r-2zeaglwf13qqmnllj5.redis.rds.aliyuncs.com + port: 6379 + password: mallone:iF0rm@2l2ol9 + timeout: 3600 + expire: 1800 #30分钟 + database: 2 + defaultExpiration: 2592000 # 默认生命周期30天 + jedis: + pool: + max-active: 100 + max-idle: 100 + max-wait: -1 + min-idle: 10 + +alipay: + open: + appId: 2021002137663024 + appPrivateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCUfymV5J73QQMG52PVIGUbowkloYCO4B7TQoKbrTZf2YeYsg/To/o4PiXPMNwEUfEUU8NYQ6WwNhCd2fa1ei8WFXJUf3bfgswtBk1aOmHLeY9yoXFxIKMTQ9RcobnmBzKQZlaAPMTSr7t1QtKZKPuc2gEHGRFYKO/ZuL8gIpnsVidVtmi52yd7hzao/pI3ThLA0lreg4L3rYP5ESQZRytxIPgUQ4KI11pZxFgbe+uy28AGDYIQscSIb+SWOHPYKLvOEqqepIZ8M18w/U0lZzpzepzi/V/llekvXJ6UEf1lzl7x/4UIA3WPN1B40+NzbD/OxEGTuM0UctOG6ZTd4Te9AgMBAAECggEAPYksnHbvARspu/SrRCh2fatkIPn6Ijrxyy3mnch7neCw9i/jqxpqmF/4nxFqO0gRlRDZBHyT7p+Y5zDpsW5+kLI2fJmNkzXKkmXoLBnBaOZo8WHBdtXFfjg/iltig9Y7t+cQtXd5QK2eCwuz5dA75FXa0ywqKdRdAGY0nYZ5LpwrHVU8RXheUDCJyhKNj2+W6lIaSKDxLZU3laO1oBrv1agcy7Crd5E2ndb8O3Enga+z7wSz2h7A1BasC/Yl/Ro0Y21wLCH3s/R6qA0Paq12+WEF+xdodM7SrP43CCTVFGbC1TfEOdanJfixop8QuYsIp7pHrL925+vP4eY9RfckgQKBgQDQqLdpDzzU7Ot/L9Vc/r8d4iwXXbX8+HwVFV4oBuausgFyv8eJJpfrI+IlEoB1ubJcPpJBFqfmeYTW6/v6ioFljJAlWfFvesUVt/HszBMIOsU0Bzt7ex6WlwKOagb0q0ZPA4T0OY0K0lg0loaaaR8ZTr4ivDymaGBtTBYhslpc7QKBgQC2MBznGEc5r2dhyENvdPOR20PnXQcevGnPdqSus8m0VmDcHE72RVcckcZtwczsb3NaLSqmjAcWTn51/VFmlvhB3F34FcFTPZGq6sj7fWK8HuFq7l7mu5OzYuVr73zy9ggsUuaw10IqvvwIVxszNAF0hiRnSGH3z27CoRmz3s+8EQKBgQCK3o7atBJ3X4rIJiypbL4DhIB1uJ+jUjk6yvLUTut+fufp1+tTw0S+cS5UIAEw2Lr1G4u5F/v8rwmTBJG6SC4gSLGyui6uVBYRA1BWmedcxchzfRDAeMt9y9kesUAZ3Fe5xIzbAeZ1ulKMBVZmM+pHrJlsgr0Wv0bV1xqvqITtbQKBgBIsIGXopQoa9dvqBtfyOW1eCprkS5aEQqWf9vM6Ga90QjsSU8n6xqKh48IE57TZtQ7UnIF6TCasc66/MsRh4KdpHLJnMR5lcMc0nhF/wz5ychehaTPol+X3wlyOyc7OPah2KG6ROhdbb3ZBggQMduyxiKYIsUTvmuOtAAxR+DSRAoGADtuDzGQDOJYWiO2uuP6FpA5IJaiwlSfu3xncJVfhO8SVr6VBJFg88igbIB3w6nk/sv7j9VTXqXre9HMvp1flxaaLsdxM4HcTSALS9q6t/ajaveqte6S5kAtWx0WW8C6PtgWXHbxcD7LXARSsKLoEl2JXXyUVS/m2l/RzHBQ8GJI= + appPublicKeyCertPath: /opt/iformall/service/alipay/appCertPublicKey_2021002137663024.crt + alipayCertPath: /opt/iformall/service/alipay/alipayCertPublicKey_RSA2.crt + alipayRootCertPath: /opt/iformall/service/alipay/alipayRootCert.crt + callback: https://callbacktest.malls.iformall.com/api/alipay/notify/callback + +video: + aliyun: + accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V + accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry + regionId: cn-beijing + +fm: + exception: true + exception_emails: houtaikaifa@iformall.com + deploy: 3 + open: true + upload_dir: /root/uploads/ + ocr_data: /root/ocr_data/ + videoType: aliyun + +logging: + level: + com.iformall: debug + path: ./logs/c \ No newline at end of file diff --git a/mallinkNeuPosAdmin/src/main/resources/application.yml b/mallinkNeuPosAdmin/src/main/resources/application.yml new file mode 100644 index 000000000..df54dadcb --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/resources/application.yml @@ -0,0 +1,54 @@ +server: + port: 9000 + servlet: + context-path: /neupos + +spring: + application: + name: mallink + profiles: + active: dev + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + default-property-inclusion: non_null +# rocketmq: +# nameServer: 127.0.0.1:9876 +# producer: +# retry-times-when-send-async-failed: 0 +# send-msg-timeout: 300000 +# compress-msg-body-over-howmuch: 4096 +# max-message-size: 4194304 +# retry-another-broker-when-not-store-ok: false +# retry-times-when-send-failed: 2 + +# MybatisPlus +mybatis-plus: + mapper-locations: classpath:mapper/*Mapper.xml + global-config: + db-config: + id-type: id_worker + field-strategy: not_null + db-type: mysql + configuration: + jdbc-type-for-null: 'null' + cache-enabled: false + call-setters-on-nulls: true + type-aliases-package: com.iformall.domain.po + type-enums-package: com.iformall.enums + +# PageHelper +pagehelper: + helperDialect: mysql + reasonable: false + supportMethodsArguments: true + params: count=countSql + offset-as-page-num: true + page-size-zero: true + row-bounds-with-count: true + +mapper: + mappers: + - com.iformall.common.CommonMapper + +version: @project.version@ \ No newline at end of file diff --git a/mallinkNeuPosAdmin/src/main/resources/logback-spring.xml b/mallinkNeuPosAdmin/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..3a54d117d --- /dev/null +++ b/mallinkNeuPosAdmin/src/main/resources/logback-spring.xml @@ -0,0 +1,100 @@ + + + + + + + + [%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] --%mdc{client}%msg%n + + + + + ${logPath}/trace.log + + ${logPath}/daily/trace.%d{yyyy-MM-dd}.log + 30 + + + [%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n + + + + + ${logPath}/info.log + + ${logPath}/daily/info.%d{yyyy-MM-dd}.log + 30 + + + [%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n + + + INFO + ACCEPT + DENY + + + + + ${logPath}/debug.log + + ${logPath}/daily/debug.%d{yyyy-MM-dd}.log + 30 + + + [%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n + + + DEBUG + ACCEPT + DENY + + + + + + ${logPath}/warn.log + + ${logPath}/daily/warn.%d{yyyy-MM-dd}.log + 30 + + + [%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n + + + WARN + ACCEPT + DENY + + + + + + + ${logPath}/error.log + + ${logPath}/daily/error.%d{yyyy-MM-dd}.log + 30 + + + [%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/NeuPosOrderMasterExt.java b/mallinkService/src/main/java/com/iformall/domain/po/NeuPosOrderMasterExt.java index 715f278e1..e9a47c2b9 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/NeuPosOrderMasterExt.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/NeuPosOrderMasterExt.java @@ -18,11 +18,6 @@ import lombok.ToString; public class NeuPosOrderMasterExt extends BaseEntity{ private Integer orgId; private Integer shopId; - private BigDecimal totalAmount; - private BigDecimal rechargeAmount; - private Integer orderCount; - private Integer rechargeCount; - @TableField(exist = false) private Date createBegin; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/service/NeuPosOrderService.java b/mallinkService/src/main/java/com/iformall/service/NeuPosOrderService.java index 4d94c3a41..12e7d3dfc 100644 --- a/mallinkService/src/main/java/com/iformall/service/NeuPosOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/NeuPosOrderService.java @@ -7,13 +7,24 @@ import com.iformall.domain.po.PosOrder; public interface NeuPosOrderService { - List queryShopPayTypeTradeList(NeuPosOrderMasterExt example); - + /** + * 集团类型 + * @param example + * @return + */ List queryShopPayOrderList(NeuPosOrderMasterExt example); + + /** + * 门店类型流水 + * @param example + * @return + */ + List queryShopPayTypeTradeList(NeuPosOrderMasterExt example); + List selectShopList(Integer orgId); List selectPayTypeList(); - List queryOrderList(NeuPosOrderMasterExt example); + PageInfo> queryOrderList(NeuPosOrderMasterExt example,Integer pageIndex, Integer pageSize); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/NeuPosOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/NeuPosOrderServiceImpl.java index 591a399e3..df136b289 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/NeuPosOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/NeuPosOrderServiceImpl.java @@ -1,5 +1,7 @@ package com.iformall.service.impl; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.NeuPosOrderMasterExt; import com.iformall.mapper.NeuPosOrderMasterExtMapper; import com.iformall.service.NeuPosOrderService; @@ -34,12 +36,12 @@ public class NeuPosOrderServiceImpl implements NeuPosOrderService { List payTypeMap = posOrderMapper.selectPayTypeList(); Map typeMap = new HashMap(); for (Map payt:payTypeMap) { - typeMap.put((Integer)payt.get("pay_type"), (String)payt.get("name")); + typeMap.put(Integer.parseInt((String)payt.get("pay_type")), (String)payt.get("name")); } List relist = new ArrayList(); for (Map payOrder:payOrderList ) { - Integer payType = (Integer)payOrder.get("payType"); + Integer payType = Integer.parseInt((String)payOrder.get("payType")); if (null != payType && typeMap.containsKey(payType)) { Map map = new HashMap(); map.put("payType",typeMap.get(payType).toString()); @@ -61,8 +63,8 @@ public class NeuPosOrderServiceImpl implements NeuPosOrderService { } @Override - public List queryOrderList(NeuPosOrderMasterExt example) { - return posOrderMapper.queryOrderList(example); + public PageInfo> queryOrderList(NeuPosOrderMasterExt example,Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> posOrderMapper.queryOrderList(example)); } } diff --git a/mallinkService/src/main/resources/mapper/NeuPosOrderMasterExtMapper.xml b/mallinkService/src/main/resources/mapper/NeuPosOrderMasterExtMapper.xml index d530f952f..015182e95 100644 --- a/mallinkService/src/main/resources/mapper/NeuPosOrderMasterExtMapper.xml +++ b/mallinkService/src/main/resources/mapper/NeuPosOrderMasterExtMapper.xml @@ -52,7 +52,7 @@ diff --git a/pom.xml b/pom.xml index 3c75506eb..b585be75d 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ mallinkPublicApi mallinkTTCApi mallinkTTAdmin + mallinkNeuPosAdmin