|
@@ -2,6 +2,7 @@ package com.qs.mp.admin.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -13,13 +14,9 @@ import com.qs.mp.admin.domain.param.TicketBoxCreateParam;
|
|
|
import com.qs.mp.admin.domain.param.TicketBoxUpdateParam;
|
|
|
import com.qs.mp.admin.mapper.TicketBoxMapper;
|
|
|
import com.qs.mp.admin.service.*;
|
|
|
-import com.qs.mp.common.enums.MqTopicType;
|
|
|
-import com.qs.mp.common.enums.TicketBoxStatusEnum;
|
|
|
-import com.qs.mp.common.enums.TicketPkgSaleStatusEnum;
|
|
|
-import com.qs.mp.common.enums.TicketPkgStatusEnum;
|
|
|
-import com.qs.mp.common.enums.TicketPrizeTypeEnum;
|
|
|
-import com.qs.mp.common.enums.TicketStatusEnum;
|
|
|
-import com.qs.mp.common.enums.TicketTypeEnum;
|
|
|
+import com.qs.mp.channel.domain.Channel;
|
|
|
+import com.qs.mp.channel.service.IChannelService;
|
|
|
+import com.qs.mp.common.enums.*;
|
|
|
import com.qs.mp.common.exception.ServiceException;
|
|
|
import com.qs.mp.common.pulsar.PulsarClientService;
|
|
|
import com.qs.mp.common.utils.LogUtil;
|
|
@@ -93,6 +90,18 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
|
|
|
@Autowired
|
|
|
private ICouponPkgService couponPkgService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ITicketBoxChannelService ticketBoxChannelService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IChannelService channelService;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TicketBox> listBySaleChannel(QueryWrapper<TicketBox> queryWrapper) {
|
|
|
+ return getBaseMapper().listBySaleChannel(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean updateTicketBox(TicketBoxUpdateParam param) {
|
|
@@ -107,8 +116,43 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
|
|
|
ticketBox.setSalePrice(param.getSalePrice());
|
|
|
ticketBox.setPkgSalePrice(param.getPkgSalePrice());
|
|
|
ticketBox.setSaleCommRate(param.getSaleCommRate());
|
|
|
+ ticketBox.setSaleChannelType(param.getSaleChannelType());
|
|
|
this.updateById(ticketBox);
|
|
|
|
|
|
+ // 清除指定渠道内容
|
|
|
+ ticketBoxChannelService.remove(new LambdaUpdateWrapper<TicketBoxChannel>().eq(TicketBoxChannel::getBoxId, ticketBox.getBoxId()));
|
|
|
+
|
|
|
+ // 指定渠道
|
|
|
+ if (TicketBoxSaleChannelTypeEnum.PART.getValue().equals(param.getSaleChannelType())) {
|
|
|
+ List<Long> channelIdList = param.getChannelIdList();
|
|
|
+ if (CollectionUtils.isEmpty(channelIdList)) {
|
|
|
+ throw new ServiceException("渠道列表为空");
|
|
|
+ }
|
|
|
+ // 校验嵌套问题
|
|
|
+ List<String> channelNoList = channelService.list(new LambdaQueryWrapper<Channel>()
|
|
|
+ .in(Channel::getChannelId, channelIdList))
|
|
|
+ .stream().map(Channel::getChannelNo)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (int i = 0; i < channelNoList.size(); i++) {
|
|
|
+ for (int j = 0; j < channelNoList.size(); j++) {
|
|
|
+ if (i == j) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (channelNoList.get(i).contains(channelNoList.get(j))) {
|
|
|
+ throw new ServiceException("已选择更高级的渠道,不支持渠道相互嵌套!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TicketBoxChannel> ticketBoxChannelList = new ArrayList<>();
|
|
|
+ for (Long channelId : channelIdList) {
|
|
|
+ TicketBoxChannel ticketBoxChannel = new TicketBoxChannel();
|
|
|
+ ticketBoxChannel.setBoxId(ticketBox.getBoxId());
|
|
|
+ ticketBoxChannel.setChannelId(channelId);
|
|
|
+ ticketBoxChannelList.add(ticketBoxChannel);
|
|
|
+ }
|
|
|
+ ticketBoxChannelService.saveBatch(ticketBoxChannelList);
|
|
|
+ }
|
|
|
+
|
|
|
// 校验更新奖品信息
|
|
|
if (CollectionUtils.isEmpty(param.getAwardsList())) {
|
|
|
throw new ServiceException("奖品列表不能为空");
|
|
@@ -196,7 +240,7 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public String createTicketBox(TicketBoxCreateParam param) {
|
|
|
// 创建盲票组
|
|
|
TicketBox ticketBox = mapperFacade.map(param, TicketBox.class);
|
|
@@ -204,8 +248,42 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
|
|
|
ticketBox.setStatus(TicketBoxStatusEnum.WAIT);
|
|
|
ticketBox.setBoxNo(ticketBoxSerialService.generateSerial(ticketBox.getType()));
|
|
|
ticketBox.setBoxId(bizIdGenerator.newId());
|
|
|
+ ticketBox.setSaleChannelType(param.getSaleChannelType());
|
|
|
save(ticketBox);
|
|
|
|
|
|
+ // 指定渠道
|
|
|
+ if (TicketBoxSaleChannelTypeEnum.PART.getValue().equals(param.getSaleChannelType())) {
|
|
|
+ List<Long> channelIdList = param.getChannelIdList();
|
|
|
+ if (CollectionUtils.isEmpty(channelIdList)) {
|
|
|
+ throw new ServiceException("渠道列表为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验嵌套问题
|
|
|
+ List<String> channelNoList = channelService.list(new LambdaQueryWrapper<Channel>()
|
|
|
+ .in(Channel::getChannelId, channelIdList))
|
|
|
+ .stream().map(Channel::getChannelNo)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (int i = 0; i < channelNoList.size(); i++) {
|
|
|
+ for (int j = 0; j < channelNoList.size(); j++) {
|
|
|
+ if (i == j) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (channelNoList.get(i).contains(channelNoList.get(j))) {
|
|
|
+ throw new ServiceException("已选择更高级的渠道,不支持渠道相互嵌套!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TicketBoxChannel> ticketBoxChannelList = new ArrayList<>();
|
|
|
+ for (Long channelId : channelIdList) {
|
|
|
+ TicketBoxChannel ticketBoxChannel = new TicketBoxChannel();
|
|
|
+ ticketBoxChannel.setBoxId(ticketBox.getBoxId());
|
|
|
+ ticketBoxChannel.setChannelId(channelId);
|
|
|
+ ticketBoxChannelList.add(ticketBoxChannel);
|
|
|
+ }
|
|
|
+ ticketBoxChannelService.saveBatch(ticketBoxChannelList);
|
|
|
+ }
|
|
|
+
|
|
|
// 创建奖级
|
|
|
List<TicketAwards> ticketAwardsList = new ArrayList<>();
|
|
|
List<TicketAwardsPrize> awardsPrizeList = new ArrayList<>();
|