| @@ -60,11 +60,11 @@ public class WxCampaignController extends BaseController { | |||||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | wxCampaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | ||||
| wxCampaign.setSortColumns(BaseEntity.SortField.SortNum_ASC, BaseEntity.SortField.CreateTime_ASC); | wxCampaign.setSortColumns(BaseEntity.SortField.SortNum_ASC, BaseEntity.SortField.CreateTime_ASC); | ||||
| String key = getTenantInfo().getTenantId(); | |||||
| PageInfo<WxCampaign> page = RedisCacheUtils.getCacheObject(redisTemplate, "wxCampaignList:"+key, PageInfo.class); | |||||
| String key = EnumCacheKey.CAMPAIGN_PAGE_LIST.getMessage() + wxCampaign.getTenantId() + "_" + pageNum + ":"; | |||||
| PageInfo<WxCampaign> page = RedisCacheUtils.getCacheObject(redisTemplate, key, PageInfo.class); | |||||
| if (null == page ) { | if (null == page ) { | ||||
| page = wxCampaignService.clistAsPage(wxCampaign, pageNum, pageSize); | page = wxCampaignService.clistAsPage(wxCampaign, pageNum, pageSize); | ||||
| RedisCacheUtils.cache(redisTemplate, "wxCampaignList:"+key, page, 100); | |||||
| RedisCacheUtils.cache(redisTemplate, key, page, 100); | |||||
| } | } | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -1,10 +1,15 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.domain.po.WxCampaign; | |||||
| import com.iformall.enums.*; | |||||
| import org.apache.commons.collections.map.HashedMap; | import org.apache.commons.collections.map.HashedMap; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -12,6 +17,7 @@ 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.beans.factory.annotation.Qualifier; | ||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.data.redis.core.ValueOperations; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| @@ -21,10 +27,6 @@ import com.iformall.domain.po.WxCouponChannel; | |||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| 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.enums.EnumCouponChannelActivityStatus; | |||||
| import com.iformall.enums.EnumCouponChannelStatus; | |||||
| import com.iformall.enums.EnumCouponChannelType; | |||||
| import com.iformall.enums.EnumCouponStatus; | |||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| @@ -68,8 +70,14 @@ public class WxCouponChannelController extends BaseController { | |||||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC); | wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC); | ||||
| } | } | ||||
| wxCouponChannel.setShowBeginTime(new Date()); | wxCouponChannel.setShowBeginTime(new Date()); | ||||
| PageInfo<WxCouponChannelVo> page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||||
| filterTimed(wxCouponChannel, page); | |||||
| String key = EnumCacheKey.C_INDEX_PAGE_LIST.getMessage() + wxCouponChannel.getTenantId() + "_" + pageNum + ":"; | |||||
| PageInfo<WxCouponChannelVo> page = RedisCacheUtils.getCacheObject(redisTemplate, key, PageInfo.class); | |||||
| if (null == page ) { | |||||
| page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||||
| filterTimed(wxCouponChannel, page); | |||||
| RedisCacheUtils.cache(redisTemplate, key, page, 100); | |||||
| } | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -126,22 +134,29 @@ public class WxCouponChannelController extends BaseController { | |||||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | wxCouponChannel.updateTenantInfo(getTenantInfo()); | ||||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | ||||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.UpdateDate_DESC, BaseEntity.SortField.Id_DESC); | wxCouponChannel.setSortColumns(BaseEntity.SortField.UpdateDate_DESC, BaseEntity.SortField.Id_DESC); | ||||
| List<Integer> targetAds = new ArrayList<>(); | |||||
| targetAds.add(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode()); | |||||
| targetAds.add(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode()); | |||||
| targetAds.add(EnumCouponChannelType.COUPON_CHANNEL_ID_CARD.getCode()); | |||||
| targetAds.add(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()); | |||||
| targetAds.add(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()); | |||||
| wxCouponChannel.setTargetAds(targetAds); | |||||
| wxCouponChannel.setShowBeginTime(new Date()); | wxCouponChannel.setShowBeginTime(new Date()); | ||||
| Map<String,Object> map = new HashedMap(); | Map<String,Object> map = new HashedMap(); | ||||
| String key = wxCouponChannel.getTenantId(); | |||||
| String key = wxCouponChannel.getTenantId()+"_"; | |||||
| if (null != merchantId) { | if (null != merchantId) { | ||||
| key = String.valueOf(merchantId); | |||||
| key += String.valueOf(merchantId); | |||||
| }else if (null != merchantIds){ | }else if (null != merchantIds){ | ||||
| key = merchantIds.toString(); | |||||
| key += merchantIds.toString(); | |||||
| } | } | ||||
| PageInfo<WxCouponChannelVo> page = RedisCacheUtils.getCacheObject(redisTemplate, "merchantCouponList:"+key, PageInfo.class); | |||||
| key = EnumCacheKey.MERCHANT_COUPON_PAGE_LIST.getMessage() + key + "_" + pageNum + ":"; | |||||
| PageInfo<WxCouponChannelVo> page = RedisCacheUtils.getCacheObject(redisTemplate, key, PageInfo.class); | |||||
| if (null == page ) { | if (null == page ) { | ||||
| page = wxCouponChannelService.newListPageVo(wxCouponChannel,pageNum,pageSize); | |||||
| filterTimed(wxCouponChannel, page); | |||||
| RedisCacheUtils.cache(redisTemplate, "merchantCouponList:"+key, page, 100); | |||||
| page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||||
| filterTimed(wxCouponChannel, page); | |||||
| RedisCacheUtils.cache(redisTemplate, key, page, 100); | |||||
| } | } | ||||
| if(wxCouponChannel.getMerchantId() != null){ | if(wxCouponChannel.getMerchantId() != null){ | ||||
| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||||
| import com.iformall.annotation.RedisCache; | import com.iformall.annotation.RedisCache; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxTopic; | import com.iformall.domain.po.WxTopic; | ||||
| import com.iformall.enums.EnumCacheKey; | |||||
| import com.iformall.enums.EnumWxTopicType; | import com.iformall.enums.EnumWxTopicType; | ||||
| import com.iformall.service.WxTopicService; | import com.iformall.service.WxTopicService; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| @@ -15,6 +16,8 @@ import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import java.util.List; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/api/topic") | @RequestMapping("/api/topic") | ||||
| @@ -40,7 +43,14 @@ public class WxTopicController extends BaseController { | |||||
| WxTopic wxTopic = new WxTopic(); | WxTopic wxTopic = new WxTopic(); | ||||
| wxTopic.updateTenantInfo(getTenantInfo()); | wxTopic.updateTenantInfo(getTenantInfo()); | ||||
| wxTopic.setTopicType(topicType); | wxTopic.setTopicType(topicType); | ||||
| return new ResultData(wxTopicService.show(wxTopic)); | |||||
| String key = EnumCacheKey.TOPIC_ONE.getMessage() + wxTopic.getTenantId() + ":"; | |||||
| WxTopic show = RedisCacheUtils.getCacheObject(redisTemplate, key, WxTopic.class); | |||||
| if (null == show ) { | |||||
| show = wxTopicService.show(wxTopic); | |||||
| RedisCacheUtils.cache(redisTemplate, key, show, 100); | |||||
| } | |||||
| return new ResultData(show); | |||||
| } | } | ||||
| @RedisCache | @RedisCache | ||||
| @@ -50,7 +60,14 @@ public class WxTopicController extends BaseController { | |||||
| WxTopic wxTopic = new WxTopic(); | WxTopic wxTopic = new WxTopic(); | ||||
| wxTopic.updateTenantInfo(getTenantInfo()); | wxTopic.updateTenantInfo(getTenantInfo()); | ||||
| wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode()); | wxTopic.setTopicType(EnumWxTopicType.SPECIAL_TOPIC.getCode()); | ||||
| return new ResultData(wxTopicService.showList(wxTopic)); | |||||
| String key = EnumCacheKey.TOPIC_LIST.getMessage() + wxTopic.getTenantId() + ":"; | |||||
| List<WxTopic> topicList = RedisCacheUtils.getCacheObject(redisTemplate, key, List.class); | |||||
| if (null == topicList ) { | |||||
| topicList = wxTopicService.showList(wxTopic); | |||||
| RedisCacheUtils.cache(redisTemplate, key, topicList, 100); | |||||
| } | |||||
| return new ResultData(topicList); | |||||
| } | } | ||||
| @RedisCache | @RedisCache | ||||
| @@ -35,6 +35,8 @@ public class WxCouponChannel extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| protected List<Long> couponIds; | protected List<Long> couponIds; | ||||
| @TableField(exist = false) | |||||
| protected List<Integer> targetAds; | |||||
| @io.swagger.annotations.ApiModelProperty(value="卡券id",name="couponId") | @io.swagger.annotations.ApiModelProperty(value="卡券id",name="couponId") | ||||
| private Long couponId; | private Long couponId; | ||||
| @@ -10,7 +10,11 @@ public enum EnumCacheKey { | |||||
| C_INDEX_PAGE_LIST(0, "couponChannelList_"), | C_INDEX_PAGE_LIST(0, "couponChannelList_"), | ||||
| COUPON_STOCK(1,"couponStock:couponStock_"), | COUPON_STOCK(1,"couponStock:couponStock_"), | ||||
| ACTIVITY_STOCK(2,"activityStock:activityStock_") | |||||
| ACTIVITY_STOCK(2,"activityStock:activityStock_"), | |||||
| CAMPAIGN_PAGE_LIST(3,"campaignList_"), | |||||
| MERCHANT_COUPON_PAGE_LIST(4, "merchantCouponList_"), | |||||
| TOPIC_ONE(5, "topicOne_"), | |||||
| TOPIC_LIST(6, "topiList_"), | |||||
| ; | ; | ||||
| private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | ||||
| static { | static { | ||||
| @@ -370,40 +370,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| */ | */ | ||||
| @Override | @Override | ||||
| public PageInfo<WxCouponChannelVo> newListPageVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCouponChannelVo> newListPageVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | ||||
| PageInfo<WxCouponChannelVo> pageInfo; | |||||
| //仅c端首页走缓存 | |||||
| if((EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode().equals(record.getTargetAd()) | |||||
| || EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_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{ | |||||
| handleCouponIds(record); | |||||
| if(record.getId() != null && record.getId().equals(-999L)){ | |||||
| return new PageInfo<WxCouponChannelVo>(); | |||||
| } | |||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.newfindCList(record)); | |||||
| handleWxCouponChannelVo(pageInfo.getList(),record); | |||||
| //插入缓存 | |||||
| operations.set(key, pageInfo, 100, TimeUnit.SECONDS); | |||||
| } | |||||
| }else{ | |||||
| handleCouponIds(record); | |||||
| if(record.getId() != null && record.getId().equals(-999L)){ | |||||
| return new PageInfo<WxCouponChannelVo>(); | |||||
| } | |||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.newfindCList(record)); | |||||
| handleWxCouponChannelVo(pageInfo.getList(),record); | |||||
| } | |||||
| handleCouponIds(record); | |||||
| if(record.getId() != null && record.getId().equals(-999L)){ | |||||
| return new PageInfo<WxCouponChannelVo>(); | |||||
| } | |||||
| PageInfo<WxCouponChannelVo> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.newfindCList(record)); | |||||
| handleWxCouponChannelVo(pageInfo.getList(),record); | |||||
| return pageInfo; | return pageInfo; | ||||
| } | } | ||||
| @@ -505,6 +505,12 @@ | |||||
| #{couponIdsItem} | #{couponIdsItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test=" null != targetAds "> | |||||
| and cc.target_ad in | |||||
| <foreach collection="targetAds" index="index" item="targetAdsItem" open="(" separator="," close=")"> | |||||
| #{targetAdsItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||