| @@ -2,8 +2,9 @@ package com.iformall.controller; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxFlowRecord; | import com.iformall.domain.po.WxFlowRecord; | ||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.iformall.enums.EnumFlowRecordStatus; | import com.iformall.enums.EnumFlowRecordStatus; | ||||
| import com.iformall.mq.MqProducer; | |||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.WxFlowService; | import com.iformall.service.WxFlowService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -27,14 +28,7 @@ public class WxFlowAbleController extends BaseController { | |||||
| private WxFlowService wxFlowService; | private WxFlowService wxFlowService; | ||||
| @Autowired | @Autowired | ||||
| RuntimeService runtimeService; | RuntimeService runtimeService; | ||||
| private MqProducer mqProducer; | |||||
| @ApiOperation(value = "mqSend",notes = "") | |||||
| @PostMapping("/mqSend") | |||||
| public ResultData mqSend() throws Throwable{ | |||||
| mqProducer.sendMessage("aaaa","topic-1","tag-1","key1"); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation(value = "启动流程",notes = "{\"businessId\":\"221178539888607232\",\"businessType\":1,\"remark\":\"意见意见。\",\"taskAssignee\":[{\"taskKey\":\"firstTaskUser\",\"assignee\":\"243650055783841792\"},{\"taskKey\":\"secondTaskUser\",\"assignee\":\"\"}],\"variables\":[{\"key\":\"contractType\",\"value\":\"1\"},{\"key\":\"contractNumber\",\"value\":\"1111\"}]}") | @ApiOperation(value = "启动流程",notes = "{\"businessId\":\"221178539888607232\",\"businessType\":1,\"remark\":\"意见意见。\",\"taskAssignee\":[{\"taskKey\":\"firstTaskUser\",\"assignee\":\"243650055783841792\"},{\"taskKey\":\"secondTaskUser\",\"assignee\":\"\"}],\"variables\":[{\"key\":\"contractType\",\"value\":\"1\"},{\"key\":\"contractNumber\",\"value\":\"1111\"}]}") | ||||
| @PostMapping("/start") | @PostMapping("/start") | ||||
| public ResultData start(@RequestBody Map<String, Object> params) { | public ResultData start(@RequestBody Map<String, Object> params) { | ||||
| @@ -31,7 +31,7 @@ spring: | |||||
| retry-another-broker-when-not-store-ok: false | retry-another-broker-when-not-store-ok: false | ||||
| retry-times-when-send-failed: 2 | retry-times-when-send-failed: 2 | ||||
| rabbitmq: | rabbitmq: | ||||
| host: 127.0.0.1 | |||||
| host: 202.165.179.86 | |||||
| port: 5672 | port: 5672 | ||||
| username: guest | username: guest | ||||
| password: guest | password: guest | ||||
| @@ -0,0 +1,35 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <parent> | |||||
| <artifactId>mallink</artifactId> | |||||
| <groupId>com.iformall</groupId> | |||||
| <version>1.0</version> | |||||
| </parent> | |||||
| <artifactId>mallinkMQConsumer</artifactId> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>com.iformall</groupId> | |||||
| <artifactId>mallinkService</artifactId> | |||||
| <version>1.0</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <build> | |||||
| <plugins> | |||||
| <plugin> | |||||
| <groupId>org.springframework.boot</groupId> | |||||
| <artifactId>spring-boot-maven-plugin</artifactId> | |||||
| <configuration> | |||||
| <executable>true</executable> | |||||
| </configuration> | |||||
| </plugin> | |||||
| </plugins> | |||||
| </build> | |||||
| </project> | |||||
| @@ -0,0 +1,35 @@ | |||||
| package com.iformall; | |||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||||
| 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 springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| import tk.mybatis.spring.annotation.MapperScan; | |||||
| /** | |||||
| * @author chenkx | |||||
| * @date 2017-12-26 | |||||
| */ | |||||
| @SpringBootApplication | |||||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||||
| @EnableSwagger2 | |||||
| @EnableRocketMQ | |||||
| @EnableEncryptableProperties | |||||
| public class ConsumerApplication { | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| SpringApplication.run(ConsumerApplication.class, args); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * @author Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "aws") | |||||
| public class AwsProperty { | |||||
| // AWS ACCESS KEY | |||||
| private String access; | |||||
| private String secret; | |||||
| private String clientRegion; | |||||
| private String bucketName; | |||||
| public String getAccess() { | |||||
| return access; | |||||
| } | |||||
| public void setAccess(String access) { | |||||
| this.access = access; | |||||
| } | |||||
| public String getSecret() { | |||||
| return secret; | |||||
| } | |||||
| public void setSecret(String secret) { | |||||
| this.secret = secret; | |||||
| } | |||||
| public String getClientRegion() { | |||||
| return clientRegion; | |||||
| } | |||||
| public void setClientRegion(String clientRegion) { | |||||
| this.clientRegion = clientRegion; | |||||
| } | |||||
| public String getBucketName() { | |||||
| return bucketName; | |||||
| } | |||||
| public void setBucketName(String bucketName) { | |||||
| this.bucketName = bucketName; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * @author Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "pay") | |||||
| public class PayProperty { | |||||
| /** | |||||
| * 真实支付 | |||||
| */ | |||||
| private boolean real; | |||||
| public boolean isReal() { | |||||
| return real; | |||||
| } | |||||
| public void setReal(boolean real) { | |||||
| this.real = real; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,111 @@ | |||||
| package com.iformall.config; | |||||
| import com.iformall.domain.po.PushLimit; | |||||
| import com.iformall.domain.po.WxScoreRules; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.cache.CacheManager; | |||||
| import org.springframework.cache.annotation.CachingConfigurerSupport; | |||||
| import org.springframework.cache.annotation.EnableCaching; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.data.redis.cache.RedisCacheConfiguration; | |||||
| import org.springframework.data.redis.cache.RedisCacheManager; | |||||
| import org.springframework.data.redis.connection.RedisConnectionFactory; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | |||||
| import org.springframework.data.redis.serializer.StringRedisSerializer; | |||||
| import java.time.Duration; | |||||
| import java.util.HashMap; | |||||
| import java.util.HashSet; | |||||
| import java.util.Map; | |||||
| import java.util.Set; | |||||
| /** | |||||
| * Created by Stormeye on 2018/10/1. | |||||
| */ | |||||
| @Configuration | |||||
| @EnableCaching | |||||
| public class RedisConfig extends CachingConfigurerSupport { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| //缓存管理器 | |||||
| @Bean | |||||
| public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { | |||||
| /* | |||||
| //user信息缓存配置 | |||||
| RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); | |||||
| Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>(); | |||||
| redisCacheConfigurationMap.put("user", userCacheConfiguration); | |||||
| //初始化一个RedisCacheWriter | |||||
| RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); | |||||
| // 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 | |||||
| // ClassLoader loader = this.getClass().getClassLoader(); | |||||
| // JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); | |||||
| // RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); | |||||
| // RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); | |||||
| RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); | |||||
| //设置默认超过期时间是30秒 | |||||
| defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); | |||||
| //初始化RedisCacheManager | |||||
| RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); | |||||
| return cacheManager; | |||||
| */ | |||||
| RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); // 生成一个默认配置,通过config对象即可对缓存进行自定义配置 | |||||
| config = config.entryTtl(Duration.ofMinutes(1)) // 设置缓存的默认过期时间,也是使用Duration设置 | |||||
| .disableCachingNullValues(); // 不缓存空值 | |||||
| // 设置一个初始化的缓存空间set集合 | |||||
| Set<String> cacheNames = new HashSet<>(); | |||||
| cacheNames.add("my-redis-cache1"); | |||||
| cacheNames.add("my-redis-cache2"); | |||||
| // 对每个缓存空间应用不同的配置 | |||||
| Map<String, RedisCacheConfiguration> configMap = new HashMap<>(); | |||||
| configMap.put("my-redis-cache1", config); | |||||
| configMap.put("my-redis-cache2", config.entryTtl(Duration.ofSeconds(120))); | |||||
| RedisCacheManager cacheManager = RedisCacheManager.builder(connectionFactory) // 使用自定义的缓存配置初始化一个cacheManager | |||||
| .initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置 | |||||
| .withInitialCacheConfigurations(configMap) | |||||
| .build(); | |||||
| return cacheManager; | |||||
| } | |||||
| @Bean("pushLimitRedisTemplate") | |||||
| public RedisTemplate<String, PushLimit> getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>(); | |||||
| Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("scoreRuleRedisTemplate") | |||||
| public RedisTemplate<String, WxScoreRules> getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>(); | |||||
| Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.config; | |||||
| import javax.servlet.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.IOException; | |||||
| import java.util.Optional; | |||||
| /** | |||||
| * 前后端分离RESTful接口过滤器 | |||||
| * | |||||
| * @author xuguoqin | |||||
| * | |||||
| */ | |||||
| public class RestFilter implements Filter { | |||||
| @Override | |||||
| public void init(FilterConfig filterConfig) throws ServletException { | |||||
| } | |||||
| @Override | |||||
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |||||
| throws IOException, ServletException { | |||||
| HttpServletRequest req = null; | |||||
| if (request instanceof HttpServletRequest) { | |||||
| req = (HttpServletRequest) request; | |||||
| } | |||||
| HttpServletResponse res = null; | |||||
| if (response instanceof HttpServletResponse) { | |||||
| res = (HttpServletResponse) response; | |||||
| } | |||||
| if (req != null && res != null) { | |||||
| //设置允许传递的参数 | |||||
| res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); | |||||
| //设置允许带上cookie | |||||
| res.setHeader("Access-Control-Allow-Credentials", "true"); | |||||
| String origin = Optional.ofNullable(req.getHeader("Origin")).orElse(req.getHeader("Referer")); | |||||
| //设置允许的请求来源 | |||||
| res.setHeader("Access-Control-Allow-Origin", origin); | |||||
| //设置允许的请求方法 | |||||
| res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS"); | |||||
| } | |||||
| chain.doFilter(request, response); | |||||
| } | |||||
| @Override | |||||
| public void destroy() { | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.client.ClientHttpRequestFactory; | |||||
| import org.springframework.http.client.SimpleClientHttpRequestFactory; | |||||
| import org.springframework.web.client.RestTemplate; | |||||
| @Configuration | |||||
| public class RestTemplateConfig { | |||||
| @Bean | |||||
| public RestTemplate restTemplate(ClientHttpRequestFactory factory) { | |||||
| return new RestTemplate(factory); | |||||
| } | |||||
| @Bean | |||||
| public ClientHttpRequestFactory simpleClientHttpRequestFactory() { | |||||
| SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); | |||||
| factory.setReadTimeout(5000);//ms | |||||
| factory.setConnectTimeout(10000);//ms | |||||
| return factory; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,79 @@ | |||||
| 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 org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.converter.HttpMessageConverter; | |||||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||||
| import org.springframework.web.servlet.config.annotation.CorsRegistry; | |||||
| import org.springframework.web.servlet.config.annotation.EnableWebMvc; | |||||
| import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | |||||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |||||
| import java.math.BigDecimal; | |||||
| import java.math.BigInteger; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.List; | |||||
| @Configuration | |||||
| @EnableWebMvc | |||||
| public class WebConfig implements WebMvcConfigurer { | |||||
| @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("/**") | |||||
| .allowedOrigins("*") | |||||
| .allowCredentials(true) | |||||
| .allowedMethods("GET", "POST", "DELETE", "PUT") | |||||
| .maxAge(3600); | |||||
| } | |||||
| @Override | |||||
| public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||||
| MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |||||
| //ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 | |||||
| ObjectMapper objectMapper = new ObjectMapper(); | |||||
| SimpleModule simpleModule = new SimpleModule(); | |||||
| //不显示为null的字段 | |||||
| objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||||
| DeserializationConfig dc = objectMapper.getDeserializationConfig(); | |||||
| // 设置反序列化日期格式、忽略不存在get、set的属性 | |||||
| objectMapper.setConfig( | |||||
| dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) | |||||
| .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |||||
| ); | |||||
| //序列化将Long转String类型 | |||||
| simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | |||||
| simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | |||||
| SimpleModule bigIntegerModule = new SimpleModule(); | |||||
| //序列化将BigInteger转String类型 | |||||
| bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); | |||||
| SimpleModule bigDecimalModule = new SimpleModule(); | |||||
| //序列化将BigDecimal转String类型 | |||||
| bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); | |||||
| objectMapper.registerModule(simpleModule); | |||||
| objectMapper.registerModule(bigDecimalModule); | |||||
| objectMapper.registerModule(bigIntegerModule); | |||||
| jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |||||
| converters.add(jackson2HttpMessageConverter); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,78 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.MailMsg; | |||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.iformall.enums.EnumMsgRecordType; | |||||
| import com.iformall.mq.MQConfig; | |||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.mq.impl.RabbitMqMessageProducer; | |||||
| import com.iformall.mq.impl.RocketMqMessageProducer; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.apache.commons.collections.map.HashedMap; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.context.annotation.Profile; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @Api(description = "登录相关接口") | |||||
| public class HomeController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Value("${version}") | |||||
| private String version; | |||||
| @Autowired | |||||
| private MqBaseProducer mqBaseProducer; | |||||
| // @Autowired | |||||
| // private RabbitMqMessageProducer rabbitMqMessageProducer; | |||||
| @Value("${spring.mail.username}") | |||||
| private String from; | |||||
| @ApiOperation("获取后端版本号") | |||||
| @GetMapping("/version") | |||||
| public ResultData version() { | |||||
| return new ResultData(version); | |||||
| } | |||||
| @GetMapping("/mqtest") | |||||
| public ResultData mqtest() { | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setSender("aa"); | |||||
| wxMsgRecord.setModelType(4); | |||||
| wxMsgRecord.setReceiver("18601973448"); | |||||
| wxMsgRecord.setSignature("富茂科技"); | |||||
| wxMsgRecord.setTenantId("456"); | |||||
| Map<String,String> map = new HashedMap(); | |||||
| map.put("contract","A11111"); | |||||
| map.put("page","www.baidu.com"); | |||||
| wxMsgRecord.setDynamicContentMap(map); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, "topic-1", "tag-1", "key-1"); | |||||
| return new ResultData(); | |||||
| } | |||||
| @GetMapping("/mail") | |||||
| public ResultData mail() { | |||||
| MailMsg wxMsgRecord = new MailMsg(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.EMAIL.getCode()); | |||||
| wxMsgRecord.setFrom(from); | |||||
| wxMsgRecord.setTo(new String[]{"luozukai@iformall.com"}); | |||||
| wxMsgRecord.setSubject("回家吃饭了"); | |||||
| wxMsgRecord.setMsg("大熊熊"); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, "topic-1", "tag-1", "key-1"); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,61 @@ | |||||
| package com.iformall.mq; | |||||
| import com.iformall.domain.po.BaseMsg; | |||||
| import com.iformall.domain.po.MailMsg; | |||||
| import com.iformall.domain.po.WxMsg; | |||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.iformall.enums.EnumMsgRecordStatus; | |||||
| import com.iformall.enums.EnumMsgRecordType; | |||||
| import com.iformall.mapper.WxMsgRecordMapper; | |||||
| import com.iformall.service.impl.SendCallBackSmsServiceImpl; | |||||
| import com.iformall.service.impl.SendEmailServiceImpl; | |||||
| import com.iformall.service.impl.SendSmsServiceImpl; | |||||
| import com.iformall.utils.JsonUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| @Slf4j | |||||
| @Service | |||||
| public class MqBaseConsumer { | |||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgRecordMapper wxMsgRecordMapper; | |||||
| @Autowired | |||||
| private SendSmsServiceImpl sendSmsService; | |||||
| @Autowired | |||||
| private SendCallBackSmsServiceImpl sendCallBackSmsService; | |||||
| @Autowired | |||||
| private SendEmailServiceImpl sendEmailService; | |||||
| public void doMessage(String message) { | |||||
| log.info("received message: {}", message); | |||||
| BaseMsg baseMsg = null; | |||||
| try { | |||||
| log.info("received message: {}", message); | |||||
| baseMsg = (BaseMsg)JsonUtil.readValue(message,BaseMsg.class); | |||||
| if(EnumMsgRecordType.SMS.getCode().equals(baseMsg.getMsgType())){ | |||||
| sendSmsService.send((WxMsgRecord)JsonUtil.readValue(message,WxMsgRecord.class)); | |||||
| }else if(EnumMsgRecordType.SMS_CALLBACK.getCode().equals(baseMsg.getMsgType())){ | |||||
| sendCallBackSmsService.send((WxMsg)JsonUtil.readValue(message,WxMsg.class)); | |||||
| }else if(EnumMsgRecordType.EMAIL.getCode().equals(baseMsg.getMsgType())){ | |||||
| sendEmailService.send((MailMsg)JsonUtil.readValue(message,MailMsg.class)); | |||||
| } | |||||
| baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); | |||||
| wxMsgRecordMapper.update(baseMsg); | |||||
| }catch (Throwable e){ | |||||
| e.printStackTrace(); | |||||
| if(null != baseMsg){ | |||||
| baseMsg.setStatusMessage(e.getMessage()); | |||||
| baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); | |||||
| wxMsgRecordMapper.update(baseMsg); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,89 @@ | |||||
| spring: | |||||
| profiles: | |||||
| include: rabbitMQ | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://202.165.179.86:3306/mallinkDev?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false | |||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | |||||
| password: ENC(WGu0+1DPIHrqorDhrbq1+7wr7xNG53mN) | |||||
| 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 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| #jackson: | |||||
| #date-format: yyyy-MM-dd HH:mm:ss | |||||
| # REDIS | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 50 | |||||
| max-idle: 50 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(R0bER9E9OB9/YQcpNXMyYDwofNVb8/pFl4nrApS8mi0=) | |||||
| password: ENC(50YqJd0iK/2r2YnmEd5RKaki3ktU73UDapBJrVYfqmc=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| 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: | |||||
| host: 202.165.179.86 | |||||
| port: 5672 | |||||
| username: guest | |||||
| password: guest | |||||
| publisher-confirms: true | |||||
| virtual-host: / | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | |||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | |||||
| jasypt: | |||||
| encryptor: | |||||
| password: oRqdnDbK5pj3eMmB | |||||
| fm: | |||||
| exception: false | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall.mapper: debug | |||||
| path: ./logs/s | |||||
| @@ -0,0 +1,65 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false | |||||
| username: ENC(NUzgQOdJnCbVLKT6BaX0aw==) | |||||
| password: ENC(mvuoDRiu0jqYaKNRwwTuXZ6U7aoIaqsjdiPqTLgi/nY=) | |||||
| 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 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| # REDIS | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 8 | |||||
| max-idle: 8 | |||||
| max-wait: -1 | |||||
| min-idle: 0 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(I2YKxnRVPY7J1r/bwzwHOhQCjj3nVqCWEbVTJvBq7y0=) | |||||
| password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | |||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | |||||
| fm: | |||||
| exception: true | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall: debug | |||||
| path: ./logs/s | |||||
| @@ -0,0 +1,63 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false | |||||
| username: ENC(Uc0AjgkytxHHCwZrmDASWg==) | |||||
| password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=) | |||||
| 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 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| # REDIS | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 8 | |||||
| max-idle: 8 | |||||
| max-wait: -1 | |||||
| min-idle: 0 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(HFbRXtAFVxU36Hk0yT3reyvRuLrw3RhMlbxFj9Ev/VY=) | |||||
| password: ENC(pk4+/3C5n2hMYmgi+VTqI4P1m77DllW8y4KElMXXmIo=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | |||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | |||||
| fm: | |||||
| exception: true | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall: debug | |||||
| path: ./logs/s | |||||
| @@ -0,0 +1,73 @@ | |||||
| server: | |||||
| port: 5001 | |||||
| servlet: | |||||
| context-path: /mq | |||||
| 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 | |||||
| servlet: | |||||
| multipart: | |||||
| max-file-size: 2MB | |||||
| max-request-size: 2MB | |||||
| cache: | |||||
| type: REDIS | |||||
| cache-names: redis_cache #缓存的名字(可以不指定) | |||||
| redis: | |||||
| time-to-live: 60000ms #很重要,缓存的有效时间,以便缓存的过期(单位为毫秒) | |||||
| 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: | |||||
| host: 202.165.179.86 | |||||
| port: 5672 | |||||
| username: guest | |||||
| password: guest | |||||
| publisher-confirms: true | |||||
| virtual-host: / | |||||
| # @{link} https://github.com/abel533 | |||||
| #Mybatis | |||||
| mybatis: | |||||
| type-aliases-package: com.iformall.domain.po | |||||
| mapper-locations: classpath:mapper/*Mapper.xml | |||||
| configuration: | |||||
| map-underscore-to-camel-case: true | |||||
| cache-enabled: true | |||||
| lazy-loading-enabled: true | |||||
| use-generated-keys: true | |||||
| default-fetch-size: 100 | |||||
| default-statement-timeout: 10 | |||||
| #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 | |||||
| pay: | |||||
| real: true | |||||
| version: @project.version@ | |||||
| @@ -0,0 +1,100 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <configuration scan="true" scanPeriod="10 seconds"> | |||||
| <!-- 外部指定路径 --> | |||||
| <springProperty scop="context" name="logPath" source="logging.path" /> | |||||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |||||
| <encoder> | |||||
| <Pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] --%mdc{client}%msg%n</Pattern> | |||||
| </encoder> | |||||
| </appender> | |||||
| <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/trace.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/trace.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| </appender> | |||||
| <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/info.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/info.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>INFO</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/debug.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/debug.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>DEBUG</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/warn.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/warn.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>WARN</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/error.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/error.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>ERROR</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <root level="TRACE"> | |||||
| <appender-ref ref="TRACE_FILE" /> | |||||
| <appender-ref ref="INFO_FILE" /> | |||||
| <!-- <appender-ref ref="DEBUG_FILE" /> --> | |||||
| <!-- <appender-ref ref="WARN_FILE" /> --> | |||||
| <appender-ref ref="ERROR_FILE" /> | |||||
| </root> | |||||
| <root level="INFO"> | |||||
| <appender-ref ref="STDOUT" /> | |||||
| </root> | |||||
| </configuration> | |||||
| @@ -1,11 +1,11 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.iformall.mq.MQConfig; | import com.iformall.mq.MQConfig; | ||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| import com.iformall.mq.impl.RabbitMqMessageProducer; | import com.iformall.mq.impl.RabbitMqMessageProducer; | ||||
| import com.iformall.mq.impl.RocketMqMessageProducer; | import com.iformall.mq.impl.RocketMqMessageProducer; | ||||
| import com.iformall.mq.MqProducer; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -30,7 +30,6 @@ public class HomeController { | |||||
| @Autowired | @Autowired | ||||
| private RabbitMqMessageProducer rabbitMqMessageProducer; | private RabbitMqMessageProducer rabbitMqMessageProducer; | ||||
| private MqProducer mqProducer; | |||||
| @ApiOperation("获取后端版本号") | @ApiOperation("获取后端版本号") | ||||
| @@ -41,8 +40,7 @@ public class HomeController { | |||||
| @GetMapping("/mqtest") | @GetMapping("/mqtest") | ||||
| public ResultData mqtest() { | public ResultData mqtest() { | ||||
| mqBaseProducer.sendMessage("mq test 1", "topic-1", "tag-1", "key-1"); | |||||
| mqProducer.sendMessage("mq test 1", "topic-1", "tag-1", "key-1"); | |||||
| mqBaseProducer.sendMessage(new WxMsgRecord(), "topic-1", "tag-1", "key-1"); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,25 +1,18 @@ | |||||
| package com.iformall.schedule; | package com.iformall.schedule; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxMsgCallback; | |||||
| import com.iformall.domain.po.WxMsgConfig; | |||||
| import com.iformall.domain.po.WxMsgValidationcode; | |||||
| import com.iformall.domain.po.WxMsgValidationcodeModel; | |||||
| import com.iformall.enums.EnumMsgModel; | |||||
| import com.iformall.enums.EnumMsgSendStatus; | |||||
| import com.iformall.enums.EnumVerifyCode; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.utils.WiwideUtil; | |||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import org.apache.commons.collections.map.HashedMap; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.scheduling.annotation.Scheduled; | import org.springframework.scheduling.annotation.Scheduled; | ||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | import java.math.RoundingMode; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -46,6 +39,9 @@ public class BillNotificationSchedule { | |||||
| @Autowired | @Autowired | ||||
| private WxMsgCallbackMapper wxMsgCallbackMapper; | private WxMsgCallbackMapper wxMsgCallbackMapper; | ||||
| @Autowired | |||||
| private MqBaseProducer mqBaseProducer; | |||||
| /** | /** | ||||
| * 每天9点执行 | * 每天9点执行 | ||||
| @@ -69,22 +65,17 @@ public class BillNotificationSchedule { | |||||
| String phone = bill.get("linkPhone").toString(); | String phone = bill.get("linkPhone").toString(); | ||||
| String appname = bill.get("appname").toString(); | String appname = bill.get("appname").toString(); | ||||
| logger.info("欠缴账单检验短信配置信息"); | logger.info("欠缴账单检验短信配置信息"); | ||||
| WxMsgConfig wxMsgConfig = checkMsgConfig(tenantId); | |||||
| if (wxMsgConfig != null) { | |||||
| logger.info("欠缴账单获取模板内容"); | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = getMsgModel(tenantId, EnumMsgModel.BILL_OWE.getCode()); | |||||
| if (wxMsgValidationcodeModel != null) { | |||||
| String signature = wxMsgValidationcodeModel.getSignature(); | |||||
| String msg = wxMsgValidationcodeModel.getContent(). | |||||
| replace("{price}", price.toString()). | |||||
| replace("{app}", appname); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| sendWaitPayBillMsg(phone, signature, msg, notifyUrl, secret, bid, publickey); | |||||
| } | |||||
| } | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.BILL_OWE.getCode()); | |||||
| wxMsgRecord.setReceiver(phone); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| Map<String,String> map = new HashedMap(); | |||||
| map.put("price",price.toString()); | |||||
| map.put("app",appname); | |||||
| wxMsgRecord.setDynamicContentMap(map); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -100,87 +91,38 @@ public class BillNotificationSchedule { | |||||
| String phone = bill.get("linkPhone").toString(); | String phone = bill.get("linkPhone").toString(); | ||||
| String appname = bill.get("appname").toString(); | String appname = bill.get("appname").toString(); | ||||
| logger.info("待缴账单检验短信配置信息"); | logger.info("待缴账单检验短信配置信息"); | ||||
| WxMsgConfig wxMsgConfig = checkMsgConfig(tenantId); | |||||
| if (wxMsgConfig != null) { | |||||
| logger.info("待缴账单获取模板内容"); | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = getMsgModel(tenantId, EnumMsgModel.BILL_WAIT_PAY.getCode()); | |||||
| if (wxMsgValidationcodeModel != null) { | |||||
| String signature = wxMsgValidationcodeModel.getSignature(); | |||||
| String msg = wxMsgValidationcodeModel.getContent(). | |||||
| replace("{price}", price.toString()). | |||||
| replace("{date}", receiveDate). | |||||
| replace("{app}", appname); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| sendWaitPayBillMsg(phone, signature, msg, notifyUrl, secret, bid, publickey); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| private WxMsgConfig checkMsgConfig(String tenantId) { | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(tenantId); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) { | |||||
| logger.info("缺少系统短信配置"); | |||||
| return null; | |||||
| } | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| if (wxMsgConfig.getRemains() == 0) { | |||||
| logger.info("短信数量为0"); | |||||
| return null; | |||||
| } | |||||
| return wxMsgConfigs.get(0); | |||||
| } | |||||
| private WxMsgValidationcodeModel getMsgModel(String tenantId, Integer type) { | |||||
| logger.info("获取通知模板-租户:" + tenantId + ",类型:" + type); | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgValidationcodeModel.setTenantId(tenantId); | |||||
| wxMsgValidationcodeModel.setType(type); | |||||
| List<WxMsgValidationcodeModel> list = wxMsgValidationcodelModelMapper.findList(wxMsgValidationcodeModel); | |||||
| if (!list.isEmpty()) { | |||||
| return wxMsgValidationcodelModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private void sendWaitPayBillMsg(String phone, String signature, String msg, String notifyUrl, String secret, String bid, String publickey) { | |||||
| logger.info("开始调用迈外迪短信接口"); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), null); | |||||
| logger.info("迈外迪短信接口返回值:" + result); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| String batchNo = jsonObjectResult.get("data").toString(); | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode())) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| wxMsgValidationcode.setCreatetime(new Date()); | |||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| addMsgCallback(wxMsgValidationcode, batchNo); | |||||
| // WxMsgConfig wxMsgConfig = checkMsgConfig(tenantId); | |||||
| // if (wxMsgConfig != null) { | |||||
| // logger.info("待缴账单获取模板内容"); | |||||
| // WxMsgValidationcodeModel wxMsgValidationcodeModel = getMsgModel(tenantId, EnumMsgModel.BILL_WAIT_PAY.getCode()); | |||||
| // if (wxMsgValidationcodeModel != null) { | |||||
| // String signature = wxMsgValidationcodeModel.getSignature(); | |||||
| // String msg = wxMsgValidationcodeModel.getContent(). | |||||
| // replace("{price}", price.toString()). | |||||
| // replace("{date}", receiveDate). | |||||
| // replace("{app}", appname); | |||||
| // String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| // String secret = wxMsgConfig.getSecret(); | |||||
| // String bid = wxMsgConfig.getBid(); | |||||
| // String publickey = wxMsgConfig.getPublickey(); | |||||
| // sendWaitPayBillMsg(phone, signature, msg, notifyUrl, secret, bid, publickey); | |||||
| // } | |||||
| // } | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.BILL_OWE.getCode()); | |||||
| wxMsgRecord.setReceiver(phone); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| Map<String,String> map = new HashedMap(); | |||||
| map.put("price",price.toString()); | |||||
| map.put("app",appname); | |||||
| map.put("date",receiveDate); | |||||
| wxMsgRecord.setDynamicContentMap(map); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | } | ||||
| } | |||||
| public void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo) { | |||||
| logger.info("验证码发送时主动添加回调记录开始..."); | |||||
| String phone = wxmsg.getPhone(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| WxMsgCallback wxMsgCallback = new WxMsgCallback(); | |||||
| wxMsgCallback.setId(idWorker.nextId()); | |||||
| wxMsgCallback.setPhone(phone); | |||||
| wxMsgCallback.setTenantId(wxmsg.getTenantId()); | |||||
| wxMsgCallback.setBatchNo(batchNo); | |||||
| wxMsgCallback.setMsgId(wxmsg.getId()); | |||||
| wxMsgCallback.setStatus(EnumMsgSendStatus.MSG_SENDING.getCode()); | |||||
| wxMsgCallback.setCreatetime(new Date()); | |||||
| wxMsgCallbackMapper.insertSelective(wxMsgCallback); | |||||
| logger.info("验证码发送时主动添加回调记录结束..."); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,24 +1,18 @@ | |||||
| package com.iformall.schedule; | package com.iformall.schedule; | ||||
| import com.alibaba.fastjson.JSONArray; | import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.domain.po.WxMsg; | import com.iformall.domain.po.WxMsg; | ||||
| import com.iformall.domain.po.WxMsgConfig; | |||||
| import com.iformall.domain.po.WxMsgModel; | |||||
| import com.iformall.enums.EnumMsgSendStatus; | |||||
| import com.iformall.enums.EnumMsgStatus; | |||||
| import com.iformall.enums.EnumVerifyCode; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.WxMsgConfigMapper; | import com.iformall.mapper.WxMsgConfigMapper; | ||||
| import com.iformall.mapper.WxMsgMapper; | import com.iformall.mapper.WxMsgMapper; | ||||
| import com.iformall.mapper.WxMsgModelMapper; | import com.iformall.mapper.WxMsgModelMapper; | ||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import com.iformall.utils.WiwideUtil; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.scheduling.annotation.Scheduled; | import org.springframework.scheduling.annotation.Scheduled; | ||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import java.util.List; | import java.util.List; | ||||
| /** | /** | ||||
| @@ -38,6 +32,9 @@ public class MsgSendingSchedule { | |||||
| @Autowired | @Autowired | ||||
| private WxMsgModelMapper wxMsgModelMapper; | private WxMsgModelMapper wxMsgModelMapper; | ||||
| @Autowired | |||||
| private MqBaseProducer mqBaseProducer; | |||||
| /** | /** | ||||
| * 每小时第一分钟执行 | * 每小时第一分钟执行 | ||||
| */ | */ | ||||
| @@ -51,55 +48,57 @@ public class MsgSendingSchedule { | |||||
| List<WxMsg> list = wxMsgMapper.findList(wxMsg); | List<WxMsg> list = wxMsgMapper.findList(wxMsg); | ||||
| logger.info("将要发送的短信列表:" + JSONArray.toJSONString(list)); | logger.info("将要发送的短信列表:" + JSONArray.toJSONString(list)); | ||||
| for (WxMsg msg : list) { | for (WxMsg msg : list) { | ||||
| sendmsg(msg); | |||||
| //sendmsg(msg); | |||||
| mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(),null); | |||||
| } | } | ||||
| logger.info("sendmsg定时任务结束"); | logger.info("sendmsg定时任务结束"); | ||||
| } | } | ||||
| public void sendmsg(WxMsg wxMsg) { | |||||
| logger.info("发送短信开始----------"); | |||||
| //从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(wxMsg.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) { | |||||
| logger.info("短信相关配置不存在"); | |||||
| return; | |||||
| } | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| if (wxMsgConfig.getRemains() == 0) { | |||||
| logger.info("短信数量为0"); | |||||
| return; | |||||
| } | |||||
| if (wxMsgConfig.getRemains() < wxMsg.getExpectSendNumber()) { | |||||
| logger.info("短信数量不足"); | |||||
| return; | |||||
| } | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| String phone = wxMsg.getPhones(); | |||||
| String signature = wxMsg.getSignature(); | |||||
| String msg = wxMsg.getMsg(); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| Integer modelId = null; | |||||
| Long modelIdParam = wxMsg.getModelId(); | |||||
| if (modelIdParam != null) { | |||||
| WxMsgModel wxMsgModel = wxMsgModelMapper.selectByPrimaryKey(modelIdParam); | |||||
| modelId = wxMsgModel.getModelId(); | |||||
| } | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.NO.getCode().toString(), modelId); | |||||
| logger.info("短信返回结果:" + result); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| if (ret.equals("1")) { | |||||
| wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode()); | |||||
| } else { | |||||
| wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | |||||
| } | |||||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||||
| wxMsgMapper.updateByPrimaryKeySelective(wxMsg); | |||||
| logger.info("短信发送结束:" + jsonObjectResult.toJSONString()); | |||||
| } | |||||
| // @Deprecated | |||||
| // public void sendmsg(WxMsg wxMsg) { | |||||
| // logger.info("发送短信开始----------"); | |||||
| // //从短信配置中查询密钥 bid 等信息 | |||||
| // WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| // wxMsgConfig.setTenantId(wxMsg.getTenantId()); | |||||
| // List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| // if (wxMsgConfigs.size() == 0) { | |||||
| // logger.info("短信相关配置不存在"); | |||||
| // return; | |||||
| // } | |||||
| // wxMsgConfig = wxMsgConfigs.get(0); | |||||
| // if (wxMsgConfig.getRemains() == 0) { | |||||
| // logger.info("短信数量为0"); | |||||
| // return; | |||||
| // } | |||||
| // if (wxMsgConfig.getRemains() < wxMsg.getExpectSendNumber()) { | |||||
| // logger.info("短信数量不足"); | |||||
| // return; | |||||
| // } | |||||
| // String secret = wxMsgConfig.getSecret(); | |||||
| // String bid = wxMsgConfig.getBid(); | |||||
| // String publickey = wxMsgConfig.getPublickey(); | |||||
| // String phone = wxMsg.getPhones(); | |||||
| // String signature = wxMsg.getSignature(); | |||||
| // String msg = wxMsg.getMsg(); | |||||
| // String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| // Integer modelId = null; | |||||
| // Long modelIdParam = wxMsg.getModelId(); | |||||
| // if (modelIdParam != null) { | |||||
| // WxMsgModel wxMsgModel = wxMsgModelMapper.selectByPrimaryKey(modelIdParam); | |||||
| // modelId = wxMsgModel.getModelId(); | |||||
| // } | |||||
| // String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.NO.getCode().toString(), modelId); | |||||
| // logger.info("短信返回结果:" + result); | |||||
| // JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| // String ret = jsonObjectResult.get("ret").toString(); | |||||
| // if (ret.equals("1")) { | |||||
| // wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode()); | |||||
| // } else { | |||||
| // wxMsg.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | |||||
| // } | |||||
| // wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||||
| // wxMsgMapper.updateByPrimaryKeySelective(wxMsg); | |||||
| // logger.info("短信发送结束:" + jsonObjectResult.toJSONString()); | |||||
| // } | |||||
| } | } | ||||
| @@ -365,6 +365,13 @@ public enum ErrorCode{ | |||||
| */ | */ | ||||
| DEVICE_NOT_FOUND(26000, "设备未找到"), | DEVICE_NOT_FOUND(26000, "设备未找到"), | ||||
| DEVICE_ALREADY_EXIST(26001, "设备已经存在"), | DEVICE_ALREADY_EXIST(26001, "设备已经存在"), | ||||
| /** | |||||
| * 消息组件 | |||||
| */ | |||||
| MSG_MODEL_NOT_FOUND(27000, "找不到短信模板"), | |||||
| MSG_CONFIG_NOT_FOUND(27001, "找不到短信配置"), | |||||
| ; | ; | ||||
| private int code; | private int code; | ||||
| @@ -0,0 +1,56 @@ | |||||
| package com.iformall.domain.po; | |||||
| import java.io.Serializable; | |||||
| /** | |||||
| * @author luozukai | |||||
| * @date 2019/3/7 10:05 | |||||
| */ | |||||
| public class BaseMsg implements Serializable { | |||||
| private static final long serialVersionUID = 923764283764823L; | |||||
| //唯一标识 | |||||
| private String uuid; | |||||
| //消息类型 1短信 2回调短信 3邮件 4微信小程序模板 5微信公众号模板 6系统通知 | |||||
| private Integer msgType; | |||||
| //消息状态 0默认1发送成功2消费成功3消费失败 | |||||
| private Integer msgStatus; | |||||
| //消费结果信息 | |||||
| private String statusMessage; | |||||
| public String getStatusMessage() { | |||||
| return statusMessage; | |||||
| } | |||||
| public void setStatusMessage(String statusMessage) { | |||||
| this.statusMessage = statusMessage; | |||||
| } | |||||
| public String getUuid() { | |||||
| return uuid; | |||||
| } | |||||
| public void setUuid(String uuid) { | |||||
| this.uuid = uuid; | |||||
| } | |||||
| public Integer getMsgStatus() { | |||||
| return msgStatus; | |||||
| } | |||||
| public void setMsgStatus(Integer msgStatus) { | |||||
| this.msgStatus = msgStatus; | |||||
| } | |||||
| public Integer getMsgType() { | |||||
| return msgType; | |||||
| } | |||||
| public void setMsgType(Integer msgType) { | |||||
| this.msgType = msgType; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,87 @@ | |||||
| package com.iformall.domain.po; | |||||
| /** | |||||
| * @author luozukai | |||||
| * @date 2019/3/7 10:05 | |||||
| */ | |||||
| public class MailMsg extends BaseMsg { | |||||
| private static final long serialVersionUID = 923764283760321L; | |||||
| private String[] to; | |||||
| private String from; | |||||
| private String msg; | |||||
| //标题 | |||||
| private String subject; | |||||
| //是否html格式 | |||||
| private boolean isHtml; | |||||
| //附件 | |||||
| private String filePath; | |||||
| //嵌入静态资源 | |||||
| private String rscPath; | |||||
| private String rscI; | |||||
| public String[] getTo() { | |||||
| return to; | |||||
| } | |||||
| public void setTo(String[] to) { | |||||
| this.to = to; | |||||
| } | |||||
| public String getFrom() { | |||||
| return from; | |||||
| } | |||||
| public void setFrom(String from) { | |||||
| this.from = from; | |||||
| } | |||||
| public String getMsg() { | |||||
| return msg; | |||||
| } | |||||
| public void setMsg(String msg) { | |||||
| this.msg = msg; | |||||
| } | |||||
| public String getSubject() { | |||||
| return subject; | |||||
| } | |||||
| public void setSubject(String subject) { | |||||
| this.subject = subject; | |||||
| } | |||||
| public boolean isHtml() { | |||||
| return isHtml; | |||||
| } | |||||
| public void setHtml(boolean html) { | |||||
| isHtml = html; | |||||
| } | |||||
| public String getFilePath() { | |||||
| return filePath; | |||||
| } | |||||
| public void setFilePath(String filePath) { | |||||
| this.filePath = filePath; | |||||
| } | |||||
| public String getRscPath() { | |||||
| return rscPath; | |||||
| } | |||||
| public void setRscPath(String rscPath) { | |||||
| this.rscPath = rscPath; | |||||
| } | |||||
| public String getRscI() { | |||||
| return rscI; | |||||
| } | |||||
| public void setRscI(String rscI) { | |||||
| this.rscI = rscI; | |||||
| } | |||||
| } | |||||
| @@ -8,7 +8,7 @@ import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| @Table(name = "wx_msg") | @Table(name = "wx_msg") | ||||
| public class WxMsg implements Serializable { | |||||
| public class WxMsg extends BaseMsg { | |||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @Id | @Id | ||||
| @@ -39,7 +39,6 @@ public class WxMsg implements Serializable { | |||||
| this.ids = ids; | this.ids = ids; | ||||
| } | } | ||||
| /*租户ID**/ | /*租户ID**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| @@ -101,6 +100,27 @@ public class WxMsg implements Serializable { | |||||
| @Transient | @Transient | ||||
| List<WxTags> tagsList; | List<WxTags> tagsList; | ||||
| //用于mq发送消息 | |||||
| private WxMsgConfig wxMsgConfig; | |||||
| private WxCouponInject couponInject; | |||||
| public WxMsgConfig getWxMsgConfig() { | |||||
| return wxMsgConfig; | |||||
| } | |||||
| public void setWxMsgConfig(WxMsgConfig wxMsgConfig) { | |||||
| this.wxMsgConfig = wxMsgConfig; | |||||
| } | |||||
| public WxCouponInject getCouponInject() { | |||||
| return couponInject; | |||||
| } | |||||
| public void setCouponInject(WxCouponInject couponInject) { | |||||
| this.couponInject = couponInject; | |||||
| } | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -2,225 +2,189 @@ package com.iformall.domain.po; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Table; | import javax.persistence.Table; | ||||
| import javax.persistence.Transient; | |||||
| import java.io.Serializable; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Table(name = "wx_msg_record") | @Table(name = "wx_msg_record") | ||||
| public class WxMsgRecord implements Serializable { | |||||
| public class WxMsgRecord extends BaseMsg { | |||||
| private static final long serialVersionUID = 18957895653478L; | private static final long serialVersionUID = 18957895653478L; | ||||
| @Id | @Id | ||||
| protected Long id; | protected Long id; | ||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public List<Long> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<Long> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| //uuid | |||||
| private String uuid; | |||||
| //租户id | //租户id | ||||
| private String tenantId; | private String tenantId; | ||||
| //域1sys 2a端 3c端 4b端 | //域1sys 2a端 3c端 4b端 | ||||
| private String group; | |||||
| //type | |||||
| private Integer type; | |||||
| //msg | |||||
| private Integer domain; | |||||
| //msg 消息类型1短信 2回调短信 邮件 3微信小程序模板 4微信公众号模板 5系统通 | |||||
| private String msg; | private String msg; | ||||
| //发送时间 | //发送时间 | ||||
| private String sendTime; | private String sendTime; | ||||
| //model_id | //model_id | ||||
| private Long modelId; | private Long modelId; | ||||
| //from,手机号邮件地址等 | //from,手机号邮件地址等 | ||||
| private String from; | |||||
| private String sender; | |||||
| //发送人id | //发送人id | ||||
| private Long fromUserId; | |||||
| private Long senderUserId; | |||||
| //发送人姓名 | //发送人姓名 | ||||
| private String fromUserName; | |||||
| private String senderUserName; | |||||
| //接收人,手机号邮件地址等 | //接收人,手机号邮件地址等 | ||||
| private String to; | |||||
| private String receiver; | |||||
| //接收人用户id | //接收人用户id | ||||
| private Long toUserId; | |||||
| private Long receiverUserId; | |||||
| //接收人姓名 | //接收人姓名 | ||||
| private String toUserName; | |||||
| //消费结果 | |||||
| private Integer status; | |||||
| //消费结果信息 | |||||
| private String statusMessage; | |||||
| private String receiverUserName; | |||||
| //签名 | //签名 | ||||
| private String signature; | private String signature; | ||||
| //模板类型 | //模板类型 | ||||
| private Integer modelType; | private Integer modelType; | ||||
| //动态内容(map结构的json数据) | |||||
| private String dynamicContent; | |||||
| //消息json | |||||
| private String msgJson; | |||||
| private Date createtime; | private Date createtime; | ||||
| private Date updatetime; | private Date updatetime; | ||||
| public String getDynamicContent() { | |||||
| return dynamicContent; | |||||
| } | |||||
| //动态替换内容 | |||||
| private Map<String,String> dynamicContentMap; | |||||
| private String dynamicContent; | |||||
| public void setDynamicContent(String dynamicContent) { | |||||
| this.dynamicContent = dynamicContent; | |||||
| } | |||||
| public Integer getModelType() { | |||||
| return modelType; | |||||
| public String getMsgJson() { | |||||
| return msgJson; | |||||
| } | } | ||||
| public void setModelType(Integer modelType) { | |||||
| this.modelType = modelType; | |||||
| public void setMsgJson(String msgJson) { | |||||
| this.msgJson = msgJson; | |||||
| } | } | ||||
| public String getSignature() { | |||||
| return signature; | |||||
| public Map<String, String> getDynamicContentMap() { | |||||
| return dynamicContentMap; | |||||
| } | } | ||||
| public void setSignature(String signature) { | |||||
| this.signature = signature; | |||||
| public void setDynamicContentMap(Map<String, String> dynamicContentMap) { | |||||
| this.dynamicContentMap = dynamicContentMap; | |||||
| } | } | ||||
| public String getUuid() { | |||||
| return uuid; | |||||
| public String getDynamicContent() { | |||||
| return dynamicContent; | |||||
| } | } | ||||
| public void setUuid(String uuid) { | |||||
| this.uuid = uuid; | |||||
| public void setDynamicContent(String dynamicContent) { | |||||
| this.dynamicContent = dynamicContent; | |||||
| } | } | ||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| public Long getId() { | |||||
| return id; | |||||
| } | } | ||||
| public void setTenantId(String tenantId) { | |||||
| this.tenantId = tenantId; | |||||
| public void setId(Long id) { | |||||
| this.id = id; | |||||
| } | } | ||||
| public String getGroup() { | |||||
| return group; | |||||
| public Integer getDomain() { | |||||
| return domain; | |||||
| } | } | ||||
| public void setGroup(String group) { | |||||
| this.group = group; | |||||
| public void setDomain(Integer domain) { | |||||
| this.domain = domain; | |||||
| } | } | ||||
| public Integer getType() { | |||||
| return type; | |||||
| public String getSender() { | |||||
| return sender; | |||||
| } | } | ||||
| public void setType(Integer type) { | |||||
| this.type = type; | |||||
| public void setSender(String sender) { | |||||
| this.sender = sender; | |||||
| } | } | ||||
| public String getMsg() { | |||||
| return msg; | |||||
| public Long getSenderUserId() { | |||||
| return senderUserId; | |||||
| } | } | ||||
| public void setMsg(String msg) { | |||||
| this.msg = msg; | |||||
| public void setSenderUserId(Long senderUserId) { | |||||
| this.senderUserId = senderUserId; | |||||
| } | } | ||||
| public String getSendTime() { | |||||
| return sendTime; | |||||
| public String getSenderUserName() { | |||||
| return senderUserName; | |||||
| } | } | ||||
| public void setSendTime(String sendTime) { | |||||
| this.sendTime = sendTime; | |||||
| public void setSenderUserName(String senderUserName) { | |||||
| this.senderUserName = senderUserName; | |||||
| } | } | ||||
| public Long getModelId() { | |||||
| return modelId; | |||||
| public String getReceiver() { | |||||
| return receiver; | |||||
| } | } | ||||
| public void setModelId(Long modelId) { | |||||
| this.modelId = modelId; | |||||
| public void setReceiver(String receiver) { | |||||
| this.receiver = receiver; | |||||
| } | } | ||||
| public String getFrom() { | |||||
| return from; | |||||
| public Long getReceiverUserId() { | |||||
| return receiverUserId; | |||||
| } | } | ||||
| public void setFrom(String from) { | |||||
| this.from = from; | |||||
| public void setReceiverUserId(Long receiverUserId) { | |||||
| this.receiverUserId = receiverUserId; | |||||
| } | } | ||||
| public Long getFromUserId() { | |||||
| return fromUserId; | |||||
| public String getReceiverUserName() { | |||||
| return receiverUserName; | |||||
| } | } | ||||
| public void setFromUserId(Long fromUserId) { | |||||
| this.fromUserId = fromUserId; | |||||
| public void setReceiverUserName(String receiverUserName) { | |||||
| this.receiverUserName = receiverUserName; | |||||
| } | } | ||||
| public String getFromUserName() { | |||||
| return fromUserName; | |||||
| public Integer getModelType() { | |||||
| return modelType; | |||||
| } | } | ||||
| public void setFromUserName(String fromUserName) { | |||||
| this.fromUserName = fromUserName; | |||||
| public void setModelType(Integer modelType) { | |||||
| this.modelType = modelType; | |||||
| } | } | ||||
| public String getTo() { | |||||
| return to; | |||||
| public String getSignature() { | |||||
| return signature; | |||||
| } | } | ||||
| public void setTo(String to) { | |||||
| this.to = to; | |||||
| public void setSignature(String signature) { | |||||
| this.signature = signature; | |||||
| } | } | ||||
| public Long getToUserId() { | |||||
| return toUserId; | |||||
| public String getTenantId() { | |||||
| return tenantId; | |||||
| } | } | ||||
| public void setToUserId(Long toUserId) { | |||||
| this.toUserId = toUserId; | |||||
| public void setTenantId(String tenantId) { | |||||
| this.tenantId = tenantId; | |||||
| } | } | ||||
| public String getToUserName() { | |||||
| return toUserName; | |||||
| public String getMsg() { | |||||
| return msg; | |||||
| } | } | ||||
| public void setToUserName(String toUserName) { | |||||
| this.toUserName = toUserName; | |||||
| public void setMsg(String msg) { | |||||
| this.msg = msg; | |||||
| } | } | ||||
| public Integer getStatus() { | |||||
| return status; | |||||
| public String getSendTime() { | |||||
| return sendTime; | |||||
| } | } | ||||
| public void setStatus(Integer status) { | |||||
| this.status = status; | |||||
| public void setSendTime(String sendTime) { | |||||
| this.sendTime = sendTime; | |||||
| } | } | ||||
| public String getStatusMessage() { | |||||
| return statusMessage; | |||||
| public Long getModelId() { | |||||
| return modelId; | |||||
| } | } | ||||
| public void setStatusMessage(String statusMessage) { | |||||
| this.statusMessage = statusMessage; | |||||
| public void setModelId(Long modelId) { | |||||
| this.modelId = modelId; | |||||
| } | } | ||||
| public Date getCreatetime() { | public Date getCreatetime() { | ||||
| @@ -239,62 +203,5 @@ public class WxMsgRecord implements Serializable { | |||||
| this.updatetime = updatetime; | this.updatetime = updatetime; | ||||
| } | } | ||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") | |||||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||||
| ,Available_ASC("`available` ASC"),Available_DESC("`available` DESC") | |||||
| ,Description_ASC("`description` ASC"),Description_DESC("`description` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(WxMsgRecord.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| List<Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,34 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by luozukai | |||||
| */ | |||||
| public enum EnumMsgMqKey { | |||||
| DEFAULT("key-1", "默认"), | |||||
| ; | |||||
| public static EnumMsgMqKey getEnum(String code) { | |||||
| for (EnumMsgMqKey value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private String code; | |||||
| private String message; | |||||
| EnumMsgMqKey(String code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public String getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,34 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by luozukai | |||||
| */ | |||||
| public enum EnumMsgMqTag { | |||||
| DEFAULT("tag-1", "默认"), | |||||
| ; | |||||
| public static EnumMsgMqTag getEnum(String code) { | |||||
| for (EnumMsgMqTag value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private String code; | |||||
| private String message; | |||||
| EnumMsgMqTag(String code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public String getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,34 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by luozukai | |||||
| */ | |||||
| public enum EnumMsgMqTopic { | |||||
| DEFAULT("topic-1", "默认"), | |||||
| ; | |||||
| public static EnumMsgMqTopic getEnum(String code) { | |||||
| for (EnumMsgMqTopic value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private String code; | |||||
| private String message; | |||||
| EnumMsgMqTopic(String code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public String getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,39 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by luozukai | |||||
| */ | |||||
| public enum EnumMsgRecordType { | |||||
| SMS(1, "短信"), | |||||
| SMS_CALLBACK(2, "业务短信"), | |||||
| EMAIL(3, "邮件"), | |||||
| SMART(4, "小程序"), | |||||
| PUBLIC(5, "公众号"), | |||||
| SYSTEM(6, "系统通知"), | |||||
| ; | |||||
| public static EnumMsgRecordType getEnum(Integer code) { | |||||
| for (EnumMsgRecordType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumMsgRecordType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -1,16 +1,12 @@ | |||||
| package com.iformall.mapper; | package com.iformall.mapper; | ||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.MallRole; | |||||
| import com.iformall.domain.po.BaseMsg; | |||||
| import com.iformall.domain.po.WxMsgRecord; | import com.iformall.domain.po.WxMsgRecord; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| public interface WxMsgRecordMapper extends CommonMapper<WxMsgRecord, String> { | public interface WxMsgRecordMapper extends CommonMapper<WxMsgRecord, String> { | ||||
| void update(WxMsgRecord record); | |||||
| void update(BaseMsg record); | |||||
| @@ -1,12 +0,0 @@ | |||||
| package com.iformall.mq; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.springframework.stereotype.Service; | |||||
| @Slf4j | |||||
| @Service | |||||
| public class MqBaseConsumer { | |||||
| public void doMessage(String message) { | |||||
| log.info("received message: {}", message); | |||||
| } | |||||
| } | |||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.mq; | package com.iformall.mq; | ||||
| import com.iformall.domain.po.BaseMsg; | |||||
| public interface MqBaseProducer { | public interface MqBaseProducer { | ||||
| void sendMessage(String data, String topic, String tags, String keys); | |||||
| void sendMessage(BaseMsg record, String topic, String tags, String keys); | |||||
| } | } | ||||
| @@ -1,12 +1,22 @@ | |||||
| package com.iformall.mq.impl; | package com.iformall.mq.impl; | ||||
| import com.iformall.domain.po.BaseMsg; | |||||
| import com.iformall.domain.po.WxMsg; | |||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.iformall.enums.EnumMsgRecordStatus; | |||||
| import com.iformall.mapper.WxMsgRecordMapper; | |||||
| import com.iformall.mq.MQConfig; | import com.iformall.mq.MQConfig; | ||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| import com.iformall.service.WxMsgRecordService; | |||||
| import com.iformall.utils.JsonUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.amqp.core.AmqpTemplate; | import org.springframework.amqp.core.AmqpTemplate; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Profile; | import org.springframework.context.annotation.Profile; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.UUID; | |||||
| /** | /** | ||||
| * @Auther: Stormeye | * @Auther: Stormeye | ||||
| @@ -17,15 +27,27 @@ import org.springframework.stereotype.Service; | |||||
| @Slf4j | @Slf4j | ||||
| @Profile(MQConfig.Impl.RABBIT_MQ) | @Profile(MQConfig.Impl.RABBIT_MQ) | ||||
| public class RabbitMqMessageProducer implements MqBaseProducer { | public class RabbitMqMessageProducer implements MqBaseProducer { | ||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | @Autowired | ||||
| private AmqpTemplate rabbitTemplate; | private AmqpTemplate rabbitTemplate; | ||||
| @Autowired | |||||
| private WxMsgRecordMapper wxMsgRecordMapper; | |||||
| @Autowired | |||||
| private WxMsgRecordService wxMsgRecordService; | |||||
| @Override | @Override | ||||
| public void sendMessage(String data, String topic, String tags, String keys) { | |||||
| public void sendMessage(BaseMsg data, String topic, String tags, String keys) { | |||||
| try { | try { | ||||
| rabbitTemplate.convertAndSend(topic, data); | |||||
| wxMsgRecordService.save(data); | |||||
| rabbitTemplate.convertAndSend(topic, JsonUtil.obj2Json(data)); | |||||
| data.setMsgStatus(EnumMsgRecordStatus.SEND_SUCC.getCode()); | |||||
| wxMsgRecordMapper.update(data); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| log.error("RabbitMqMessageProducer: Send Message Error ", e); | log.error("RabbitMqMessageProducer: Send Message Error ", e); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,7 +1,14 @@ | |||||
| package com.iformall.mq.impl; | package com.iformall.mq.impl; | ||||
| import com.iformall.domain.po.BaseMsg; | |||||
| import com.iformall.domain.po.WxMsg; | |||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.iformall.enums.EnumMsgRecordStatus; | |||||
| import com.iformall.mapper.WxMsgRecordMapper; | |||||
| import com.iformall.mq.MQConfig; | import com.iformall.mq.MQConfig; | ||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| import com.iformall.service.WxMsgRecordService; | |||||
| import com.iformall.utils.JsonUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.rocketmq.client.producer.DefaultMQProducer; | import org.apache.rocketmq.client.producer.DefaultMQProducer; | ||||
| import org.apache.rocketmq.client.producer.SendCallback; | import org.apache.rocketmq.client.producer.SendCallback; | ||||
| @@ -10,11 +17,12 @@ import org.apache.rocketmq.common.message.Message; | |||||
| import org.apache.rocketmq.remoting.common.RemotingHelper; | import org.apache.rocketmq.remoting.common.RemotingHelper; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.context.annotation.Profile; | import org.springframework.context.annotation.Profile; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import javax.annotation.PostConstruct; | import javax.annotation.PostConstruct; | ||||
| import java.util.UUID; | |||||
| /** | /** | ||||
| * @Auther: Stormeye | * @Auther: Stormeye | ||||
| @@ -25,11 +33,19 @@ import javax.annotation.PostConstruct; | |||||
| @Slf4j | @Slf4j | ||||
| @Profile(MQConfig.Impl.ROCKET_MQ) | @Profile(MQConfig.Impl.ROCKET_MQ) | ||||
| public class RocketMqMessageProducer implements MqBaseProducer { | public class RocketMqMessageProducer implements MqBaseProducer { | ||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | |||||
| @Value("${spring.rocketmq.nameServer}") | @Value("${spring.rocketmq.nameServer}") | ||||
| private String namesrvAddr; | private String namesrvAddr; | ||||
| private static final DefaultMQProducer producer = new DefaultMQProducer("DefaultProducer"); | private static final DefaultMQProducer producer = new DefaultMQProducer("DefaultProducer"); | ||||
| @Autowired | |||||
| private WxMsgRecordMapper wxMsgRecordMapper; | |||||
| @Autowired | |||||
| private WxMsgRecordService wxMsgRecordService; | |||||
| @PostConstruct | @PostConstruct | ||||
| public void start(){ | public void start(){ | ||||
| try { | try { | ||||
| @@ -42,9 +58,11 @@ public class RocketMqMessageProducer implements MqBaseProducer { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void sendMessage(String data, String topic, String tags, String keys) { | |||||
| public void sendMessage(BaseMsg data, String topic, String tags, String keys) { | |||||
| try { | try { | ||||
| byte[] messageBody = data.getBytes(RemotingHelper.DEFAULT_CHARSET); | |||||
| wxMsgRecordService.save(data); | |||||
| byte[] messageBody = JsonUtil.obj2Json(data).getBytes(RemotingHelper.DEFAULT_CHARSET); | |||||
| Message mqMsg = new Message(topic, tags, keys, messageBody); | Message mqMsg = new Message(topic, tags, keys, messageBody); | ||||
| @@ -52,6 +70,8 @@ public class RocketMqMessageProducer implements MqBaseProducer { | |||||
| @Override | @Override | ||||
| public void onSuccess(SendResult sendResult) { | public void onSuccess(SendResult sendResult) { | ||||
| log.info("Message Producer: Send Message Success {}", sendResult); | log.info("Message Producer: Send Message Success {}", sendResult); | ||||
| // data.setMsgStatus(EnumMsgRecordStatus.SEND_SUCC.getCode()); | |||||
| // wxMsgRecordMapper.update(data); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -64,4 +84,5 @@ public class RocketMqMessageProducer implements MqBaseProducer { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,12 +1,10 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.iformall.domain.po.BaseMsg; | |||||
| /** | |||||
| * 发送消息 | |||||
| */ | |||||
| public interface MsgSendService { | public interface MsgSendService { | ||||
| void send(WxMsgRecord record); | |||||
| void send(BaseMsg baseMsg) throws Exception; | |||||
| } | } | ||||
| @@ -0,0 +1,7 @@ | |||||
| package com.iformall.service; | |||||
| import com.iformall.domain.po.BaseMsg; | |||||
| public interface WxMsgRecordService { | |||||
| void save(BaseMsg baseMsg); | |||||
| } | |||||
| @@ -43,4 +43,5 @@ public interface WxMsgService { | |||||
| void sendMsgFromCouponInject(WxMsg wxmsg, WxMsgConfig wxMsgConfig, WxCouponInject record); | void sendMsgFromCouponInject(WxMsg wxmsg, WxMsgConfig wxMsgConfig, WxCouponInject record); | ||||
| void addMsgCallback(WxMsg wxmsg, String batchNo); | |||||
| } | } | ||||
| @@ -7,21 +7,10 @@ import com.iformall.domain.po.WxMsgValidationcode; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| public interface WxMsgValidationcodeService { | public interface WxMsgValidationcodeService { | ||||
| /** | |||||
| * 发送审批流通知短信 | |||||
| * @param wxMsgValidationcode | |||||
| * @param dynamicContentMap 动态替换的内容 | |||||
| * @return | |||||
| */ | |||||
| ResultData sendWorkFlowNodify(WxMsgValidationcode wxMsgValidationcode, Map<String,String> dynamicContentMap); | |||||
| /** | /** | ||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| * | * | ||||
| * @param record | * @param record | ||||
| * @param offset | |||||
| * @param limit | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize); | PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize); | ||||
| @@ -54,7 +43,7 @@ public interface WxMsgValidationcodeService { | |||||
| ResultData hasvalidationcode(WxMsgValidationcode record); | ResultData hasvalidationcode(WxMsgValidationcode record); | ||||
| void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo); | |||||
| } | } | ||||
| @@ -0,0 +1,125 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumMsgSendStatus; | |||||
| import com.iformall.enums.EnumVerifyCode; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | |||||
| import com.iformall.service.MsgSendService; | |||||
| import com.iformall.service.WxMsgService; | |||||
| import com.iformall.service.WxMsgValidationcodeService; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.WiwideUtil; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author luozukai | |||||
| * 业务短信发送实现 | |||||
| */ | |||||
| @Service | |||||
| public class SendCallBackSmsServiceImpl implements MsgSendService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgConfigMapper wxMsgConfigMapper; | |||||
| @Autowired | |||||
| private WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | |||||
| @Autowired | |||||
| private WxMsgValidationcodeMapper wxMsgValidationcodeMapper; | |||||
| @Autowired | |||||
| private WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
| @Autowired | |||||
| private WxMsgModelMapper wxMsgModelMapper; | |||||
| @Autowired | |||||
| private WxMsgMapper wxMsgMapper; | |||||
| @Autowired | |||||
| private WxMsgService wxMsgService; | |||||
| @Override | |||||
| public void send(BaseMsg baseMsg) { | |||||
| WxMsg record = (WxMsg)baseMsg; | |||||
| WxMsgConfig wxMsgConfig = record.getWxMsgConfig(); | |||||
| if(wxMsgConfig == null){ | |||||
| wxMsgConfig.setTenantId(record.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) { | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_NOT_FOUND); | |||||
| } | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| if (wxMsgConfig.getRemains() == 0) { | |||||
| throw new MallinkException(ErrorCode.MSG_SUM_ZERO); | |||||
| } | |||||
| if (wxMsgConfig.getRemains() < record.getExpectSendNumber()) { | |||||
| throw new MallinkException(ErrorCode.MSG_SUM_INSUFFICENT); | |||||
| } | |||||
| } | |||||
| WxCouponInject couponInject = record.getCouponInject(); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| String phone = record.getPhones(); | |||||
| String signature = record.getSignature(); | |||||
| String msg = record.getMsg(); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| WxMsgModel wxMsgModel = wxMsgModelMapper.selectByPrimaryKey(record.getModelId()); | |||||
| Integer modelId = null; | |||||
| if (wxMsgModel != null) { | |||||
| modelId = wxMsgModel.getModelId(); | |||||
| } | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.NO.getCode().toString(), modelId); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| String batchNo = jsonObjectResult.get("data").toString(); | |||||
| //String resultMsg = jsonObjectResult.get("msg").toString(); | |||||
| record.setReturnResult(jsonObjectResult.toJSONString()); | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| record.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode()); | |||||
| } else { | |||||
| record.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| long id = idWorker.nextId(); | |||||
| WxMsg wxMsg = new WxMsg(); | |||||
| wxMsg.setTenantId(record.getTenantId()); | |||||
| wxMsg.setModelId(record.getModelId()); | |||||
| wxMsg.setMsg(record.getMsg()); | |||||
| wxMsg.setExpectSendNumber(record.getExpectSendNumber()); | |||||
| wxMsg.setPhones(record.getPhones()); | |||||
| wxMsg.setSignature(record.getSignature()); | |||||
| wxMsg.setIsright(record.getIsright()); | |||||
| wxMsg.setName(record.getName()); | |||||
| wxMsg.setSendstatus(record.getSendstatus()); | |||||
| wxMsg.setLabel(record.getLabel()); | |||||
| wxMsg.setStatus(record.getStatus()); | |||||
| wxMsg.setWay(record.getWay()); | |||||
| wxMsg.setId(id); | |||||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); | |||||
| wxMsg.setSendtime(systemTime); | |||||
| wxMsg.setCreatetime(DateUtils.stringToDate(systemTime, "yyyy-MM-dd HH:mm:ss")); | |||||
| //精准投放 | |||||
| if (couponInject != null) { | |||||
| wxMsg.setCouponInjectId(couponInject.getId()); | |||||
| } | |||||
| wxMsgMapper.insertSelective(wxMsg); | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| wxMsgService.addMsgCallback(wxMsg, batchNo); | |||||
| } else { | |||||
| logger.error("SendCallBackSmsServiceImpl 运营商返回失败,wxmsg.id:{},message:{}",id,result); | |||||
| throw new MallinkException(ErrorCode.MSG_SEND_INTERFACE_ERROR); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,85 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.iformall.domain.po.BaseMsg; | |||||
| import com.iformall.domain.po.MailMsg; | |||||
| import com.iformall.service.MsgSendService; | |||||
| 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.Value; | |||||
| import org.springframework.core.io.FileSystemResource; | |||||
| import org.springframework.mail.SimpleMailMessage; | |||||
| import org.springframework.mail.javamail.JavaMailSender; | |||||
| import org.springframework.mail.javamail.MimeMessageHelper; | |||||
| import org.springframework.stereotype.Service; | |||||
| import javax.mail.internet.MimeMessage; | |||||
| import java.io.File; | |||||
| /** | |||||
| * 发送邮件 | |||||
| * @author luozukai | |||||
| * @date 2019/3/7 16:03 | |||||
| */ | |||||
| @Service | |||||
| public class SendEmailServiceImpl implements MsgSendService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private JavaMailSender sender; | |||||
| @Value("${spring.mail.username}") | |||||
| private String from; | |||||
| @Override | |||||
| public void send(BaseMsg baseMsg) throws Exception{ | |||||
| MailMsg mailMsg = (MailMsg)baseMsg; | |||||
| if(mailMsg.isHtml()){ | |||||
| MimeMessage message = sender.createMimeMessage(); | |||||
| MimeMessageHelper helper = new MimeMessageHelper(message, true); | |||||
| helper.setFrom(from); | |||||
| helper.setTo(mailMsg.getTo()); | |||||
| helper.setSubject(mailMsg.getSubject()); | |||||
| helper.setText(mailMsg.getMsg(), true); | |||||
| sender.send(message); | |||||
| logger.info("html邮件已经发送。"); | |||||
| }else if(StringUtils.isNotBlank(mailMsg.getFilePath())){ | |||||
| MimeMessage message = sender.createMimeMessage(); | |||||
| String filePath = mailMsg.getFilePath(); | |||||
| MimeMessageHelper helper = new MimeMessageHelper(message, true); | |||||
| helper.setFrom(from); | |||||
| helper.setTo(mailMsg.getTo()); | |||||
| helper.setSubject(mailMsg.getSubject()); | |||||
| helper.setText(mailMsg.getMsg(), true); | |||||
| FileSystemResource file = new FileSystemResource(new File(filePath)); | |||||
| String fileName = filePath.substring(filePath.lastIndexOf(File.separator)); | |||||
| helper.addAttachment(fileName, file); | |||||
| sender.send(message); | |||||
| logger.info("带附件的邮件已经发送。"); | |||||
| }else if(StringUtils.isNotBlank(mailMsg.getRscI()) && StringUtils.isNotBlank(mailMsg.getRscPath())){ | |||||
| MimeMessage message = sender.createMimeMessage(); | |||||
| MimeMessageHelper helper = new MimeMessageHelper(message, true); | |||||
| helper.setFrom(from); | |||||
| helper.setTo(mailMsg.getTo()); | |||||
| helper.setSubject(mailMsg.getSubject()); | |||||
| helper.setText(mailMsg.getMsg(), true); | |||||
| FileSystemResource res = new FileSystemResource(new File(mailMsg.getRscPath())); | |||||
| helper.addInline(mailMsg.getRscI(), res); | |||||
| sender.send(message); | |||||
| logger.info("嵌入静态资源的邮件已经发送。"); | |||||
| }else{ | |||||
| SimpleMailMessage message = new SimpleMailMessage(); | |||||
| message.setFrom(from); | |||||
| message.setTo(mailMsg.getTo()); | |||||
| message.setSubject(mailMsg.getSubject()); | |||||
| message.setText(mailMsg.getMsg()); | |||||
| sender.send(message); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,25 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.iformall.domain.po.WxMsgRecord; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumVerifyCode; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxMsgConfigMapper; | |||||
| import com.iformall.mapper.WxMsgValidationcodeMapper; | |||||
| import com.iformall.mapper.WxMsgValidationcodeModelMapper; | |||||
| import com.iformall.service.MsgSendService; | import com.iformall.service.MsgSendService; | ||||
| import com.iformall.service.WxMsgValidationcodeService; | |||||
| import com.iformall.utils.WiwideUtil; | |||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * @author luozukai | * @author luozukai | ||||
| @@ -10,9 +27,82 @@ import org.springframework.stereotype.Service; | |||||
| */ | */ | ||||
| @Service | @Service | ||||
| public class SendSmsServiceImpl implements MsgSendService { | public class SendSmsServiceImpl implements MsgSendService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxMsgConfigMapper wxMsgConfigMapper; | |||||
| @Autowired | |||||
| private WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | |||||
| @Autowired | |||||
| private WxMsgValidationcodeMapper wxMsgValidationcodeMapper; | |||||
| @Autowired | |||||
| private WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
| @Override | @Override | ||||
| public void send(WxMsgRecord record) { | |||||
| public void send(BaseMsg baseMsg) { | |||||
| WxMsgRecord record = (WxMsgRecord)baseMsg; | |||||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setPhone(record.getReceiver()); | |||||
| wxMsgValidationcode.setTenantId(record.getTenantId()); | |||||
| wxMsgValidationcode.setType(record.getModelType()); | |||||
| //3、从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(record.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if(CollectionUtils.isEmpty(wxMsgConfigs)){ | |||||
| throw new MallinkException(ErrorCode.MSG_CONFIG_NOT_FOUND); | |||||
| } | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgValidationcodeModel.setTenantId(record.getTenantId()); | |||||
| wxMsgValidationcodeModel.setType(record.getModelType()); | |||||
| List<WxMsgValidationcodeModel> modelList = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel); | |||||
| if(CollectionUtils.isEmpty(modelList)){ | |||||
| throw new MallinkException(ErrorCode.MSG_MODEL_NOT_FOUND); | |||||
| } | |||||
| wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| String phone = record.getReceiver(); | |||||
| String signature = wxMsgValidationcodeModel.getSignature(); | |||||
| wxMsgValidationcode.setSignature(signature); | |||||
| //替换内容 | |||||
| String msg = wxMsgValidationcodeModel.getContent(); | |||||
| for (Map.Entry<String, String> entry : record.getDynamicContentMap().entrySet()) { | |||||
| msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | |||||
| } | |||||
| wxMsgValidationcode.setMsg(msg); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| String batchNo = jsonObjectResult.get("data").toString(); | |||||
| if (ret.equals("1")) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| long currentTime = System.currentTimeMillis() ; | |||||
| Date createtime=new Date(currentTime); | |||||
| wxMsgValidationcode.setCreatetime(createtime); | |||||
| Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||||
| if(minutes >0) { | |||||
| currentTime += minutes * 60 * 1000; | |||||
| Date expiredate = new Date(currentTime); | |||||
| wxMsgValidationcode.setExpiretime(expiredate); | |||||
| } | |||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| wxMsgValidationcodeService.addMsgCallback(wxMsgValidationcode,batchNo); | |||||
| logger.error("短信运营商返回成功,手机号:{}",phone); | |||||
| }else{ | |||||
| logger.error("短信运营商返回失败,手机号:{},返回信息:{}",phone,result); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -10,6 +10,7 @@ import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| @@ -56,8 +57,6 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| @Autowired | @Autowired | ||||
| private MallUserInfoService mallUserInfoService; | private MallUserInfoService mallUserInfoService; | ||||
| @Autowired | @Autowired | ||||
| private WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
| @Autowired | |||||
| private WxRentContractMapper wxRentContractMapper; | private WxRentContractMapper wxRentContractMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxPropertyContractMapper wxPropertyContractMapper; | private WxPropertyContractMapper wxPropertyContractMapper; | ||||
| @@ -71,6 +70,8 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| private WxBillPropertyMapper wxBillPropertyMapper; | private WxBillPropertyMapper wxBillPropertyMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxMerchantService wxMerchantService; | private WxMerchantService wxMerchantService; | ||||
| @Autowired | |||||
| private MqBaseProducer mqBaseProducer; | |||||
| /** | /** | ||||
| * 获取流程key,1合同 2账单 | * 获取流程key,1合同 2账单 | ||||
| @@ -241,11 +242,13 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| content.put("userName",starterInfo.getName()); | content.put("userName",starterInfo.getName()); | ||||
| content.put("page", Constant.adminPage); | content.put("page", Constant.adminPage); | ||||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setTenantId(tenantId); | |||||
| wxMsgValidationcode.setPhone(mallUserInfo.getPhone()); | |||||
| wxMsgValidationcode.setType(EnumMsgModel.FLOW_ASSIGNEE_NODIFY.getCode()); | |||||
| wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,content); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_ASSIGNEE_NODIFY.getCode()); | |||||
| wxMsgRecord.setReceiver(mallUserInfo.getPhone()); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| wxMsgRecord.setDynamicContentMap(content); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | } | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -472,10 +475,13 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("userName",userName); | msgReplaceMap.put("userName",userName); | ||||
| msgReplaceMap.put("page",Constant.adminPage); | msgReplaceMap.put("page",Constant.adminPage); | ||||
| assignee += mallUserInfo.getName()+" "; | |||||
| wxMsgValidationcode.setPhone(mallUserInfo.getPhone()); | |||||
| wxMsgValidationcode.setType(EnumMsgModel.FLOW_ASSIGNEE_NODIFY.getCode()); | |||||
| wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_ASSIGNEE_NODIFY.getCode()); | |||||
| wxMsgRecord.setReceiver(mallUserInfo.getPhone()); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | } | ||||
| // 给发起人发送短信 | // 给发起人发送短信 | ||||
| @@ -485,10 +491,13 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract",businessId+""); | msgReplaceMap.put("contract",businessId+""); | ||||
| msgReplaceMap.put("toUserName",assignee.trim()); | msgReplaceMap.put("toUserName",assignee.trim()); | ||||
| wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setPhone(userMap!=null?(String)userMap.get("phone"):""); | |||||
| wxMsgValidationcode.setType(EnumMsgModel.FLOW_APPLY_NODIFY.getCode()); | |||||
| wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_APPLY_NODIFY.getCode()); | |||||
| wxMsgRecord.setReceiver(userMap!=null?(String)userMap.get("phone"):""); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| return false; | return false; | ||||
| }else{ | }else{ | ||||
| //继续递归判断 | //继续递归判断 | ||||
| @@ -501,10 +510,14 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap = new HashedMap(); | msgReplaceMap = new HashedMap(); | ||||
| msgReplaceMap.put("contract",businessId+""); | msgReplaceMap.put("contract",businessId+""); | ||||
| msgReplaceMap.put("page",Constant.adminPage); | msgReplaceMap.put("page",Constant.adminPage); | ||||
| wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setPhone(userMap!=null?(String)userMap.get("phone"):""); | |||||
| wxMsgValidationcode.setType(EnumMsgModel.FLOW_PASS_NODIFY.getCode()); | |||||
| wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_PASS_NODIFY.getCode()); | |||||
| wxMsgRecord.setReceiver(userMap!=null?(String)userMap.get("phone"):""); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -583,10 +596,13 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| msgReplaceMap.put("contract",businessId+""); | msgReplaceMap.put("contract",businessId+""); | ||||
| msgReplaceMap.put("page",Constant.adminPage); | msgReplaceMap.put("page",Constant.adminPage); | ||||
| wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setPhone(userMap!=null?(String)userMap.get("phone"):""); | |||||
| wxMsgValidationcode.setType(EnumMsgModel.FLOW_REJECT_NODIFY.getCode()); | |||||
| wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(EnumMsgModel.FLOW_REJECT_NODIFY.getCode()); | |||||
| wxMsgRecord.setReceiver(userMap!=null?(String)userMap.get("phone"):""); | |||||
| wxMsgRecord.setTenantId(tenantId); | |||||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -7,17 +7,16 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMallApply; | |||||
| import com.iformall.domain.po.WxMsgConfig; | |||||
| import com.iformall.domain.po.WxMsgValidationcode; | |||||
| import com.iformall.domain.po.WxMsgValidationcodeModel; | |||||
| import com.iformall.enums.EnumVerifyCode; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.WxMallApplyMapper; | import com.iformall.mapper.WxMallApplyMapper; | ||||
| import com.iformall.mapper.WxMsgConfigMapper; | import com.iformall.mapper.WxMsgConfigMapper; | ||||
| import com.iformall.mapper.WxMsgValidationcodeMapper; | import com.iformall.mapper.WxMsgValidationcodeMapper; | ||||
| import com.iformall.mapper.WxMsgValidationcodeModelMapper; | import com.iformall.mapper.WxMsgValidationcodeModelMapper; | ||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.WxMallApplyService; | import com.iformall.service.WxMallApplyService; | ||||
| import com.iformall.utils.*; | import com.iformall.utils.*; | ||||
| import org.apache.commons.collections.map.HashedMap; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -42,6 +41,8 @@ public class WxMallApplyServiceImpl implements WxMallApplyService { | |||||
| @Autowired | @Autowired | ||||
| WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | WxMsgValidationcodeModelMapper wxMsgValidationcodeModelMapper; | ||||
| @Autowired | |||||
| private MqBaseProducer mqBaseProducer; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMallApply> listAsPage(WxMallApply record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMallApply> listAsPage(WxMallApply record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -83,7 +84,7 @@ public class WxMallApplyServiceImpl implements WxMallApplyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData sendvalidationcode(WxMsgValidationcode wxMsgValidationcode) { | |||||
| public ResultData sendvalidationcode(WxMsgValidationcode wxMsgValidationcode){ | |||||
| //1、查看是否存在未过期的短信,有返回成功 没有继续 | //1、查看是否存在未过期的短信,有返回成功 没有继续 | ||||
| List<WxMsgValidationcode> wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | List<WxMsgValidationcode> wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | ||||
| Date currentdate = new Date(); | Date currentdate = new Date(); | ||||
| @@ -91,54 +92,65 @@ public class WxMallApplyServiceImpl implements WxMallApplyService { | |||||
| validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); | validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); | ||||
| if(wxmsgvalidationcodelist.size()>0) return new ResultData(ErrorCode.MSG_REPEAT_SEND.getCode(),ErrorCode.MSG_REPEAT_SEND.getMessage()); | if(wxmsgvalidationcodelist.size()>0) return new ResultData(ErrorCode.MSG_REPEAT_SEND.getCode(),ErrorCode.MSG_REPEAT_SEND.getMessage()); | ||||
| //3、从短信配置中查询密钥 bid 等信息 | //3、从短信配置中查询密钥 bid 等信息 | ||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgValidationcodeModel.setTenantId(wxMsgConfig.getTenantId()); | |||||
| wxMsgValidationcodeModel.setType(wxMsgValidationcode.getType()); | |||||
| wxMsgValidationcodeModel.setName("验证码"); | |||||
| wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| // WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| // wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| // List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| // if (wxMsgConfigs.size() == 0) new ResultData(500,"发送失败"); | |||||
| // wxMsgConfig = wxMsgConfigs.get(0); | |||||
| // | |||||
| // WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| // wxMsgValidationcodeModel.setTenantId(wxMsgConfig.getTenantId()); | |||||
| // wxMsgValidationcodeModel.setType(wxMsgValidationcode.getType()); | |||||
| // wxMsgValidationcodeModel.setName("验证码"); | |||||
| // wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| // wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||||
| // | |||||
| // String secret = wxMsgConfig.getSecret(); | |||||
| // String bid = wxMsgConfig.getBid(); | |||||
| // String publickey = wxMsgConfig.getPublickey(); | |||||
| // //验证码 | |||||
| // int code = (int) ((Math.random() * 9 + 1) * 100000); | |||||
| // String phone = wxMsgValidationcode.getPhone(); | |||||
| // String signature = wxMsgValidationcode.getSignature(); | |||||
| // //内容 | |||||
| // String msg = wxMsgValidationcodeModel.getContent().replace("{s6}", String.valueOf(code)); | |||||
| // wxMsgValidationcode.setCode(String.valueOf(code)); | |||||
| // wxMsgValidationcode.setMsg(msg); | |||||
| // | |||||
| // String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| // Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| // String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| // JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| // String ret = jsonObjectResult.get("ret").toString(); | |||||
| // | |||||
| // if (ret.equals("1")) { | |||||
| // final IdWorker idWorker = IdWorker.get(); | |||||
| // wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| // long currentTime = System.currentTimeMillis() ; | |||||
| // Date createtime=new Date(currentTime); | |||||
| // Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||||
| // currentTime +=minutes*60*1000; | |||||
| // Date expiredate=new Date(currentTime); | |||||
| // wxMsgValidationcode.setExpiretime(expiredate); | |||||
| // wxMsgValidationcode.setCreatetime(createtime); | |||||
| // wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| // return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| // } | |||||
| //验证码 | //验证码 | ||||
| int code = (int) ((Math.random() * 9 + 1) * 100000); | int code = (int) ((Math.random() * 9 + 1) * 100000); | ||||
| String phone = wxMsgValidationcode.getPhone(); | |||||
| String signature = wxMsgValidationcode.getSignature(); | |||||
| //内容 | |||||
| String msg = wxMsgValidationcodeModel.getContent().replace("{s6}", String.valueOf(code)); | |||||
| wxMsgValidationcode.setCode(String.valueOf(code)); | |||||
| wxMsgValidationcode.setMsg(msg); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| if (ret.equals("1")) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| long currentTime = System.currentTimeMillis() ; | |||||
| Date createtime=new Date(currentTime); | |||||
| Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||||
| currentTime +=minutes*60*1000; | |||||
| Date expiredate=new Date(currentTime); | |||||
| wxMsgValidationcode.setExpiretime(expiredate); | |||||
| wxMsgValidationcode.setCreatetime(createtime); | |||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| } | |||||
| return new ResultData(500,"发送失败"); | |||||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||||
| wxMsgRecord.setModelType(wxMsgValidationcode.getType()); | |||||
| wxMsgRecord.setReceiver(wxMsgValidationcode.getPhone()); | |||||
| wxMsgRecord.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| Map<String,String> map = new HashedMap(); | |||||
| map.put("s6",String.valueOf(code)); | |||||
| wxMsgRecord.setDynamicContentMap(map); | |||||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| } | } | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.mapper.*; | |||||
| import com.iformall.service.WxMsgRecordService; | |||||
| import com.iformall.utils.JsonUtil; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.UUID; | |||||
| /** | |||||
| * @author luozukai | |||||
| * 业务短信发送实现 | |||||
| */ | |||||
| @Service | |||||
| public class WxMsgRecordServiceImpl implements WxMsgRecordService { | |||||
| @Autowired | |||||
| private WxMsgRecordMapper wxMsgRecordMapper; | |||||
| @Override | |||||
| public void save(BaseMsg data) { | |||||
| if(data instanceof WxMsgRecord){ | |||||
| WxMsgRecord msgRecord = (WxMsgRecord)data; | |||||
| msgRecord.setUuid(UUID.randomUUID().toString()); | |||||
| if(msgRecord.getDynamicContentMap() != null && msgRecord.getDynamicContentMap().size() > 0) { | |||||
| msgRecord.setDynamicContent(JsonUtil.obj2Json(msgRecord.getDynamicContentMap())); | |||||
| } | |||||
| wxMsgRecordMapper.insertSelective(msgRecord); | |||||
| }else if(data instanceof WxMsg || data instanceof MailMsg){ | |||||
| WxMsgRecord msgRecord = new WxMsgRecord(); | |||||
| msgRecord.setUuid(UUID.randomUUID().toString()); | |||||
| msgRecord.setMsgJson(JsonUtil.obj2Json(data)); | |||||
| wxMsgRecordMapper.insertSelective(msgRecord); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -8,11 +8,9 @@ import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.EnumMsgSend; | |||||
| import com.iformall.enums.EnumMsgSendStatus; | |||||
| import com.iformall.enums.EnumMsgStatus; | |||||
| import com.iformall.enums.EnumVerifyCode; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import com.iformall.service.WxCUserTagsService; | import com.iformall.service.WxCUserTagsService; | ||||
| import com.iformall.service.WxMsgService; | import com.iformall.service.WxMsgService; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| @@ -52,6 +50,9 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| @Autowired | @Autowired | ||||
| WxMsgModelMapper wxMsgModelMapper; | WxMsgModelMapper wxMsgModelMapper; | ||||
| @Autowired | |||||
| MqBaseProducer mqBaseProducer; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsg> listAsPage(WxMsg record, Integer pageIndex, Integer pageSize) { | ||||
| PageHelper.startPage(pageIndex, pageSize); | PageHelper.startPage(pageIndex, pageSize); | ||||
| @@ -110,7 +111,10 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| if (wxMsg.getExpectSendNumber().intValue() > 1000) { | if (wxMsg.getExpectSendNumber().intValue() > 1000) { | ||||
| batchSendMsg(wxMsg, wxMsgConfig, null); | batchSendMsg(wxMsg, wxMsgConfig, null); | ||||
| } else { | } else { | ||||
| sendmsg(wxMsg, wxMsgConfig, null); | |||||
| //sendmsg(wxMsg, wxMsgConfig, null); | |||||
| wxMsg.setWxMsgConfig(wxMsgConfig); | |||||
| wxMsg.setCouponInject(null); | |||||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),null); | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "短信已发送"); | return new ResultData(Result.SUCCESS, "短信已发送"); | ||||
| } else { | } else { | ||||
| @@ -136,7 +140,9 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| if (wxMsg.getExpectSendNumber().intValue() > 1000) { | if (wxMsg.getExpectSendNumber().intValue() > 1000) { | ||||
| batchSendMsg(wxMsg, wxMsgConfig, null); | batchSendMsg(wxMsg, wxMsgConfig, null); | ||||
| } else { | } else { | ||||
| sendmsg(wxMsg, wxMsgConfig, null); | |||||
| //sendmsg(wxMsg, wxMsgConfig, null); | |||||
| wxMsg.setWxMsgConfig(wxMsgConfig); | |||||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "短信已发送"); | return new ResultData(Result.SUCCESS, "短信已发送"); | ||||
| } else { | } else { | ||||
| @@ -175,83 +181,93 @@ public class WxMsgServiceImpl implements WxMsgService { | |||||
| String phones = StringUtils.join(phoneList, ","); | String phones = StringUtils.join(phoneList, ","); | ||||
| wxMsg.setPhones(phones); | wxMsg.setPhones(phones); | ||||
| wxMsg.setExpectSendNumber(extra); | wxMsg.setExpectSendNumber(extra); | ||||
| sendmsg(wxMsg, wxMsgConfig, couponInject); | |||||
| //sendmsg(wxMsg, wxMsgConfig, couponInject); | |||||
| wxMsg.setWxMsgConfig(wxMsgConfig); | |||||
| wxMsg.setCouponInject(couponInject); | |||||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } else { | } else { | ||||
| List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i + 1) * 1000); | List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i + 1) * 1000); | ||||
| String phones = StringUtils.join(phoneList, ","); | String phones = StringUtils.join(phoneList, ","); | ||||
| wxMsg.setExpectSendNumber(1000); | wxMsg.setExpectSendNumber(1000); | ||||
| wxMsg.setPhones(phones); | wxMsg.setPhones(phones); | ||||
| sendmsg(wxMsg, wxMsgConfig, couponInject); | |||||
| //sendmsg(wxMsg, wxMsgConfig, couponInject); | |||||
| wxMsg.setWxMsgConfig(wxMsgConfig); | |||||
| wxMsg.setCouponInject(couponInject); | |||||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public ResultData sendmsg(WxMsg record, WxMsgConfig wxMsgConfig, WxCouponInject couponInject) { | |||||
| logger.info("发送短信开始..."); | |||||
| logger.info("couponInject:" + couponInject); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| String phone = record.getPhones(); | |||||
| String signature = record.getSignature(); | |||||
| String msg = record.getMsg(); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| WxMsgModel wxMsgModel = wxMsgModelMapper.selectByPrimaryKey(record.getModelId()); | |||||
| Integer modelId = null; | |||||
| if (wxMsgModel != null) { | |||||
| modelId = wxMsgModel.getModelId(); | |||||
| } | |||||
| logger.info("=============迈外迪API开始调用"); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.NO.getCode().toString(), modelId); | |||||
| logger.info("=============迈外迪API返回结果:" + result); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| String batchNo = jsonObjectResult.get("data").toString(); | |||||
| String resultMsg = jsonObjectResult.get("msg").toString(); | |||||
| record.setReturnResult(jsonObjectResult.toJSONString()); | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| record.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode()); | |||||
| } else { | |||||
| record.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| long id = idWorker.nextId(); | |||||
| WxMsg wxMsg = new WxMsg(); | |||||
| wxMsg.setTenantId(record.getTenantId()); | |||||
| wxMsg.setModelId(record.getModelId()); | |||||
| wxMsg.setMsg(record.getMsg()); | |||||
| wxMsg.setExpectSendNumber(record.getExpectSendNumber()); | |||||
| wxMsg.setPhones(record.getPhones()); | |||||
| wxMsg.setSignature(record.getSignature()); | |||||
| wxMsg.setIsright(record.getIsright()); | |||||
| wxMsg.setName(record.getName()); | |||||
| wxMsg.setSendstatus(record.getSendstatus()); | |||||
| wxMsg.setLabel(record.getLabel()); | |||||
| wxMsg.setStatus(record.getStatus()); | |||||
| wxMsg.setWay(record.getWay()); | |||||
| wxMsg.setId(id); | |||||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); | |||||
| wxMsg.setSendtime(systemTime); | |||||
| wxMsg.setCreatetime(DateUtils.stringToDate(systemTime, "yyyy-MM-dd HH:mm:ss")); | |||||
| //精准投放 | |||||
| if (couponInject != null) { | |||||
| wxMsg.setCouponInjectId(couponInject.getId()); | |||||
| } | |||||
| wxMsgMapper.insertSelective(wxMsg); | |||||
| logger.info("发送短信结束..."); | |||||
| if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| addMsgCallback(wxMsg, batchNo); | |||||
| return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态", id); | |||||
| } else { | |||||
| return new ResultData(ErrorCode.MSG_SEND_INTERFACE_ERROR.getCode(), | |||||
| ErrorCode.MSG_SEND_INTERFACE_ERROR.getMessage() + ":" + resultMsg); | |||||
| } | |||||
| } | |||||
| // @Deprecated | |||||
| // public ResultData sendmsg(WxMsg record, WxMsgConfig wxMsgConfig, WxCouponInject couponInject) { | |||||
| // logger.info("发送短信开始..."); | |||||
| // logger.info("couponInject:" + couponInject); | |||||
| // String secret = wxMsgConfig.getSecret(); | |||||
| // String bid = wxMsgConfig.getBid(); | |||||
| // String publickey = wxMsgConfig.getPublickey(); | |||||
| // | |||||
| // String phone = record.getPhones(); | |||||
| // String signature = record.getSignature(); | |||||
| // String msg = record.getMsg(); | |||||
| // String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| // WxMsgModel wxMsgModel = wxMsgModelMapper.selectByPrimaryKey(record.getModelId()); | |||||
| // Integer modelId = null; | |||||
| // if (wxMsgModel != null) { | |||||
| // modelId = wxMsgModel.getModelId(); | |||||
| // } | |||||
| // logger.info("=============迈外迪API开始调用"); | |||||
| // String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.NO.getCode().toString(), modelId); | |||||
| // logger.info("=============迈外迪API返回结果:" + result); | |||||
| // JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| // String ret = jsonObjectResult.get("ret").toString(); | |||||
| // String batchNo = jsonObjectResult.get("data").toString(); | |||||
| // String resultMsg = jsonObjectResult.get("msg").toString(); | |||||
| // record.setReturnResult(jsonObjectResult.toJSONString()); | |||||
| // | |||||
| // | |||||
| // if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| // record.setSendstatus(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode()); | |||||
| // } else { | |||||
| // record.setSendstatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode()); | |||||
| // } | |||||
| // | |||||
| // final IdWorker idWorker = IdWorker.get(); | |||||
| // long id = idWorker.nextId(); | |||||
| // WxMsg wxMsg = new WxMsg(); | |||||
| // wxMsg.setTenantId(record.getTenantId()); | |||||
| // wxMsg.setModelId(record.getModelId()); | |||||
| // wxMsg.setMsg(record.getMsg()); | |||||
| // wxMsg.setExpectSendNumber(record.getExpectSendNumber()); | |||||
| // wxMsg.setPhones(record.getPhones()); | |||||
| // wxMsg.setSignature(record.getSignature()); | |||||
| // wxMsg.setIsright(record.getIsright()); | |||||
| // wxMsg.setName(record.getName()); | |||||
| // wxMsg.setSendstatus(record.getSendstatus()); | |||||
| // wxMsg.setLabel(record.getLabel()); | |||||
| // wxMsg.setStatus(record.getStatus()); | |||||
| // wxMsg.setWay(record.getWay()); | |||||
| // wxMsg.setId(id); | |||||
| // String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); | |||||
| // wxMsg.setSendtime(systemTime); | |||||
| // wxMsg.setCreatetime(DateUtils.stringToDate(systemTime, "yyyy-MM-dd HH:mm:ss")); | |||||
| // //精准投放 | |||||
| // if (couponInject != null) { | |||||
| // wxMsg.setCouponInjectId(couponInject.getId()); | |||||
| // } | |||||
| // wxMsgMapper.insertSelective(wxMsg); | |||||
| // | |||||
| // logger.info("发送短信结束..."); | |||||
| // if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { | |||||
| // addMsgCallback(wxMsg, batchNo); | |||||
| // return new ResultData(Result.SUCCESS, "短信发送中,您可在短信明细中查看发送状态", id); | |||||
| // } else { | |||||
| // return new ResultData(ErrorCode.MSG_SEND_INTERFACE_ERROR.getCode(), | |||||
| // ErrorCode.MSG_SEND_INTERFACE_ERROR.getMessage() + ":" + resultMsg); | |||||
| // } | |||||
| // | |||||
| // } | |||||
| @Override | |||||
| public void addMsgCallback(WxMsg wxmsg, String batchNo) { | public void addMsgCallback(WxMsg wxmsg, String batchNo) { | ||||
| logger.info("营销短信发送时主动添加回调记录开始..."); | logger.info("营销短信发送时主动添加回调记录开始..."); | ||||
| String phones = wxmsg.getPhones(); | String phones = wxmsg.getPhones(); | ||||
| @@ -42,68 +42,12 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| @Autowired | @Autowired | ||||
| WxMerchantBUserMapper wxMerchantBUserMapper; | WxMerchantBUserMapper wxMerchantBUserMapper; | ||||
| @Autowired | @Autowired | ||||
| WxMerchantMapper wxMerchantMapper; | WxMerchantMapper wxMerchantMapper; | ||||
| @Autowired | @Autowired | ||||
| WxMsgCallbackMapper wxMsgCallbackMapper; | WxMsgCallbackMapper wxMsgCallbackMapper; | ||||
| @Override | |||||
| public ResultData sendWorkFlowNodify(WxMsgValidationcode wxMsgValidationcode,Map<String,String> dynamicContentMap) { | |||||
| //3、从短信配置中查询密钥 bid 等信息 | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.setTenantId(wxMsgValidationcode.getTenantId()); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| WxMsgValidationcodeModel wxMsgValidationcodeModel = new WxMsgValidationcodeModel(); | |||||
| wxMsgValidationcodeModel.setTenantId(wxMsgConfig.getTenantId()); | |||||
| wxMsgValidationcodeModel.setType(wxMsgValidationcode.getType()); | |||||
| wxMsgValidationcodeModel = wxMsgValidationcodeModelMapper.findList(wxMsgValidationcodeModel).get(0); | |||||
| wxMsgValidationcode.setSignature(wxMsgValidationcodeModel.getSignature()); | |||||
| String secret = wxMsgConfig.getSecret(); | |||||
| String bid = wxMsgConfig.getBid(); | |||||
| String publickey = wxMsgConfig.getPublickey(); | |||||
| // 验证码 | |||||
| String phone = wxMsgValidationcode.getPhone(); | |||||
| String signature = wxMsgValidationcode.getSignature(); | |||||
| //替换内容 | |||||
| String msg = wxMsgValidationcodeModel.getContent(); | |||||
| for (Map.Entry<String, String> entry : dynamicContentMap.entrySet()) { | |||||
| msg = msg.replace("{"+entry.getKey()+"}", entry.getValue()); | |||||
| } | |||||
| // wxMsgValidationcode.setCode(String.valueOf(code)); | |||||
| wxMsgValidationcode.setMsg(msg); | |||||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||||
| Integer modelId = wxMsgValidationcodeModel.getModelId(); | |||||
| String result = WiwideUtil.sendMsg(secret, bid, publickey, phone, signature, msg, notifyUrl, EnumVerifyCode.YES.getCode().toString(), modelId); | |||||
| JSONObject jsonObjectResult = JSONObject.parseObject(result); | |||||
| String ret = jsonObjectResult.get("ret").toString(); | |||||
| String batchNo = jsonObjectResult.get("data").toString(); | |||||
| if (ret.equals("1")) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxMsgValidationcode.setId(idWorker.nextId()); | |||||
| long currentTime = System.currentTimeMillis() ; | |||||
| Date createtime=new Date(currentTime); | |||||
| // Integer minutes = wxMsgValidationcodeModel.getMinutes(); | |||||
| // currentTime +=minutes*60*1000; | |||||
| // Date expiredate=new Date(currentTime); | |||||
| // wxMsgValidationcode.setExpiretime(expiredate); | |||||
| wxMsgValidationcode.setCreatetime(createtime); | |||||
| wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode); | |||||
| addMsgCallback(wxMsgValidationcode,batchNo); | |||||
| return new ResultData(Result.SUCCESS,"发送成功"); | |||||
| }else{ | |||||
| logger.error("短信运营商返回失败,手机号:{},返回信息:{}",phone,result); | |||||
| } | |||||
| return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(),"发送失败"); | |||||
| } | |||||
| @Override | @Override | ||||
| public PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMsgValidationcode> listAsPage(WxMsgValidationcode record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgValidationcodeMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgValidationcodeMapper.findList(record)); | ||||
| @@ -199,6 +143,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic | |||||
| } | } | ||||
| @Override | |||||
| public void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo){ | public void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo){ | ||||
| logger.info("验证码发送时主动添加回调记录开始..."); | logger.info("验证码发送时主动添加回调记录开始..."); | ||||
| String phone = wxmsg.getPhone(); | String phone = wxmsg.getPhone(); | ||||
| @@ -0,0 +1,128 @@ | |||||
| package com.iformall.utils; | |||||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||||
| import com.fasterxml.jackson.core.JsonGenerator; | |||||
| import com.fasterxml.jackson.core.JsonParser; | |||||
| import com.fasterxml.jackson.core.JsonProcessingException; | |||||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||||
| import com.fasterxml.jackson.databind.JsonSerializer; | |||||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||||
| import com.fasterxml.jackson.databind.SerializerProvider; | |||||
| import com.fasterxml.jackson.databind.module.SimpleModule; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import java.io.IOException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.HashMap; | |||||
| import java.util.Iterator; | |||||
| import java.util.Map; | |||||
| public final class JsonUtil { | |||||
| private static Logger log = LoggerFactory.getLogger(JsonUtil.class); | |||||
| public static final ObjectMapper mapper = new ObjectMapper(); | |||||
| private JsonUtil() { | |||||
| } | |||||
| public static String obj2Json(Object obj) { | |||||
| if(obj != null) { | |||||
| try { | |||||
| return mapper.writeValueAsString(obj); | |||||
| } catch (JsonProcessingException var2) { | |||||
| throw new RuntimeException(var2); | |||||
| } | |||||
| } else { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| public static byte[] obj2Byte(Object obj) { | |||||
| if(obj != null) { | |||||
| try { | |||||
| return mapper.writeValueAsBytes(obj); | |||||
| } catch (JsonProcessingException var2) { | |||||
| var2.printStackTrace(); | |||||
| } | |||||
| } | |||||
| return new byte[0]; | |||||
| } | |||||
| public static Object readValue(String json, Class<?> clazz) { | |||||
| Object t = null; | |||||
| try { | |||||
| return mapper.readValue(json, clazz); | |||||
| } catch (Exception var4) { | |||||
| log.info("解析对象:{}", json); | |||||
| log.error("json解析错误:{}", var4.getMessage(), var4); | |||||
| return t; | |||||
| } | |||||
| } | |||||
| // public static <T> T readValue(String json, TypeReference type) { | |||||
| // Object object = null; | |||||
| // | |||||
| // try { | |||||
| // object = mapper.readValue(json, type); | |||||
| // } catch (Exception var4) { | |||||
| // log.info("解析对象:{}", json); | |||||
| // log.error("json解析错误:{}", var4.getMessage(), var4); | |||||
| // } | |||||
| // | |||||
| // return object; | |||||
| // } | |||||
| // | |||||
| // public static <T> T readValue(byte[] json, TypeReference type) { | |||||
| // Object object = null; | |||||
| // | |||||
| // try { | |||||
| // object = mapper.readValue(json, type); | |||||
| // } catch (Exception var4) { | |||||
| // log.info("解析对象:{}", json); | |||||
| // log.error("json解析错误:{}", var4.getMessage(), var4); | |||||
| // } | |||||
| // | |||||
| // return object; | |||||
| // } | |||||
| // | |||||
| // public static Map<String, Object> readValueAsMap(String json) { | |||||
| // return (Map)readValue(json, new TypeReference<HashMap<String, Object>>() { | |||||
| // }); | |||||
| // } | |||||
| static { | |||||
| mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||||
| mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); | |||||
| mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true); | |||||
| mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||||
| mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); | |||||
| SimpleModule module = new SimpleModule(); | |||||
| module.addSerializer(HashMap.class, new JsonUtil.HashMapSerializer()); | |||||
| mapper.registerModule(module); | |||||
| } | |||||
| public static class HashMapSerializer extends JsonSerializer<HashMap> { | |||||
| public HashMapSerializer() { | |||||
| } | |||||
| public void serialize(HashMap value, JsonGenerator jgen, SerializerProvider provider) throws IOException { | |||||
| jgen.writeStartObject(); | |||||
| Iterator var4 = value.entrySet().iterator(); | |||||
| while(var4.hasNext()) { | |||||
| Object entry = var4.next(); | |||||
| if(entry instanceof Map.Entry) { | |||||
| Map.Entry en = (Map.Entry)entry; | |||||
| if(en.getValue() != null && en.getKey() != null) { | |||||
| jgen.writeObjectField(en.getKey().toString(), en.getValue()); | |||||
| } | |||||
| } | |||||
| } | |||||
| jgen.writeEndObject(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -4,18 +4,18 @@ | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMsgRecord"> | <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMsgRecord"> | ||||
| <id column="id" property="id" /> | <id column="id" property="id" /> | ||||
| <result column="tenant_id" property="tenantId" /> | <result column="tenant_id" property="tenantId" /> | ||||
| <result column="group" property="group" /> | |||||
| <result column="type" property="type" /> | |||||
| <result column="domain" property="domain" /> | |||||
| <result column="msg_type" property="msgType" /> | |||||
| <result column="msg" property="msg" /> | <result column="msg" property="msg" /> | ||||
| <result column="send_time" property="sendTime" /> | <result column="send_time" property="sendTime" /> | ||||
| <result column="model_id" property="modelId" /> | <result column="model_id" property="modelId" /> | ||||
| <result column="from" property="from" /> | |||||
| <result column="from_user_id" property="fromUserId" /> | |||||
| <result column="from_user_name" property="fromUserName" /> | |||||
| <result column="to" property="to" /> | |||||
| <result column="to_user_id" property="toUserId" /> | |||||
| <result column="to_user_name" property="toUserName" /> | |||||
| <result column="status" property="status" /> | |||||
| <result column="sender" property="from" /> | |||||
| <result column="sender_user_id" property="fromUserId" /> | |||||
| <result column="sender_user_name" property="fromUserName" /> | |||||
| <result column="receiver" property="to" /> | |||||
| <result column="receiver_user_id" property="toUserId" /> | |||||
| <result column="receiver_user_name" property="toUserName" /> | |||||
| <result column="msg_status" property="msgStatus" /> | |||||
| <result column="status_message" property="statusMessage" /> | <result column="status_message" property="statusMessage" /> | ||||
| <result column="createtime" property="createtime" /> | <result column="createtime" property="createtime" /> | ||||
| <result column="updatetime" property="updatetime" /> | <result column="updatetime" property="updatetime" /> | ||||
| @@ -23,14 +23,10 @@ | |||||
| <result column="signature" property="signature" /> | <result column="signature" property="signature" /> | ||||
| <result column="model_type" property="modelType" /> | <result column="model_type" property="modelType" /> | ||||
| <result column="dynamic_content" property="dynamicContent" /> | <result column="dynamic_content" property="dynamicContent" /> | ||||
| <result column="msg_json" property="msgJson" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`group`,`type`,`msg` ,send_time,model_id,from,from_user_id,from_user_name,to,to_user_id,to_user_name | |||||
| ,status,status_message,createtime,updatetime,uuid,signature,model_type,dynamic_content | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where 1 = 1 | where 1 = 1 | ||||
| @@ -53,10 +49,10 @@ | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </sql> | </sql> | ||||
| <update id="update" parameterType="com.iformall.domain.po.WxMsgRecord"> | |||||
| <update id="update" parameterType="com.iformall.domain.po.BaseMsg"> | |||||
| update wx_msg_record set updatetime = now() | update wx_msg_record set updatetime = now() | ||||
| <if test=" null != status ">,status = #{status}</if> | |||||
| <if test=" null != message ">,message = #{message}</if> | |||||
| <if test=" null != msgStatus ">,msg_status = #{msgStatus}</if> | |||||
| <if test=" null != statusMessage ">,status_message = #{statusMessage}</if> | |||||
| where uuid = #{uuid} | where uuid = #{uuid} | ||||
| </update> | </update> | ||||
| @@ -18,6 +18,7 @@ | |||||
| <module>mallinkBApi</module> | <module>mallinkBApi</module> | ||||
| <module>mallinkSchedule</module> | <module>mallinkSchedule</module> | ||||
| <module>mallinkWechatOpen</module> | <module>mallinkWechatOpen</module> | ||||
| <module>mallinkMQConsumer</module> | |||||
| </modules> | </modules> | ||||
| <parent> | <parent> | ||||