Browse Source

管乐迷商城改造

zouxuan 1 year ago
parent
commit
d27c71fa17

+ 0 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ComplementGoodsDto.java

@@ -11,6 +11,4 @@ public class ComplementGoodsDto {
         private Integer goodsId;
 
         private BigDecimal organCostPrice;
-
-        private String skuCode;
 }

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Goods.java

@@ -115,8 +115,8 @@ public class Goods {
 	private String complementGoodsIdList;
 
 	/** 发布时间 */
-	@ApiModelProperty(value = "附件商品详情",required = false)
-	private String complementGoodsJson;
+//	@ApiModelProperty(value = "附件商品详情",required = false)
+//	private String complementGoodsJson;
 
 	/** 辅件列表 */
 	@ApiModelProperty(value = "辅件列表(子商品)",required = false)

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/mapper/GoodsSubMapper.java

@@ -1,11 +1,13 @@
 package com.ym.mec.biz.dal.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ym.mec.biz.dal.dto.ComplementGoodsDto;
 import com.ym.mec.biz.dal.entity.GoodsSub;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 组合商品,子商品信息
@@ -18,4 +20,6 @@ public interface GoodsSubMapper extends BaseMapper<GoodsSub> {
     void saveBatch(@Param("goodsSubs") List<GoodsSub> goodsSubs);
 
     void updateStatus(@Param("goodsSubIdList") List<Integer> goodsSubIdList, @Param("status") Boolean status);
+
+    List<ComplementGoodsDto> queryChildGoods(@Param("goodsId") Integer goodsId);
 }

+ 0 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderGoodsServiceImpl.java

@@ -57,14 +57,6 @@ public class MusicGroupPaymentCalenderGoodsServiceImpl extends ServiceImpl<Music
             List<Integer> goodsIds = goodsList.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
             List<Goods> goodies = goodsDao.getGoodies(goodsIds);
             Map<Integer,Goods> goodsMap = goodies.stream().collect(Collectors.toMap(Goods::getId, e -> e));
-            for (MusicGroupPaymentCalenderGoods e : goodsList) {
-                Goods goods = goodsMap.get(e.getGoodsId());
-                e.setGoodsSn(goods.getSn());
-                e.setTotalPrice(goods.getGroupPurchasePrice().multiply(new BigDecimal(e.getNum())));
-                e.setSinglePrice(goods.getGroupPurchasePrice());
-                e.setCalenderId(musicGroupPaymentBaseCalender.getCalenderId());
-                e.setChildGoodsJson(goods.getComplementGoodsJson());
-            }
             //计算原价
             return goodsList.stream().map(e -> {
                 Goods goods = goodsMap.get(e.getGoodsId());

+ 21 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -142,6 +142,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     private MallFeignService mallFeignService;
     @Autowired
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
+    @Autowired
+    private GoodsSubService goodsSubService;
+    @Autowired
+    private GoodsDao goodsDao;
 
     @Override
     public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -446,9 +450,24 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         //保存商品缴费信息
         if (musicGroupPaymentCalender.getPaymentType() == GOODS_PURCHASE) {
             if(CollectionUtils.isNotEmpty(musicGroupPaymentBaseCalender.getCalenderGoodsList())){
+                List<Integer> goodsIds = musicGroupPaymentBaseCalender.getCalenderGoodsList().stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+                Map<Integer, Goods> goodsMap = goodsDao.getGoodies(goodsIds).stream().collect(Collectors.toMap(Goods::getId, e -> e));
+                for (MusicGroupPaymentCalenderGoods e : musicGroupPaymentBaseCalender.getCalenderGoodsList()) {
+                    Goods goods = goodsMap.get(e.getGoodsId());
+                    e.setGoodsSn(goods.getSn());
+                    e.setTotalPrice(goods.getGroupPurchasePrice().multiply(new BigDecimal(e.getNum())));
+                    e.setSinglePrice(goods.getGroupPurchasePrice());
+                    e.setCalenderId(calenderId);
+                    List<ComplementGoodsDto> childGoods = goodsSubService.getBaseMapper().queryChildGoods(e.getGoodsId());
+                    if(CollectionUtils.isEmpty(childGoods)){
+                        throw new BizException("商品{}没有子商品",goods.getName());
+                    }
+                    e.setChildGoodsJson(JSON.toJSONString(childGoods));
+                }
                 musicGroupPaymentCalenderGoodsService.saveBatch(musicGroupPaymentBaseCalender.getCalenderGoodsList());
             }
             if(musicGroupPaymentBaseCalender.getCalenderAddress() != null){
+                musicGroupPaymentBaseCalender.getCalenderAddress().setCalenderId(calenderId);
                 musicGroupPaymentCalenderAddressService.save(musicGroupPaymentBaseCalender.getCalenderAddress());
             }
         }
@@ -953,7 +972,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);
             MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
 
-            if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.FEE_AUDIT) {
+            if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.FEE_AUDIT && calender.getPaymentType() != GOODS_PURCHASE) {
                 throw new BizException("当前乐团状态不支持此操作");
             }
             
@@ -1172,7 +1191,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
             MusicGroupPaymentCalender calender = musicGroupPaymentCalenders.get(0);
 
 			MusicGroup musicGroup = musicGroupDao.get(calender.getMusicGroupId());
-            if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.FEE_AUDIT) {
+            if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS && musicGroup.getStatus() != MusicGroupStatusEnum.FEE_AUDIT && calender.getPaymentType() != GOODS_PURCHASE){
                 throw new BizException("当前乐团状态不支持此操作");
             }
             //如果是报名,并且所有的报名都审核通过,需要修改乐团状态

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/GoodsSubMapper.xml

@@ -16,4 +16,7 @@
             #{item}
         </foreach>
     </update>
+    <select id="queryChildGoods" resultType="com.ym.mec.biz.dal.dto.ComplementGoodsDto">
+        select sku_ skuStockId,goods_id_ goodsId,goods_price_ organCostPrice from goods_sub where goods_id_ = 1
+    </select>
 </mapper>