Browse Source

盲票创建编辑关联商品

cup 2 years ago
parent
commit
2b1078d9a0

+ 5 - 1
mp-service/src/main/java/com/qs/mp/admin/domain/param/TicketBoxCreateParam.java

@@ -1,5 +1,6 @@
 package com.qs.mp.admin.domain.param;
 
+import com.qs.mp.admin.domain.TicketBoxGoods;
 import com.qs.mp.common.enums.TicketTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -62,5 +63,8 @@ public class TicketBoxCreateParam {
 
 	@NotEmpty(message = "奖级列表不能为空")
 	@ApiModelProperty(value = "奖级列表",required=true)
-	List<TicketAwardsParam> awardsList;
+	private List<TicketAwardsParam> awardsList;
+
+	@ApiModelProperty("关联商品列表")
+	private List<TicketBoxGoods> goodsList;
 }

+ 5 - 1
mp-service/src/main/java/com/qs/mp/admin/domain/param/TicketBoxUpdateParam.java

@@ -1,5 +1,6 @@
 package com.qs.mp.admin.domain.param;
 
+import com.qs.mp.admin.domain.TicketBoxGoods;
 import com.qs.mp.common.enums.TicketTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -51,5 +52,8 @@ public class TicketBoxUpdateParam {
     private BigDecimal saleCommRate;
 
     @ApiModelProperty(value = "奖级列表")
-    List<TicketAwardsParam> awardsList;
+    private List<TicketAwardsParam> awardsList;
+
+    @ApiModelProperty("关联商品列表")
+    private List<TicketBoxGoods> goodsList;
 }

+ 4 - 0
mp-service/src/main/java/com/qs/mp/admin/domain/vo/TicketBoxVO.java

@@ -2,6 +2,7 @@ package com.qs.mp.admin.domain.vo;
 
 import com.qs.mp.admin.domain.TicketBox;
 
+import com.qs.mp.admin.domain.TicketBoxGoods;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.List;
@@ -37,6 +38,9 @@ public class TicketBoxVO extends TicketBox {
   @ApiModelProperty("奖级列表(后台显示)")
   List<TicketAwardsVO> awardsList;
 
+  @ApiModelProperty("关联商品列表")
+  private List<TicketBoxGoods> goodsList;
+
   @ApiModelProperty("经销商分佣百分比")
   private BigDecimal channelCommRate;
 

+ 22 - 1
mp-service/src/main/java/com/qs/mp/admin/service/impl/TicketBoxServiceImpl.java

@@ -94,6 +94,9 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
   @Autowired
   private IAsyncTaskService asyncTaskService;
 
+  @Autowired
+  private ITicketBoxGoodsService ticketBoxGoodsService;
+
 
   @Override
   public List<TicketBox> listBySaleChannel(QueryWrapper<TicketBox> queryWrapper) {
@@ -125,8 +128,20 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
     ticketBox.setSaleChannelType(param.getSaleChannelType());
     this.updateById(ticketBox);
 
+
+    // 清除盲票关联商品
+    Assert.isTrue(ticketBoxGoodsService.remove(
+        new LambdaUpdateWrapper<TicketBoxGoods>().eq(TicketBoxGoods::getBoxId, ticketBox.getBoxId())), "清除盲票关联商品失败");
+
+    // 关联商品
+    if (CollectionUtils.isNotEmpty(param.getGoodsList())) {
+      ticketBoxGoodsService.saveBatch(param.getGoodsList());
+    }
+
+
     // 清除指定渠道内容
-    ticketBoxChannelService.remove(new LambdaUpdateWrapper<TicketBoxChannel>().eq(TicketBoxChannel::getBoxId, ticketBox.getBoxId()));
+    Assert.isTrue(ticketBoxChannelService.remove(
+        new LambdaUpdateWrapper<TicketBoxChannel>().eq(TicketBoxChannel::getBoxId, ticketBox.getBoxId())), "清除清除指定渠道内容失败");
 
     // 指定渠道
     if (TicketBoxSaleChannelTypeEnum.PART.getValue().equals(param.getSaleChannelType())) {
@@ -322,6 +337,12 @@ public class TicketBoxServiceImpl extends ServiceImpl<TicketBoxMapper, TicketBox
     ticketBox.setSaleChannelType(param.getSaleChannelType());
     save(ticketBox);
 
+
+    // 关联商品
+    if (CollectionUtils.isNotEmpty(param.getGoodsList())) {
+      ticketBoxGoodsService.saveBatch(param.getGoodsList());
+    }
+
     // 指定渠道
     if (TicketBoxSaleChannelTypeEnum.PART.getValue().equals(param.getSaleChannelType())) {
       List<Long> channelIdList = param.getChannelIdList();