Quellcode durchsuchen

盲票创建编辑增加指定经销商

cup vor 3 Jahren
Ursprung
Commit
8fc6b1dd7d

+ 6 - 0
mp-service/src/main/java/com/qs/mp/admin/domain/param/TicketBoxCreateParam.java

@@ -25,6 +25,12 @@ public class TicketBoxCreateParam {
 	@ApiModelProperty(value = "图片",required=true)
 	private String picUrl;
 
+	@ApiModelProperty("销售渠道类型  1 所有渠道 2 指定渠道")
+	private Integer saleChannelType;
+
+	@ApiModelProperty("渠道商id列表")
+	private List<Long> channelIdList;
+
 	@NotNull(message = "面值不能为空")
 	@ApiModelProperty(value = "面值",required=true)
 	private Integer facePrice;

+ 6 - 0
mp-service/src/main/java/com/qs/mp/admin/domain/param/TicketBoxUpdateParam.java

@@ -32,6 +32,12 @@ public class TicketBoxUpdateParam {
     @ApiModelProperty(value = "售价",required=true)
     private Integer salePrice;
 
+    @ApiModelProperty("销售渠道类型  1 所有渠道 2 指定渠道")
+    private Integer saleChannelType;
+
+    @ApiModelProperty("渠道商id列表")
+    private List<Long> channelIdList;
+
     @ApiModelProperty(value = "盲票包采购单价,线下票时必传")
     private Integer pkgSalePrice;
 

+ 42 - 8
mp-service/src/main/java/com/qs/mp/admin/service/impl/TicketBoxServiceImpl.java

@@ -13,13 +13,7 @@ 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.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 +87,9 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
   @Autowired
   private ICouponPkgService couponPkgService;
 
+  @Autowired
+  private ITicketBoxChannelService ticketBoxChannelService;
+
   @Override
   @Transactional(rollbackFor = Exception.class)
   public boolean updateTicketBox(TicketBoxUpdateParam param) {
@@ -107,8 +104,28 @@ 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<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 +213,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 +221,25 @@ 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<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<>();