From a6658460351e347ba1f770d9756b299d09f54d95 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Fri, 21 Oct 2022 16:15:13 +0800 Subject: [PATCH] 1 --- v1/src/main/java/com/V1Application.java | 7 +- .../com/v1/controller/WxMsgController.java | 38 ++++++++--- v1/src/main/resources/dev/application.yml | 66 ++++++++++--------- v1/src/main/resources/prod/config.properties | 3 + 4 files changed, 73 insertions(+), 41 deletions(-) diff --git a/v1/src/main/java/com/V1Application.java b/v1/src/main/java/com/V1Application.java index d9e44505..7ea41025 100644 --- a/v1/src/main/java/com/V1Application.java +++ b/v1/src/main/java/com/V1Application.java @@ -1,5 +1,7 @@ package com; +import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation; +import com.alicp.jetcache.anno.config.EnableMethodCache; import com.hai.common.utils.SpringContextUtil; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; @@ -11,11 +13,12 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.transaction.annotation.EnableTransactionManagement; @SpringBootApplication -// @ComponentScan +//@ComponentScan @EnableTransactionManagement @EnableScheduling +@EnableMethodCache(basePackages = "com.hai") +@EnableCreateCacheAnnotation @ServletComponentScan -@EnableAspectJAutoProxy(proxyTargetClass = true) @MapperScan("com.hai.dao") public class V1Application { diff --git a/v1/src/main/java/com/v1/controller/WxMsgController.java b/v1/src/main/java/com/v1/controller/WxMsgController.java index 58051ed5..c59cac35 100644 --- a/v1/src/main/java/com/v1/controller/WxMsgController.java +++ b/v1/src/main/java/com/v1/controller/WxMsgController.java @@ -11,9 +11,11 @@ import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.CommonSysConst; +import com.hai.entity.HighUser; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.service.HighMerchantStoreService; +import com.hai.service.HighUserService; import com.v1.config.SysConst; import com.v1.config.WeChatQrcodeUtils; import io.swagger.annotations.Api; @@ -53,6 +55,9 @@ public class WxMsgController { @Resource private HighMerchantStoreService merchantStoreService; + @Resource + private HighUserService highUserService; + @Resource private RedisUtil redisUtil; @@ -108,22 +113,42 @@ public class WxMsgController { String msgType = map.get("MsgType"); // 二维码参数 String eventKey = map.get("EventKey"); - String linkContent; + + // 判断用户是否是新用户 + HighUser user = highUserService.findByOpenIdH5(userOpenId); + + + String linkContent = null; + String newUserContent = null; String content = null; if (eventKey != null && eventKey.length() != 0) { JSONObject object = weChatQrcodeUtils.paramPars(eventKey); - // type = 1 推广扫码 type = 2 + // type = 1 推广扫码 type = 2 商户门店 3:查看视频教程 if (Objects.equals(object.getString("qrscene_type"), "1") || Objects.equals(object.getString("type"), "1")) { linkContent = "点击查看更多优惠\n\n"; - } else { + } else if (Objects.equals(object.getString("qrscene_type"), "2") || Objects.equals(object.getString("type"), "2")){ // 商户门店 HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(object.getString("code")); linkContent = "欢迎来到" + store.getStoreName()+"" + "[哇][哇][哇]\n\n点击这里一键加油\n\n"; + } else if (Objects.equals(object.getString("qrscene_type"), "3") || Objects.equals(object.getString("type"), "3")){ + // 商户门店 + linkContent = "点击查看重庆中石油视频教程" + + "[哇][哇][哇]\n\n点击查看贵州中石化视频教程\n\n"; } } else { linkContent = "点击查看更多优惠\n\n"; } + // 判断是否是新用户 + if (user == null) { + newUserContent = "特意为您奉上" + + "5张优惠券" + + ",放在您的"+ + "优惠券"+ + "里面,记得及时使用哦[爱心][爱心][爱心]\n\n"; + } + + log.info("二维码参数:" + eventKey); // 普通消息 if ("text".equals(msgType)) { @@ -145,12 +170,7 @@ public class WxMsgController { "终于等到你,还好我没放弃[玫瑰][玫瑰][玫瑰]\n\n" + "您好,感谢关注嗨森逛商城!\n\n" + linkContent + - "在线等你来撩~[哇][哇][哇]\n\n" + - "特意为您奉上" + - "5张优惠券" + - ",放在您的"+ - "优惠券"+ - "里面,记得及时使用哦[爱心][爱心][爱心]\n\n" + + "在线等你来撩~[哇][哇][哇]\n\n" + newUserContent + "【如遇任何问题请致电客服:400-678-0738】" ; // todo 业务处理 diff --git a/v1/src/main/resources/dev/application.yml b/v1/src/main/resources/dev/application.yml index 748fc6d8..6d26a97d 100644 --- a/v1/src/main/resources/dev/application.yml +++ b/v1/src/main/resources/dev/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.159.177.244:3306/hsg_order?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource @@ -32,7 +32,7 @@ spring: host: 139.159.177.244 port: 36379 password: HF123456.Redis - timeout: 36000000 + timeout: 1000 jedis: pool: max-active: 20 @@ -50,14 +50,15 @@ spring: #客户端id(不能重复) # client: # id: provider-id - #MQTT默认的消息推送主题,实际可在调用接口是指定 - # default: + #MQTT默认的消息推送主题,实际可在调用接口是指定 + # default: # topic: topic - rocketmq: - name-server: 139.159.177.244:9876 - producer: - #必须指定group - group: default-group +rocketmq: + name-server: 139.159.177.244:9876 + producer: + #必须指定group + group: default-group + #配置日期返回至前台为时间戳 jackson: serialization: @@ -67,27 +68,32 @@ mybatis: - classpath*:sqlmap*/*.xml type-aliases-package: org.springboot.sample.entity - jetcache: - statIntervalMinutes: 15 - areaInCacheName: false - local: - default: - type: linkedhashmap - keyConvertor: fastjson - remote: - default: - type: redis - host: 139.159.177.244 - port: 36379 - password: HF123456.Redis - keyConvertor: fastjson - broadcastChannel: projectA - valueEncoder: java - valueDecoder: java - poolConfig: - minIdle: 5 - maxIdle: 20 - maxTotal: 50 + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + #开启MyBatis的二级缓存 + cache-enabled: true + +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.159.177.244 + port: 36379 + password: HF123456.Redis + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 pagehelper: helperDialect: mysql diff --git a/v1/src/main/resources/prod/config.properties b/v1/src/main/resources/prod/config.properties index b7bbc8e8..39cffecb 100644 --- a/v1/src/main/resources/prod/config.properties +++ b/v1/src/main/resources/prod/config.properties @@ -1,2 +1,5 @@ wxH5AppId=wxa075e8509802f826 wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5 + +wxAppId=wx8d49e2f83025229d +wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df