| @@ -230,6 +230,7 @@ public class WxCouponController extends BaseController { | |||||
| CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); | CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); | ||||
| CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId(),null); | CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId(),null); | ||||
| CouponCacheUtils.removeOnlyCouponCache(redisTemplate, wxCoupon.getId()); | CouponCacheUtils.removeOnlyCouponCache(redisTemplate, wxCoupon.getId()); | ||||
| CouponCacheUtils.removeOldDetailCache(redisTemplate); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -527,11 +527,13 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue(); | ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue(); | ||||
| // 缓存 | // 缓存 | ||||
| boolean hasKey = cdRedisTemplate.hasKey(key); | boolean hasKey = cdRedisTemplate.hasKey(key); | ||||
| if (hasKey) { | if (hasKey) { | ||||
| // 从缓存获取用户信息 | // 从缓存获取用户信息 | ||||
| WxCouponCVo wxCouponCVo = operations.get(key); | |||||
| //WxCouponCVo wxCouponCVo = operations.get(key); | |||||
| WxCouponCVo wxCouponCVo = CouponCacheUtils.getOldDetailCache(redisTemplate, couponChannelIdL, couponIdL); | |||||
| // 库存 | // 库存 | ||||
| if (couponIdL > 0L) { | if (couponIdL > 0L) { | ||||
| // 更新状态 | // 更新状态 | ||||
| @@ -576,7 +578,8 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| // 插入缓存 | // 插入缓存 | ||||
| operations.set(key, wxCouponCVo, 3600, TimeUnit.SECONDS); | |||||
| //operations.set(key, wxCouponCVo, 3600, TimeUnit.SECONDS); | |||||
| CouponCacheUtils.setOldDetaileCache(redisTemplate, wxCouponCVo, couponChannelIdL, couponIdL); | |||||
| updateActivityStatus(wxCouponCVo); | updateActivityStatus(wxCouponCVo); | ||||
| @@ -16,7 +16,8 @@ public enum EnumCacheKey { | |||||
| TOPIC_ONE(5, "topicOne_"), | TOPIC_ONE(5, "topicOne_"), | ||||
| TOPIC_LIST(6, "topiList_"), | TOPIC_LIST(6, "topiList_"), | ||||
| COUPON_CHANNEL_STOCK(7, "couponChannelStock:couponChannelStock_"), | COUPON_CHANNEL_STOCK(7, "couponChannelStock:couponChannelStock_"), | ||||
| DOUYIN_LIVE_PAGE_LIST(8,"douyinLiveList") | |||||
| DOUYIN_LIVE_PAGE_LIST(8,"douyinLiveList"), | |||||
| OLD_DETAIL(9,"cc:") | |||||
| ; | ; | ||||
| private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | ||||
| static { | static { | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service.util; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.vo.WxCouponCVo; | |||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.enums.EnumCacheKey; | import com.iformall.enums.EnumCacheKey; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| @@ -131,4 +132,29 @@ public class CouponCacheUtils { | |||||
| return RedisCacheUtils.getCacheObject(template, key,PageInfo.class); | return RedisCacheUtils.getCacheObject(template, key,PageInfo.class); | ||||
| } | } | ||||
| public static void removeOldDetailCache(RedisTemplate<String, Object> template) { | |||||
| String key = EnumCacheKey.OLD_DETAIL.getMessage(); | |||||
| RedisCacheUtils.removeCachePrefix(template, key); | |||||
| } | |||||
| public static void setOldDetaileCache(RedisTemplate<String, Object> template,WxCouponCVo coupon,Long couponChannelIdL,Long couponIdL) { | |||||
| String key = EnumCacheKey.OLD_DETAIL.getMessage(); | |||||
| if(couponChannelIdL > 0){ | |||||
| key = key + couponChannelIdL; | |||||
| }else if(couponIdL > 0){ | |||||
| key = key + couponIdL; | |||||
| } | |||||
| RedisCacheUtils.cache(template, key, coupon, 3600); | |||||
| } | |||||
| public static WxCouponCVo getOldDetailCache(RedisTemplate<String, Object> template,Long couponChannelIdL,Long couponIdL) { | |||||
| String key = EnumCacheKey.OLD_DETAIL.getMessage(); | |||||
| if(couponChannelIdL > 0){ | |||||
| key = key + couponChannelIdL; | |||||
| }else if(couponIdL > 0){ | |||||
| key = key + couponIdL; | |||||
| } | |||||
| return RedisCacheUtils.getCacheObject(template, key,WxCouponCVo.class); | |||||
| } | |||||
| } | } | ||||