| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -160,4 +162,21 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -122,4 +124,21 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -1,10 +1,12 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -140,4 +142,20 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -160,4 +162,21 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -144,4 +146,20 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -122,4 +124,20 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -241,6 +241,7 @@ public class PosServiceImpl implements PosService { | |||||
| promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | ||||
| // 券优惠总信息 | // 券优惠总信息 | ||||
| promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | ||||
| promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); | |||||
| promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | ||||
| } else if(sceneType.equals(EnumPosSceneType.PAY)) { | } else if(sceneType.equals(EnumPosSceneType.PAY)) { | ||||
| JSONObject promotionCoupon = new JSONObject(); | JSONObject promotionCoupon = new JSONObject(); | ||||
| @@ -356,6 +357,7 @@ public class PosServiceImpl implements PosService { | |||||
| promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | ||||
| // 券优惠总信息 | // 券优惠总信息 | ||||
| promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | ||||
| promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); | |||||
| promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | ||||
| } | } | ||||
| // 构造支付信息 | // 构造支付信息 | ||||
| @@ -497,7 +499,7 @@ public class PosServiceImpl implements PosService { | |||||
| retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); | retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); | ||||
| retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); | retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); | ||||
| if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { | if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { | ||||
| retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getSalePrice()); | |||||
| retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getUsePrice()); | |||||
| String des = String.format("%s-满%s元可用,可抵%s元, 过期时间: %s", | String des = String.format("%s-满%s元可用,可抵%s元, 过期时间: %s", | ||||
| couponType.getMessage(), couponOrderCVo.getUsePriceStr(), couponOrderCVo.getPriceStr(), | couponType.getMessage(), couponOrderCVo.getUsePriceStr(), couponOrderCVo.getPriceStr(), | ||||
| mydateFormat.format(couponOrderCVo.getExpiredTime())); | mydateFormat.format(couponOrderCVo.getExpiredTime())); | ||||
| @@ -557,7 +559,7 @@ public class PosServiceImpl implements PosService { | |||||
| retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); | retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); | ||||
| retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); | retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); | ||||
| if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { | if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { | ||||
| retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getSalePrice()); | |||||
| retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getUsePrice()); | |||||
| String des = String.format("%s-满%s元可用,可抵%s元, 过期时间: %s", | String des = String.format("%s-满%s元可用,可抵%s元, 过期时间: %s", | ||||
| couponType.getMessage(), couponOrderCVo.getUsePriceStr(), couponOrderCVo.getPriceStr(), | couponType.getMessage(), couponOrderCVo.getUsePriceStr(), couponOrderCVo.getPriceStr(), | ||||
| mydateFormat.format(couponOrderCVo.getExpiredTime())); | mydateFormat.format(couponOrderCVo.getExpiredTime())); | ||||
| @@ -840,6 +842,7 @@ public class PosServiceImpl implements PosService { | |||||
| promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | ||||
| // 券优惠总信息 | // 券优惠总信息 | ||||
| promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | ||||
| promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); | |||||
| promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | ||||
| } else if(sceneType.equals(EnumPosSceneType.PAY)) { | } else if(sceneType.equals(EnumPosSceneType.PAY)) { | ||||
| JSONObject promotionCoupon = new JSONObject(); | JSONObject promotionCoupon = new JSONObject(); | ||||
| @@ -922,6 +925,7 @@ public class PosServiceImpl implements PosService { | |||||
| promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); | ||||
| // 券优惠总信息 | // 券优惠总信息 | ||||
| promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); | ||||
| promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); | |||||
| promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); | ||||
| } | } | ||||
| // 构造支付信息 | // 构造支付信息 | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -145,4 +147,21 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -21,18 +21,22 @@ import com.iformall.service.*; | |||||
| 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 | ||||
| public class WxCouponChannelServiceImpl implements WxCouponChannelService { | public class WxCouponChannelServiceImpl implements WxCouponChannelService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| @Autowired | |||||
| WxCouponChannelMapper wxCouponChannelMapper; | WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | |||||
| @Autowired | |||||
| WxCouponService wxCouponService; | WxCouponService wxCouponService; | ||||
| @Autowired | @Autowired | ||||
| WxMerchantMapper wxMerchantMapper; | WxMerchantMapper wxMerchantMapper; | ||||
| @@ -46,6 +50,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| QrCodeService qrCodeService; | QrCodeService qrCodeService; | ||||
| @Autowired | @Autowired | ||||
| WxCardInfoMapper wxCardInfoMapper; | WxCardInfoMapper wxCardInfoMapper; | ||||
| @Autowired | |||||
| @Qualifier("couponChannelRedisTemplate") | |||||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> cdRedisTemplate; | |||||
| /** | /** | ||||
| * B端业务端 | * B端业务端 | ||||
| @@ -69,7 +76,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxCouponChannelMapper.insertSelective(record); | wxCouponChannelMapper.insertSelective(record); | ||||
| return new ResultData(record); | return new ResultData(record); | ||||
| } else { | } else { | ||||
| @@ -111,9 +118,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| wxCouponChannelMapper.updateByPrimaryKeySelective(record); | wxCouponChannelMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| //清除缓存 | |||||
| clearCache(record.getTenantId()); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| /** | |||||
| * 清除c端首页卷列表缓存 | |||||
| * @param tenantId | |||||
| */ | |||||
| public void clearCache(String tenantId){ | |||||
| for (int i = 1; i <=20 ; i++) { | |||||
| String key = "couponChannelList_"+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<>(); | ||||
| @@ -228,7 +249,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()) || // 砍价 | channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()) || // 砍价 | ||||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()) || // 拼团 | channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()) || // 拼团 | ||||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CREDIT.getCode()) // 积分商城 | channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CREDIT.getCode()) // 积分商城 | ||||
| ){ | |||||
| ){ | |||||
| // 默认投放结束时间为有效时间之后 | // 默认投放结束时间为有效时间之后 | ||||
| beginTime = new Date(); | beginTime = new Date(); | ||||
| endTime = wxCoupon.getValidEndDate(); | endTime = wxCoupon.getValidEndDate(); | ||||
| @@ -284,6 +305,24 @@ 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; | |||||
| //首页走缓存 | |||||
| if(EnumTargetAd.LIST.getCode().equals(record.getTargetAd()) && new Integer(6).equals(pageSize) && pageIndex.intValue() <=20 ) { | |||||
| logger.info("---------chache"); | |||||
| String key = "couponChannelList_"+record.getTenantId()+"_" + pageIndex + ":"; | |||||
| ValueOperations<String, PageInfo<WxCouponChannelVo>> operations = cdRedisTemplate.opsForValue(); | |||||
| boolean hasKey = cdRedisTemplate.hasKey(key); | |||||
| if (hasKey) { | |||||
| pageInfo = operations.get(key); | |||||
| logger.info("---------get:{}",pageInfo.getList().size()); | |||||
| }else{ | |||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | |||||
| } | |||||
| //插入缓存 | |||||
| operations.set(key, pageInfo, 3600, TimeUnit.SECONDS); | |||||
| return pageInfo; | |||||
| } | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | ||||
| } | } | ||||
| @@ -308,3 +347,4 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| } | } | ||||
| } | } | ||||
| @@ -6,7 +6,6 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.google.common.collect.Lists; | import com.google.common.collect.Lists; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.msg.AppUniformMsg; | import com.iformall.domain.po.msg.AppUniformMsg; | ||||
| import com.iformall.domain.po.msg.MpAppMsg; | import com.iformall.domain.po.msg.MpAppMsg; | ||||
| @@ -26,7 +25,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| 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; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.*; | import java.util.*; | ||||
| @@ -11,6 +11,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.dto.WxCouponMerchantDto; | import com.iformall.domain.dto.WxCouponMerchantDto; | ||||
| 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 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.*; | ||||
| @@ -22,6 +23,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; | ||||
| @@ -69,6 +72,10 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| @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(); | ||||
| @@ -427,9 +434,24 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| wxCouponMapper.updateByPrimaryKeySelective(record); | wxCouponMapper.updateByPrimaryKeySelective(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 <=20 ; i++) { | |||||
| String key = "couponChannelList_"+tenantId+"_" + i + ":"; | |||||
| cdRedisTemplate.delete(key); | |||||
| } | |||||
| } | |||||
| @Override | @Override | ||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxCouponMapper.deleteByPrimaryKey(id); | wxCouponMapper.deleteByPrimaryKey(id); | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -160,4 +162,21 @@ 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; | |||||
| } | |||||
| } | } | ||||
| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.config; | package com.iformall.config; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.PushLimit; | import com.iformall.domain.po.PushLimit; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| 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; | ||||
| @@ -144,4 +146,22 @@ 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; | |||||
| } | |||||
| } | } | ||||