| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -156,6 +158,24 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -9,6 +9,7 @@ import com.iformall.controller.app.WxAppinfoController; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.dto.WxCouponChannelDto; | import com.iformall.domain.dto.WxCouponChannelDto; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -119,6 +121,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -137,6 +139,24 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -156,6 +158,24 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -141,6 +143,24 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -119,6 +121,24 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -141,6 +143,24 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -0,0 +1,49 @@ | |||||
| package com.iformall.enums; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCacheKey { | |||||
| C_INDEX_PAGE_LIST(0, "couponChannelList_"), | |||||
| ; | |||||
| private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | |||||
| static { | |||||
| for (EnumCacheKey value : values()) { | |||||
| map.put(value.code, value); | |||||
| } | |||||
| } | |||||
| public static EnumCacheKey getEnum(Integer code) { | |||||
| if (code == null) return null; | |||||
| return map.get(code); | |||||
| } | |||||
| public static String getEnumMessage(Integer code) { | |||||
| if (code == null) return null; | |||||
| if (map.get(code) == null) | |||||
| return null; | |||||
| return map.get(code).getMessage(); | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCacheKey(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,34 @@ | |||||
| package com.iformall.enums; | |||||
| public enum EnumTargetAd { | |||||
| LIST(1, "列表"), | |||||
| BUG(2, "显示抢购"), | |||||
| ; | |||||
| public static EnumTargetAd getEnum(Integer code) { | |||||
| for (EnumTargetAd value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumTargetAd(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -15,12 +15,18 @@ import com.iformall.domain.vo.WxMerchantVo; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.JsonUtil; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| 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.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.data.redis.core.ValueOperations; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.concurrent.TimeUnit; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @Service | @Service | ||||
| @@ -46,6 +52,10 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| @Autowired | @Autowired | ||||
| WxFloatingLayerMapper wxFloatingLayerMapper; | WxFloatingLayerMapper wxFloatingLayerMapper; | ||||
| @Autowired | |||||
| @Qualifier("couponChannelRedisTemplate") | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> cdRedisTemplate; | |||||
| /** | /** | ||||
| * B端业务端 | * B端业务端 | ||||
| * @param record | * @param record | ||||
| @@ -111,9 +121,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| wxCouponChannelMapper.updateById(record); | wxCouponChannelMapper.updateById(record); | ||||
| } | } | ||||
| //清除缓存 | |||||
| clearCache(record.getTenantId()); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| /** | |||||
| * 清除c端首页卷列表缓存 | |||||
| * @param tenantId | |||||
| */ | |||||
| public void clearCache(String tenantId){ | |||||
| for (int i = 1; i <=5 ; i++) { | |||||
| String key = EnumCacheKey.C_INDEX_PAGE_LIST.getMessage()+tenantId+"_" + i + ":"; | |||||
| cdRedisTemplate.delete(key); | |||||
| } | |||||
| } | |||||
| @Override | @Override | ||||
| public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { | public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { | ||||
| List<WxCouponChannelAddVo> errorList = new ArrayList<>(); | List<WxCouponChannelAddVo> errorList = new ArrayList<>(); | ||||
| @@ -284,6 +308,28 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | ||||
| PageInfo<WxCouponChannelVo> pageInfo; | |||||
| //仅c端首页走缓存 | |||||
| if(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode().equals(record.getTargetAd()) | |||||
| && new Integer(6).equals(pageSize) | |||||
| && pageIndex.intValue() <=5 | |||||
| && record.getBusiness() == null) { | |||||
| logger.info("listPageCVo.chache"); | |||||
| String key = EnumCacheKey.C_INDEX_PAGE_LIST.getMessage() +record.getTenantId()+"_" + pageIndex + ":"; | |||||
| ValueOperations<String, PageInfo<WxCouponChannelVo>> operations = cdRedisTemplate.opsForValue(); | |||||
| boolean hasKey = cdRedisTemplate.hasKey(key); | |||||
| if (hasKey) { | |||||
| pageInfo = operations.get(key); | |||||
| logger.info("listPageCVo.chache.get:{}", pageInfo.getList()==null?0:pageInfo.getList().size()); | |||||
| }else{ | |||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | |||||
| } | |||||
| //插入缓存 | |||||
| operations.set(key, pageInfo, 60, TimeUnit.SECONDS); | |||||
| return pageInfo; | |||||
| } | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | ||||
| } | } | ||||
| @@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | |||||
| @Service | @Service | ||||
| public class WxCouponInjectServiceImpl implements WxCouponInjectService { | public class WxCouponInjectServiceImpl implements WxCouponInjectService { | ||||
| @@ -11,7 +11,6 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCouponPasswordMapper; | import com.iformall.mapper.WxCouponPasswordMapper; | ||||
| import com.iformall.service.ExcelService; | import com.iformall.service.ExcelService; | ||||
| import com.iformall.service.WxCouponPasswordService; | import com.iformall.service.WxCouponPasswordService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| 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; | ||||
| @@ -13,6 +13,7 @@ import com.iformall.domain.dto.WxCouponMerchantDto; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import com.iformall.domain.vo.WxCouponStatisVo; | import com.iformall.domain.vo.WxCouponStatisVo; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -24,6 +25,8 @@ import org.apache.commons.lang3.StringUtils; | |||||
| 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.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Isolation; | import org.springframework.transaction.annotation.Isolation; | ||||
| import org.springframework.transaction.annotation.Propagation; | import org.springframework.transaction.annotation.Propagation; | ||||
| @@ -71,6 +74,10 @@ import java.util.stream.Collectors; | |||||
| @Autowired | @Autowired | ||||
| WxCouponPasswordService couponPasswordService; | WxCouponPasswordService couponPasswordService; | ||||
| @Autowired | |||||
| @Qualifier("couponChannelRedisTemplate") | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> cdRedisTemplate; | |||||
| @Override | @Override | ||||
| public ResultData list(WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | public ResultData list(WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | ||||
| if (null == wxCoupon) wxCoupon = new WxCoupon(); | if (null == wxCoupon) wxCoupon = new WxCoupon(); | ||||
| @@ -429,9 +436,24 @@ import java.util.stream.Collectors; | |||||
| wxCouponMapper.updateById(record); | wxCouponMapper.updateById(record); | ||||
| } | } | ||||
| //清空缓存 | |||||
| clearCache(record.getTenantId()); | |||||
| return new ResultData(record.getId()); | return new ResultData(record.getId()); | ||||
| } | } | ||||
| /** | |||||
| * 清除c端首页卷列表缓存 | |||||
| * @param tenantId | |||||
| */ | |||||
| public void clearCache(String tenantId){ | |||||
| for (int i = 1; i <=5 ; i++) { | |||||
| String key = EnumCacheKey.C_INDEX_PAGE_LIST.getMessage() +tenantId+"_" + i + ":"; | |||||
| cdRedisTemplate.delete(key); | |||||
| } | |||||
| } | |||||
| @Override | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxCouponMapper.deleteById(id); | wxCouponMapper.deleteById(id); | ||||
| @@ -590,12 +612,14 @@ import java.util.stream.Collectors; | |||||
| // 库存 是否改变 | // 库存 是否改变 | ||||
| bChanged = true; | bChanged = true; | ||||
| } | } | ||||
| if(wxCoupon.getInventory()-wxCoupon.getRemainInventory() != oldCoupon.getInventory() - oldCoupon.getRemainInventory()) { | |||||
| Integer newSale = wxCoupon.getInventory()-wxCoupon.getRemainInventory(); | |||||
| Integer oldSale = oldCoupon.getInventory() - oldCoupon.getRemainInventory(); | |||||
| if (!newSale.equals(oldSale)) { | |||||
| // 已售卖数不变 | // 已售卖数不变 | ||||
| logger.error("已售卖数不变"); | |||||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR.getCode(), "已售卖数不变"); | |||||
| logger.error("券库存要保证同增同减"); | |||||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR.getCode(), "券库存要保证同增同减"); | |||||
| } | } | ||||
| if(wxCoupon.getValidType() != oldCoupon.getValidType()) { | |||||
| if (!wxCoupon.getValidType().equals(oldCoupon.getValidType())) { | |||||
| // 券有效期类型不能改变 | // 券有效期类型不能改变 | ||||
| logger.error("券有效期类型不能改变"); | logger.error("券有效期类型不能改变"); | ||||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期类型不能改变"); | return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期类型不能改变"); | ||||
| @@ -627,8 +651,10 @@ import java.util.stream.Collectors; | |||||
| wxCoupon.setOrgInventory(oldCoupon.getInventory()); | wxCoupon.setOrgInventory(oldCoupon.getInventory()); | ||||
| wxCoupon.setOrgRemainInventory(oldCoupon.getRemainInventory()); | wxCoupon.setOrgRemainInventory(oldCoupon.getRemainInventory()); | ||||
| if((wxCoupon.getRemainInventory() - wxCoupon.getOrgRemainInventory()) != (wxCoupon.getInventory() - wxCoupon.getOrgInventory())) { | |||||
| // 库存要保证,同增同减 | |||||
| Integer newSale1 = wxCoupon.getRemainInventory() - wxCoupon.getOrgRemainInventory(); | |||||
| Integer oldSale1 = wxCoupon.getInventory() - wxCoupon.getOrgInventory(); | |||||
| if (!newSale1.equals(oldSale1)) { | |||||
| // 库存要保证,同增同减 | |||||
| logger.error("券库存要保证同增同减"); | logger.error("券库存要保证同增同减"); | ||||
| return new ResultData(ErrorCode.COUPON_STOCK_NO_EQUAL_ERR); | return new ResultData(ErrorCode.COUPON_STOCK_NO_EQUAL_ERR); | ||||
| } | } | ||||
| @@ -13,6 +13,7 @@ import com.iformall.domain.po.msg.WxMsgRecord; | |||||
| import com.iformall.domain.vo.FlowUserVo; | import com.iformall.domain.vo.FlowUserVo; | ||||
| import com.iformall.domain.vo.UserTaskVo; | import com.iformall.domain.vo.UserTaskVo; | ||||
| import com.iformall.domain.vo.WxBillAll; | import com.iformall.domain.vo.WxBillAll; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| @@ -38,6 +39,8 @@ import org.flowable.task.api.TaskQuery; | |||||
| 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.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Propagation; | import org.springframework.transaction.annotation.Propagation; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| @@ -90,6 +93,9 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| private WxBillSettleMapper wxBillSettleMapper; | private WxBillSettleMapper wxBillSettleMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxBillSettleService wxBillSettleService; | private WxBillSettleService wxBillSettleService; | ||||
| @Autowired | |||||
| @Qualifier("couponChannelRedisTemplate") | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> cdRedisTemplate; | |||||
| /** | /** | ||||
| * 获取流程key | * 获取流程key | ||||
| @@ -286,6 +292,7 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| wxCoupon.setRemainInventory(remainInventory); | wxCoupon.setRemainInventory(remainInventory); | ||||
| wxCoupon.setType(type); | wxCoupon.setType(type); | ||||
| wxCoupon.setValidType(validType); | wxCoupon.setValidType(validType); | ||||
| wxCoupon.setTenantId(wxCoupon.getTenantId()); | |||||
| wxCouponService.updateCouponStockAndEndTime(wxCoupon); | wxCouponService.updateCouponStockAndEndTime(wxCoupon); | ||||
| } | } | ||||
| }else if(EnumCouponAppType.CANCLE.getCode().equals(operateType)){ | }else if(EnumCouponAppType.CANCLE.getCode().equals(operateType)){ | ||||
| @@ -298,6 +305,8 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| } | } | ||||
| wxCoupon.setApprovalType(operateType); | wxCoupon.setApprovalType(operateType); | ||||
| wxCouponMapper.updateById(wxCoupon); | wxCouponMapper.updateById(wxCoupon); | ||||
| //清除缓存 | |||||
| clearCache(wxCoupon.getTenantId()); | |||||
| }else if(EnumFlowKey.SETTLE.getCode().equals(flowType)){ | }else if(EnumFlowKey.SETTLE.getCode().equals(flowType)){ | ||||
| WxBillSettle wxBillSettle = new WxBillSettle(); | WxBillSettle wxBillSettle = new WxBillSettle(); | ||||
| wxBillSettle.setId(businessId); | wxBillSettle.setId(businessId); | ||||
| @@ -323,6 +332,17 @@ public class WxFlowServiceImpl implements WxFlowService { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 清除c端首页卷列表缓存 | |||||
| * @param tenantId | |||||
| */ | |||||
| public void clearCache(String tenantId){ | |||||
| for (int i = 1; i <=5 ; i++) { | |||||
| String key = EnumCacheKey.C_INDEX_PAGE_LIST.getMessage()+tenantId+"_" + i + ":"; | |||||
| cdRedisTemplate.delete(key); | |||||
| } | |||||
| } | |||||
| public Map<String,Object> mallUserInfoToMap(MallUserInfo userInfo){ | public Map<String,Object> mallUserInfoToMap(MallUserInfo userInfo){ | ||||
| try { | try { | ||||
| Map<String, Object> map = new HashMap<>(); | Map<String, Object> map = new HashMap<>(); | ||||
| @@ -18,7 +18,6 @@ import com.iformall.mapper.*; | |||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.*; | import com.iformall.utils.*; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| 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; | ||||
| @@ -271,7 +271,11 @@ | |||||
| SET | SET | ||||
| `remain_inventory` = #{remainInventory}, `inventory` = #{inventory}, | `remain_inventory` = #{remainInventory}, `inventory` = #{inventory}, | ||||
| `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays} | `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays} | ||||
| WHERE `tenant_id` = #{tenantId} and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory} | |||||
| WHERE 1=1 | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory} | |||||
| </update> | </update> | ||||
| @@ -141,7 +141,7 @@ | |||||
| (select count(*) as coupon_count,coupon_id from wx_coupon_password | (select count(*) as coupon_count,coupon_id from wx_coupon_password | ||||
| where tenant_id=#{tenantId} and status=0 group by coupon_id) cp | where tenant_id=#{tenantId} and status=0 group by coupon_id) cp | ||||
| inner join wx_coupon c on cp.coupon_id = c.id | inner join wx_coupon c on cp.coupon_id = c.id | ||||
| where c.tenant_id=#{tenantId} and c.status=0 | |||||
| where c.tenant_id=#{tenantId} and c.status=0 and c.put_apply_status in(0,2) | |||||
| <if test=" null != couponId "> | <if test=" null != couponId "> | ||||
| and cp.`coupon_id` = #{couponId} | and cp.`coupon_id` = #{couponId} | ||||
| </if> | </if> | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -156,6 +158,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.cache.CacheManager; | import org.springframework.cache.CacheManager; | ||||
| @@ -141,6 +143,24 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("couponChannelRedisTemplate") | |||||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("buserTokenRedisTemplate") | @Bean("buserTokenRedisTemplate") | ||||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | RedisTemplate<String, WxBuser> template = new RedisTemplate(); | ||||