|
|
|
@@ -21,18 +21,22 @@ import com.iformall.service.*; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.ValueOperations; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCouponChannelMapper wxCouponChannelMapper; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
WxCouponService wxCouponService; |
|
|
|
@Autowired |
|
|
|
WxMerchantMapper wxMerchantMapper; |
|
|
|
@@ -46,6 +50,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
QrCodeService qrCodeService; |
|
|
|
@Autowired |
|
|
|
WxCardInfoMapper wxCardInfoMapper; |
|
|
|
@Autowired |
|
|
|
@Qualifier("couponChannelRedisTemplate") |
|
|
|
RedisTemplate<String, PageInfo<WxCouponChannelVo>> cdRedisTemplate; |
|
|
|
|
|
|
|
/** |
|
|
|
* B端业务端 |
|
|
|
@@ -69,7 +76,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
if (record.getId() == null) { |
|
|
|
//record.setId(UUID.randomUUID().toString().replaceAll("-", "")); |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
wxCouponChannelMapper.insertSelective(record); |
|
|
|
return new ResultData(record); |
|
|
|
} else { |
|
|
|
@@ -111,9 +118,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
record.setUpdateDate(new Date()); |
|
|
|
wxCouponChannelMapper.updateByPrimaryKeySelective(record); |
|
|
|
} |
|
|
|
|
|
|
|
//清除缓存 |
|
|
|
clearCache(record.getTenantId()); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 清除c端首页卷列表缓存 |
|
|
|
* @param tenantId |
|
|
|
*/ |
|
|
|
public void clearCache(String tenantId){ |
|
|
|
for (int i = 1; i <=20 ; i++) { |
|
|
|
String key = "couponChannelList_"+tenantId+"_" + i + ":"; |
|
|
|
cdRedisTemplate.delete(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { |
|
|
|
List<WxCouponChannelAddVo> errorList = new ArrayList<>(); |
|
|
|
@@ -228,7 +249,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()) || // 砍价 |
|
|
|
channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()) || // 拼团 |
|
|
|
channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CREDIT.getCode()) // 积分商城 |
|
|
|
){ |
|
|
|
){ |
|
|
|
// 默认投放结束时间为有效时间之后 |
|
|
|
beginTime = new Date(); |
|
|
|
endTime = wxCoupon.getValidEndDate(); |
|
|
|
@@ -284,6 +305,24 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageInfo<WxCouponChannelVo> listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) { |
|
|
|
PageInfo<WxCouponChannelVo> pageInfo; |
|
|
|
//首页走缓存 |
|
|
|
if(EnumTargetAd.LIST.getCode().equals(record.getTargetAd()) && new Integer(6).equals(pageSize) && pageIndex.intValue() <=20 ) { |
|
|
|
logger.info("---------chache"); |
|
|
|
String key = "couponChannelList_"+record.getTenantId()+"_" + pageIndex + ":"; |
|
|
|
ValueOperations<String, PageInfo<WxCouponChannelVo>> operations = cdRedisTemplate.opsForValue(); |
|
|
|
boolean hasKey = cdRedisTemplate.hasKey(key); |
|
|
|
if (hasKey) { |
|
|
|
pageInfo = operations.get(key); |
|
|
|
logger.info("---------get:{}",pageInfo.getList().size()); |
|
|
|
}else{ |
|
|
|
pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); |
|
|
|
} |
|
|
|
//插入缓存 |
|
|
|
operations.set(key, pageInfo, 3600, TimeUnit.SECONDS); |
|
|
|
return pageInfo; |
|
|
|
} |
|
|
|
|
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -308,3 +347,4 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|