| @@ -9,6 +9,7 @@ import java.util.concurrent.TimeUnit; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.domain.po.WxCampaign; | import com.iformall.domain.po.WxCampaign; | ||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.enums.*; | 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; | ||||
| @@ -96,6 +97,38 @@ public class WxCouponChannelController extends BaseController { | |||||
| } | } | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @RedisCache | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("douyinLiveList") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||||
| public ResultData zhiboList(@ModelAttribute WxCouponChannel wxCouponChannel,Integer pageNum, Integer pageSize) { | |||||
| if (null == wxCouponChannel) wxCouponChannel = new WxCouponChannel(); | |||||
| wxCouponChannel.updateTenantInfo(getTenantInfo()); | |||||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||||
| wxCouponChannel.setCouponStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); | |||||
| wxCouponChannel.setSortColumn(null); | |||||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC); | |||||
| wxCouponChannel.setShowBeginTime(new Date()); | |||||
| String key = EnumCacheKey.DOUYIN_LIVE_PAGE_LIST.getMessage() | |||||
| + wxCouponChannel.getTenantId() + "_" | |||||
| + wxCouponChannel.getTargetAd() + "_" | |||||
| + wxCouponChannel.getBusiness() + "_" | |||||
| + pageNum + ":"+ pageNum + ":"; | |||||
| PageInfo<WxCoupon> page = RedisCacheUtils.getCacheObject(redisTemplate, key, PageInfo.class); | |||||
| logger.info("WxCouponChannelController.chache.get:{} page:{}",key,page); | |||||
| if (null == page ) { | |||||
| page = wxCouponChannelService.liveHomePage(wxCouponChannel, pageNum, pageSize); | |||||
| if(page.getList() != null && page.getList().size() > 0){ | |||||
| RedisCacheUtils.cache(redisTemplate, key, page, 100); | |||||
| } | |||||
| } | |||||
| return new ResultData(page); | |||||
| } | |||||
| // @ApiOperation("商户活动列表信息") | // @ApiOperation("商户活动列表信息") | ||||
| @@ -16,6 +16,7 @@ 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") | |||||
| ; | ; | ||||
| private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | private static Map<Integer,EnumCacheKey> map = new HashMap<Integer,EnumCacheKey>(); | ||||
| static { | static { | ||||
| @@ -48,6 +48,8 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| List<WxCouponChannel> newfindCList(WxCouponChannel wxCouponChannel); | List<WxCouponChannel> newfindCList(WxCouponChannel wxCouponChannel); | ||||
| List<WxCouponChannel> liveHomeList(WxCouponChannel wxCouponChannel); | |||||
| /** | /** | ||||
| * 查询已同步的上架卷的Id | * 查询已同步的上架卷的Id | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| 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.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| @@ -62,6 +63,8 @@ public interface WxCouponChannelService { | |||||
| PageInfo<WxCouponChannelVo> newListPageVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | PageInfo<WxCouponChannelVo> newListPageVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | ||||
| PageInfo<WxCoupon> liveHomePage(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| void reduceChannelStock(TenantEntity tenantEntity,Long couponChannelId, Integer number); | void reduceChannelStock(TenantEntity tenantEntity,Long couponChannelId, Integer number); | ||||
| void backChannelStock(TenantEntity tenantEntity,Long couponChannelId, Integer number); | void backChannelStock(TenantEntity tenantEntity,Long couponChannelId, Integer number); | ||||
| void setChannelStock(WxCouponChannel record,Integer number); | void setChannelStock(WxCouponChannel record,Integer number); | ||||
| @@ -485,6 +485,56 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| retPageInfo.setList(handleWxCouponChannelVo(pageInfo.getList(),record)); | retPageInfo.setList(handleWxCouponChannelVo(pageInfo.getList(),record)); | ||||
| return retPageInfo; | return retPageInfo; | ||||
| } | } | ||||
| /** | |||||
| * 直播间查询,精简字段,提升效率 | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| @Override | |||||
| public PageInfo<WxCoupon> liveHomePage(WxCouponChannel record, Integer pageIndex, Integer pageSize) { | |||||
| PageInfo<WxCouponChannel> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.liveHomeList(record)); | |||||
| PageInfo<WxCoupon> retPageInfo = new PageInfo<WxCoupon>(); | |||||
| retPageInfo.setPageNum(pageInfo.getPageNum()); | |||||
| retPageInfo.setPageSize(pageInfo.getPageSize()); | |||||
| retPageInfo.setPages(pageInfo.getPages()); | |||||
| retPageInfo.setTotal(pageInfo.getTotal()); | |||||
| retPageInfo.setList(toLiveHomeCouponList(pageInfo.getList(),record)); | |||||
| return retPageInfo; | |||||
| } | |||||
| private List<WxCoupon> toLiveHomeCouponList(List<WxCouponChannel> list, TenantEntity tenantEntity){ | |||||
| if(list == null || list.isEmpty()){ | |||||
| return null; | |||||
| } | |||||
| List<Long> couponIds = list.stream().map(cc -> cc.getCouponId()).collect(Collectors.toList()); | |||||
| Map<Long,WxCoupon> couponMap = wxCouponService.getCouponMap(couponIds,tenantEntity); | |||||
| List<WxCoupon> retList = new ArrayList<>(); | |||||
| for (WxCouponChannel cc:list) { | |||||
| WxCoupon cm = couponMap.get(cc.getCouponId()); | |||||
| if (null != cm) { | |||||
| WxCoupon vo = new WxCoupon(); | |||||
| vo.setId(cc.getId()); | |||||
| vo.setCouponId(cc.getCouponId()); | |||||
| vo.setCoverImg(cm.getCoverImg()); | |||||
| vo.setTitle(cm.getTitle()); | |||||
| vo.setRemainInventory(cm.getRemainInventory()); | |||||
| vo.setInventory(cm.getInventory()); | |||||
| vo.setSalePrice(cm.getSalePrice()); | |||||
| vo.setPrice(cm.getPrice()); | |||||
| retList.add(vo); | |||||
| } | |||||
| } | |||||
| if (retList.size() <= 0 ) { | |||||
| return null; | |||||
| } | |||||
| return retList; | |||||
| } | |||||
| private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { | private boolean isCouponMerchantValid(Long couponId,TenantEntity tenantEntity) { | ||||
| List<WxMerchantVo> merchantVoList = wxMerchantService.findMerchantListByProduct(tenantEntity,couponId,false); | List<WxMerchantVo> merchantVoList = wxMerchantService.findMerchantListByProduct(tenantEntity,couponId,false); | ||||
| @@ -328,6 +328,41 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </select> | </select> | ||||
| <select id="liveHomeList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap"> | |||||
| select cc.`id`,cc.`coupon_id` | |||||
| from wx_coupon_channel cc | |||||
| where cc.`tenant_id` = #{tenantId} and cc.`target_ad` = #{targetAd} | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and cc.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != business "> | |||||
| and cc.`business` = #{business} | |||||
| </if> | |||||
| <if test=" null != subBusiness "> | |||||
| and cc.`sub_business` = #{subBusiness} | |||||
| </if> | |||||
| <if test=" null != showBeginTime "> | |||||
| and cc.`show_begin_time` <= #{showBeginTime} | |||||
| </if> | |||||
| <if test=" null != status "> | |||||
| and cc.`status` = #{status} | |||||
| </if> | |||||
| <if test=" null != couponStatus "> | |||||
| and cc.`coupon_status` = #{couponStatus} | |||||
| </if> | |||||
| <if test=" null != subTargetId "> | |||||
| and cc.`sub_target_id` = #{subTargetId} | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </select> | |||||
| <select id="getPoiProductIdList" parameterType="java.util.HashMap" resultType="Long"> | <select id="getPoiProductIdList" parameterType="java.util.HashMap" resultType="Long"> | ||||