diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index dbf900933..936f724de 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -230,6 +230,7 @@ public class WxCouponController extends BaseController { CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId(),null); CouponCacheUtils.removeOnlyCouponCache(redisTemplate, wxCoupon.getId()); + CouponCacheUtils.removeOldDetailCache(redisTemplate); return new ResultData(); } diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java index 2c4fba50c..b435e644c 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -527,11 +527,13 @@ public class WxCouponController extends BaseController { } ValueOperations operations = cdRedisTemplate.opsForValue(); + // 缓存 boolean hasKey = cdRedisTemplate.hasKey(key); if (hasKey) { // 从缓存获取用户信息 - WxCouponCVo wxCouponCVo = operations.get(key); + //WxCouponCVo wxCouponCVo = operations.get(key); + WxCouponCVo wxCouponCVo = CouponCacheUtils.getOldDetailCache(redisTemplate, couponChannelIdL, couponIdL); // 库存 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); diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCacheKey.java b/mallinkService/src/main/java/com/iformall/enums/EnumCacheKey.java index c933c8bf8..42c1aaaae 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCacheKey.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCacheKey.java @@ -16,7 +16,8 @@ public enum EnumCacheKey { TOPIC_ONE(5, "topicOne_"), TOPIC_LIST(6, "topiList_"), 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 map = new HashMap(); static { diff --git a/mallinkService/src/main/java/com/iformall/service/util/CouponCacheUtils.java b/mallinkService/src/main/java/com/iformall/service/util/CouponCacheUtils.java index a7e43007f..839de1334 100644 --- a/mallinkService/src/main/java/com/iformall/service/util/CouponCacheUtils.java +++ b/mallinkService/src/main/java/com/iformall/service/util/CouponCacheUtils.java @@ -3,6 +3,7 @@ package com.iformall.service.util; import com.github.pagehelper.PageInfo; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponChannel; +import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxMerchantVo; import com.iformall.enums.EnumCacheKey; import com.iformall.utils.RedisCacheUtils; @@ -131,4 +132,29 @@ public class CouponCacheUtils { return RedisCacheUtils.getCacheObject(template, key,PageInfo.class); } + public static void removeOldDetailCache(RedisTemplate template) { + String key = EnumCacheKey.OLD_DETAIL.getMessage(); + RedisCacheUtils.removeCachePrefix(template, key); + } + + public static void setOldDetaileCache(RedisTemplate 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 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); + } + }