| @@ -169,7 +169,7 @@ public class WxCampaignController extends BaseController { | |||||
| wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); | wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); | ||||
| wxCouponChannel.setSubTargetId(wxCampaign.getId()); | wxCouponChannel.setSubTargetId(wxCampaign.getId()); | ||||
| wxCouponChannel.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | wxCouponChannel.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | ||||
| List<WxCouponChannelVo> voList = wxCouponChannelService.listVo(wxCouponChannel); | |||||
| List<WxCouponChannelVo> voList = wxCouponChannelService.newfindListVo(wxCouponChannel); | |||||
| wxCampaign.setCoupons(voList); | wxCampaign.setCoupons(voList); | ||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, "查询成功", wxCampaign); | return new ResultData(Result.SUCCESS, "查询成功", wxCampaign); | ||||
| @@ -10,17 +10,13 @@ import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.dto.WxCouponChannelDto; | import com.iformall.domain.dto.WxCouponChannelDto; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.enums.EnumAppPlat; | |||||
| import com.iformall.enums.EnumCouponSourceType; | import com.iformall.enums.EnumCouponSourceType; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.service.QrCodeService; | import com.iformall.service.QrCodeService; | ||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import com.iformall.service.WxFlowService; | import com.iformall.service.WxFlowService; | ||||
| import com.iformall.utils.Constant; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -33,27 +29,17 @@ import org.springframework.web.bind.annotation.*; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxCouponChannel") | @RequestMapping("wxCouponChannel") | ||||
| @Api(description = "优惠券投放接口") | @Api(description = "优惠券投放接口") | ||||
| public class WxCouponChannelController extends BaseController { | public class WxCouponChannelController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelService wxCouponChannelService; | private WxCouponChannelService wxCouponChannelService; | ||||
| @Autowired | |||||
| private WxAppinfoController wxAppinfoController; | |||||
| @Autowired | |||||
| private WxCouponChannelMapper wxCouponChannelMapper; | |||||
| @Autowired | |||||
| private QrCodeService qrCodeService; | |||||
| @Autowired | |||||
| private WxFlowService wxFlowService; | |||||
| @Autowired | |||||
| private WxCouponService wxCouponService; | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @@ -78,7 +64,7 @@ public class WxCouponChannelController extends BaseController { | |||||
| }else{ | }else{ | ||||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | ||||
| } | } | ||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); | |||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -63,7 +63,7 @@ public class MemCouponController extends BaseController { | |||||
| }else{ | }else{ | ||||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | ||||
| } | } | ||||
| final PageInfo<WxCouponChannelVo> page = couponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); | |||||
| final PageInfo<WxCouponChannelVo> page = couponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -8,14 +8,7 @@ import com.iformall.domain.dto.WxCouponChannelDto; | |||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| 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.EnumAppPlat; | |||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.mapper.WxCouponChannelMapper; | |||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxCouponService; | |||||
| import com.iformall.service.WxFlowService; | |||||
| import com.iformall.utils.Constant; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -28,7 +21,6 @@ import org.springframework.web.bind.annotation.*; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| @RestController | @RestController | ||||
| @@ -39,14 +31,6 @@ public class WxCouponChannelController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelService wxCouponChannelService; | private WxCouponChannelService wxCouponChannelService; | ||||
| @Autowired | |||||
| private WxCouponChannelMapper wxCouponChannelMapper; | |||||
| @Autowired | |||||
| private QrCodeService qrCodeService; | |||||
| @Autowired | |||||
| private WxFlowService wxFlowService; | |||||
| @Autowired | |||||
| private WxCouponService wxCouponService; | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @@ -67,7 +51,7 @@ public class WxCouponChannelController extends BaseController { | |||||
| }else{ | }else{ | ||||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC); | ||||
| } | } | ||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); | |||||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -68,7 +68,7 @@ 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.listPageCVo(wxCouponChannel, pageNum, pageSize); | |||||
| PageInfo<WxCouponChannelVo> page = wxCouponChannelService.newListPageVo(wxCouponChannel, pageNum, pageSize); | |||||
| filterTimed(wxCouponChannel, page); | filterTimed(wxCouponChannel, page); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -113,7 +113,7 @@ public class WxCouponChannelController extends BaseController { | |||||
| } | } | ||||
| String merchantIdStr = (String) params.get("merchantId"); | String merchantIdStr = (String) params.get("merchantId"); | ||||
| List<String> merchantIds = (List<String>) params.get("merchantIds"); | |||||
| List<Long> merchantIds = (List<Long>) params.get("merchantIds"); | |||||
| Long merchantId = null; | Long merchantId = null; | ||||
| if(StringUtils.isNotBlank(merchantIdStr)){ | if(StringUtils.isNotBlank(merchantIdStr)){ | ||||
| merchantId = Long.parseLong(merchantIdStr); | merchantId = Long.parseLong(merchantIdStr); | ||||
| @@ -122,17 +122,15 @@ public class WxCouponChannelController extends BaseController { | |||||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | WxCouponChannel wxCouponChannel = new WxCouponChannel(); | ||||
| wxCouponChannel.setMerchantId(merchantId); | wxCouponChannel.setMerchantId(merchantId); | ||||
| wxCouponChannel.setMerchantIds(merchantIds); | wxCouponChannel.setMerchantIds(merchantIds); | ||||
| wxCouponChannel.setStatus(0); | |||||
| 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); | ||||
| wxCouponChannel.setShowBeginTime(new Date()); | |||||
| Map<String,Object> map = new HashedMap(); | Map<String,Object> map = new HashedMap(); | ||||
| wxCouponChannel.setShowBeginTime(new Date()); | |||||
| //TODO待优化数据,先用缓存处理 | |||||
| String key = wxCouponChannel.getTenantId(); | String key = wxCouponChannel.getTenantId(); | ||||
| if (null != merchantId) { | if (null != merchantId) { | ||||
| key = String.valueOf(merchantId); | key = String.valueOf(merchantId); | ||||
| @@ -141,9 +139,9 @@ public class WxCouponChannelController extends BaseController { | |||||
| } | } | ||||
| PageInfo<WxCouponChannelVo> page = RedisCacheUtils.getCacheObject(redisTemplate, "merchantCouponList:"+key, PageInfo.class); | PageInfo<WxCouponChannelVo> page = RedisCacheUtils.getCacheObject(redisTemplate, "merchantCouponList:"+key, PageInfo.class); | ||||
| if (null == page ) { | if (null == page ) { | ||||
| page = wxCouponChannelService.listByMerchant(wxCouponChannel,pageNum,pageSize); | |||||
| page = wxCouponChannelService.newListPageVo(wxCouponChannel,pageNum,pageSize); | |||||
| filterTimed(wxCouponChannel, page); | filterTimed(wxCouponChannel, page); | ||||
| RedisCacheUtils.cache(redisTemplate, "merchantCouponList:"+key, page, 3600); | |||||
| RedisCacheUtils.cache(redisTemplate, "merchantCouponList:"+key, page, 100); | |||||
| } | } | ||||
| if(wxCouponChannel.getMerchantId() != null){ | if(wxCouponChannel.getMerchantId() != null){ | ||||
| @@ -92,7 +92,7 @@ public class WxCouponChannel extends TenantEntity { | |||||
| private Long merchantId; | private Long merchantId; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<String> merchantIds; | |||||
| private List<Long> merchantIds; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @io.swagger.annotations.ApiModelProperty(value = "用户积分", name = "userCredit") | @io.swagger.annotations.ApiModelProperty(value = "用户积分", name = "userCredit") | ||||
| @@ -3,6 +3,7 @@ package com.iformall.domain.vo; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||||
| import com.iformall.common.SortColumn; | import com.iformall.common.SortColumn; | ||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| @@ -166,4 +167,40 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { | |||||
| public void setTitle(String title) { | public void setTitle(String title) { | ||||
| this.title = title; | this.title = title; | ||||
| } | } | ||||
| /** | |||||
| * 可能字段不全, 使用时先确认 | |||||
| * @param c | |||||
| */ | |||||
| public void setWxCoupon(WxCoupon c){ | |||||
| if(c != null){ | |||||
| this.setRemainInventory(c.getRemainInventory()); | |||||
| this.setInventory(c.getInventory()); | |||||
| this.setCoverImg(c.getCoverImg()); | |||||
| this.setSubTitle(c.getSubTitle()); | |||||
| this.setSalePrice(c.getSalePrice()); | |||||
| this.setUsePrice(c.getUsePrice()); | |||||
| this.setPrice(c.getPrice()); | |||||
| this.setTailPrice(c.getTailPrice()); | |||||
| this.setOrigPrice(c.getOrigPrice()); | |||||
| this.setUnit(c.getUnit()); | |||||
| this.setUseLimitRule(c.getUseLimitRule()); | |||||
| this.setUseLimitQuantity(c.getUseLimitQuantity()); | |||||
| this.setSendType(c.getSendType()); | |||||
| this.setSupportTransfer(c.getSupportTransfer()); | |||||
| this.setPressLimitNum(c.getPressLimitNum()); | |||||
| this.setAutoRefund(c.getAutoRefund()); | |||||
| this.setConditions(c.getConditions()); | |||||
| this.setValidType(c.getValidType()); | |||||
| this.setValidStartDate(c.getValidStartDate()); | |||||
| this.setValidEndDate(c.getValidEndDate()); | |||||
| this.setPickStartDate(c.getPickStartDate()); | |||||
| this.setPickEndDate(c.getPickEndDate()); | |||||
| this.setValidDays(c.getValidDays()); | |||||
| this.setCreditPrice(c.getCreditPrice()); | |||||
| this.setContentType(c.getContentType()); | |||||
| this.setSourceType(c.getSourceType()); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -19,9 +19,9 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| int countCouponChannel(WxCouponChannel wxCouponChannel); | int countCouponChannel(WxCouponChannel wxCouponChannel); | ||||
| List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | |||||
| // List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | |||||
| List<WxCouponChannelVo> findVoListByMerchant(WxCouponChannel wxCouponChannel); | |||||
| // List<WxCouponChannelVo> findVoListByMerchant(WxCouponChannel wxCouponChannel); | |||||
| WxCouponCVo findVoDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | WxCouponCVo findVoDetail(@Param("id")Long id,@Param("tenantId")String tenantId); | ||||
| @@ -2,12 +2,10 @@ 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.WxCouponOrder; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| 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; | ||||
| import com.iformall.enums.EnumPayWay; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -32,7 +30,7 @@ public interface WxCouponChannelService { | |||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| // PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| /** | /** | ||||
| @@ -42,7 +40,7 @@ public interface WxCouponChannelService { | |||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxCouponChannelVo> listByMerchant(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| // PageInfo<WxCouponChannelVo> listByMerchant(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| WxCouponCVo findDetailVo(Long id,String tenantId); | WxCouponCVo findDetailVo(Long id,String tenantId); | ||||
| @@ -54,7 +52,7 @@ public interface WxCouponChannelService { | |||||
| * @param record | * @param record | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| List<WxCouponChannelVo> listVo(WxCouponChannel record); | |||||
| // List<WxCouponChannelVo> listVo(WxCouponChannel record); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| @@ -85,4 +83,6 @@ public interface WxCouponChannelService { | |||||
| int countCoupon(WxCouponChannel wxCouponChannel, List<TenantEntity> tenantEntitys); | int countCoupon(WxCouponChannel wxCouponChannel, List<TenantEntity> tenantEntitys); | ||||
| List<WxCouponChannelVo> newfindListVo(WxCouponChannel wxCouponChannel); | List<WxCouponChannelVo> newfindListVo(WxCouponChannel wxCouponChannel); | ||||
| PageInfo<WxCouponChannelVo> newListPageVo(WxCouponChannel record, Integer pageIndex, Integer pageSize); | |||||
| } | } | ||||
| @@ -289,17 +289,12 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| return count; | return count; | ||||
| } | } | ||||
| @Override | |||||
| public List<WxCouponChannelVo> newfindListVo(WxCouponChannel wxCouponChannel) { | |||||
| List<WxCouponChannelVo> list = new ArrayList<>(); | |||||
| List<Long> mcids = new ArrayList<>(); | |||||
| if(wxCouponChannel.getMerchantId() != null){ | |||||
| mcids = wxCouponMerchantMapper.findOneMerchantProductIds(wxCouponChannel.getTenantId(), wxCouponChannel.getMerchantId()); | |||||
| if(mcids == null || mcids.isEmpty()){ | |||||
| return list; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 处理券相关查询参数,得到卷id list | |||||
| * @param wxCouponChannel | |||||
| * @return | |||||
| */ | |||||
| private List<Long> handleCouponParam(WxCouponChannel wxCouponChannel){ | |||||
| WxCoupon couponQ = new WxCoupon(); | WxCoupon couponQ = new WxCoupon(); | ||||
| couponQ.setStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); | couponQ.setStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); | ||||
| if(wxCouponChannel.getSupportTransfer() != null){ | if(wxCouponChannel.getSupportTransfer() != null){ | ||||
| @@ -312,52 +307,106 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| couponQ.setSourceType(wxCouponChannel.getSourceType()); | couponQ.setSourceType(wxCouponChannel.getSourceType()); | ||||
| } | } | ||||
| List<Long> cids = wxCouponMapper.findIdList(couponQ); | List<Long> cids = wxCouponMapper.findIdList(couponQ); | ||||
| return cids; | |||||
| } | |||||
| private void handleCouponIds(WxCouponChannel wxCouponChannel){ | |||||
| List<Long> cids =handleCouponParam(wxCouponChannel); | |||||
| if(cids == null || cids.isEmpty()){ | if(cids == null || cids.isEmpty()){ | ||||
| return list; | |||||
| wxCouponChannel.setId(-999L); | |||||
| return; | |||||
| } | |||||
| if(wxCouponChannel.getMerchantId() != null){ | |||||
| List<Long> mcids = wxCouponMerchantMapper.findOneMerchantProductIds(wxCouponChannel.getTenantId(), wxCouponChannel.getMerchantId()); | |||||
| if(mcids == null || mcids.isEmpty()){ | |||||
| wxCouponChannel.setId(-999L); | |||||
| return; | |||||
| } | |||||
| cids.retainAll(mcids); | |||||
| }else if(wxCouponChannel.getMerchantIds() != null && !wxCouponChannel.getMerchantIds().isEmpty()){ | |||||
| List<Long> mcids = wxCouponMerchantMapper.findMerchantProductIds(wxCouponChannel.getTenantId(), wxCouponChannel.getMerchantIds()); | |||||
| if(mcids == null || mcids.isEmpty()){ | |||||
| wxCouponChannel.setId(-999L); | |||||
| return; | |||||
| } | |||||
| cids.retainAll(mcids); | |||||
| } | } | ||||
| cids.retainAll(mcids); | |||||
| if(cids.isEmpty()){ | if(cids.isEmpty()){ | ||||
| return list; | |||||
| wxCouponChannel.setId(-999L); | |||||
| return; | |||||
| } | } | ||||
| wxCouponChannel.setCouponIds(cids); | wxCouponChannel.setCouponIds(cids); | ||||
| } | |||||
| list = wxCouponChannelMapper.newfindCList(wxCouponChannel); | |||||
| private void handleWxCouponChannelVo(List<WxCouponChannelVo> list, TenantEntity tenantEntity){ | |||||
| if(list == null || list.isEmpty()){ | |||||
| return; | |||||
| } | |||||
| List<Long> couponIds = list.stream().map(cc -> cc.getCouponId()).collect(Collectors.toList()); | List<Long> couponIds = list.stream().map(cc -> cc.getCouponId()).collect(Collectors.toList()); | ||||
| Map<Long,WxCoupon> couponMap = wxCouponService.getCouponMap(couponIds,wxCouponChannel); | |||||
| Map<Long,WxCoupon> couponMap = wxCouponService.getCouponMap(couponIds,tenantEntity); | |||||
| for (WxCouponChannelVo cc:list) { | for (WxCouponChannelVo cc:list) { | ||||
| WxCoupon c = couponMap.get(cc.getCouponId()); | |||||
| if(c != null){ | |||||
| cc.setRemainInventory(c.getRemainInventory()); | |||||
| cc.setInventory(c.getInventory()); | |||||
| cc.setCoverImg(c.getCoverImg()); | |||||
| cc.setSubTitle(c.getSubTitle()); | |||||
| cc.setSalePrice(c.getSalePrice()); | |||||
| cc.setUsePrice(c.getUsePrice()); | |||||
| cc.setPrice(c.getPrice()); | |||||
| cc.setTailPrice(c.getTailPrice()); | |||||
| cc.setOrigPrice(c.getOrigPrice()); | |||||
| cc.setUnit(c.getUnit()); | |||||
| cc.setUseLimitRule(c.getUseLimitRule()); | |||||
| cc.setUseLimitQuantity(c.getUseLimitQuantity()); | |||||
| cc.setSendType(c.getSendType()); | |||||
| cc.setSupportTransfer(c.getSupportTransfer()); | |||||
| cc.setPressLimitNum(c.getPressLimitNum()); | |||||
| cc.setAutoRefund(c.getAutoRefund()); | |||||
| cc.setConditions(c.getConditions()); | |||||
| cc.setValidType(c.getValidType()); | |||||
| cc.setValidStartDate(c.getValidStartDate()); | |||||
| cc.setValidEndDate(c.getValidEndDate()); | |||||
| cc.setPickStartDate(c.getPickStartDate()); | |||||
| cc.setPickEndDate(c.getPickEndDate()); | |||||
| cc.setValidDays(c.getValidDays()); | |||||
| cc.setCreditPrice(c.getCreditPrice()); | |||||
| cc.setContentType(c.getContentType()); | |||||
| cc.setSourceType(c.getSourceType()); | |||||
| } | |||||
| cc.setWxCoupon(couponMap.get(cc.getCouponId())); | |||||
| } | } | ||||
| } | |||||
| @Override | |||||
| public List<WxCouponChannelVo> newfindListVo(WxCouponChannel wxCouponChannel) { | |||||
| handleCouponIds(wxCouponChannel); | |||||
| if(-999L == wxCouponChannel.getId()){ | |||||
| return new ArrayList<>(); | |||||
| } | |||||
| List<WxCouponChannelVo> list = wxCouponChannelMapper.newfindCList(wxCouponChannel); | |||||
| handleWxCouponChannelVo(list,wxCouponChannel); | |||||
| return list; | return list; | ||||
| } | } | ||||
| /** | |||||
| * C端api使用,关联查找的券时已生效 | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| @Override | |||||
| 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(-999L == record.getId()){ | |||||
| 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(-999L == record.getId()){ | |||||
| return new PageInfo<WxCouponChannelVo>(); | |||||
| } | |||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.newfindCList(record)); | |||||
| handleWxCouponChannelVo(pageInfo.getList(),record); | |||||
| } | |||||
| return pageInfo; | |||||
| } | |||||
| private boolean isCouponMerchantValid(Long couponId,String tenantId) { | private boolean isCouponMerchantValid(Long couponId,String tenantId) { | ||||
| List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); | List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(couponId,tenantId); | ||||
| if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){ | if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){ | ||||
| @@ -465,33 +514,33 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| @Override | |||||
| public PageInfo<WxCouponChannelVo> listPageCVo(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{ | |||||
| pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | |||||
| //插入缓存 | |||||
| operations.set(key, pageInfo, 600, TimeUnit.SECONDS); | |||||
| } | |||||
| return pageInfo; | |||||
| } | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | |||||
| } | |||||
| // @Override | |||||
| // public PageInfo<WxCouponChannelVo> listPageCVo(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{ | |||||
| // pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | |||||
| // //插入缓存 | |||||
| // operations.set(key, pageInfo, 600, TimeUnit.SECONDS); | |||||
| // } | |||||
| // return pageInfo; | |||||
| // } | |||||
| // | |||||
| // return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); | |||||
| // } | |||||
| @Override | @Override | ||||
| public WxCouponCVo findDetailVo(Long id,String tenantId) { | public WxCouponCVo findDetailVo(Long id,String tenantId) { | ||||
| @@ -503,15 +552,15 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||||
| return wxCouponChannelMapper.findVoStatusDetail(id,tenantId); | return wxCouponChannelMapper.findVoStatusDetail(id,tenantId); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxCouponChannelVo> listVo(WxCouponChannel record) { | |||||
| return wxCouponChannelMapper.findVoList(record); | |||||
| } | |||||
| // @Override | |||||
| // public List<WxCouponChannelVo> listVo(WxCouponChannel record) { | |||||
| // return wxCouponChannelMapper.findVoList(record); | |||||
| // } | |||||
| @Override | |||||
| public PageInfo<WxCouponChannelVo> listByMerchant(WxCouponChannel record, Integer pageNum, Integer pageSize) { | |||||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoListByMerchant(record)); | |||||
| } | |||||
| // @Override | |||||
| // public PageInfo<WxCouponChannelVo> listByMerchant(WxCouponChannel record, Integer pageNum, Integer pageSize) { | |||||
| // return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoListByMerchant(record)); | |||||
| // } | |||||
| } | } | ||||
| @@ -204,7 +204,7 @@ public class WxTopicServiceImpl implements WxTopicService { | |||||
| } | } | ||||
| PageInfo<WxCouponChannelVo> wxCouponChannelVoPageInfo = wxCouponChannelService.listPageCVo(wxCouponChannel, 1, pageSize); | |||||
| PageInfo<WxCouponChannelVo> wxCouponChannelVoPageInfo = wxCouponChannelService.newListPageVo(wxCouponChannel, 1, pageSize); | |||||
| if(wxCouponChannelVoPageInfo != null && wxCouponChannelVoPageInfo.getList() != null | if(wxCouponChannelVoPageInfo != null && wxCouponChannelVoPageInfo.getList() != null | ||||
| && wxCouponChannelVoPageInfo.getList().size() > 0){ | && wxCouponChannelVoPageInfo.getList().size() > 0){ | ||||
| record.setCouponList(wxCouponChannelVoPageInfo.getList()); | record.setCouponList(wxCouponChannelVoPageInfo.getList()); | ||||