From c3f2f93821ac8d351fe7c9d1f0f28c39b36cfef1 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 01 Mar 2023 18:01:06 +0800
Subject: [PATCH] 增加活动公告

---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java |   55 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java
index e80afe0..cc9f184 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java
@@ -7,17 +7,13 @@
 import cc.mrbird.febs.mall.conversion.MallMemberConversion;
 import cc.mrbird.febs.mall.dto.ApiMallGoodsCommentDto;
 import cc.mrbird.febs.mall.dto.MallGoodsQueryDto;
-import cc.mrbird.febs.mall.entity.DataDictionaryCustom;
-import cc.mrbird.febs.mall.entity.MallGoods;
-import cc.mrbird.febs.mall.entity.MallGoodsComment;
-import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper;
-import cc.mrbird.febs.mall.mapper.MallGoodsCommentMapper;
-import cc.mrbird.febs.mall.mapper.MallGoodsImagesMapper;
-import cc.mrbird.febs.mall.mapper.MallGoodsMapper;
+import cc.mrbird.febs.mall.entity.*;
+import cc.mrbird.febs.mall.mapper.*;
 import cc.mrbird.febs.mall.service.IApiMallGoodsService;
 import cc.mrbird.febs.mall.vo.*;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -45,6 +41,8 @@
     private final MallGoodsImagesMapper goodsImagesMapper;
     private final MallGoodsCommentMapper mallGoodsCommentMapper;
     private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
+    private final MallCarriageRuleMapper mallCarriageRuleMapper;
+    private final MallCarriageRuleInfoMapper mallCarriageRuleInfoMapper;
 
 
     @Override
@@ -59,6 +57,33 @@
     }
 
     @Override
+    public ApiMallCarriageRuleVo findMallCarriageRuleById(Long id) {
+        ApiMallCarriageRuleVo apiMallCarriageRuleVo = new ApiMallCarriageRuleVo();
+
+        MallCarriageRule mallCarriageRule = mallCarriageRuleMapper.selectById(id);
+        if(ObjectUtil.isEmpty(mallCarriageRule)){
+            throw new FebsException("商品不存在");
+        }
+        apiMallCarriageRuleVo.setName(mallCarriageRule.getName());
+
+        List<MallCarriageRuleInfo> mallCarriageRuleInfos = mallCarriageRuleInfoMapper.selectMallCarriageRuleInfoByRuleIdAndAreaAddress(id, null);
+        if(CollUtil.isNotEmpty(mallCarriageRuleInfos)){
+            List<ApiMallCarriageRuleInfoVo> apiMallCarriageRuleInfoVos = new ArrayList<>();
+            for(MallCarriageRuleInfo mallCarriageRuleInfo : mallCarriageRuleInfos){
+                ApiMallCarriageRuleInfoVo apiMallCarriageRuleInfoVo = new ApiMallCarriageRuleInfoVo();
+                apiMallCarriageRuleInfoVo.setAreaAddress(mallCarriageRuleInfo.getAreaAddress());
+                apiMallCarriageRuleInfoVo.setBasicPrice(mallCarriageRuleInfo.getBasicPrice());
+                apiMallCarriageRuleInfoVo.setBasicCnt(mallCarriageRuleInfo.getBasicCnt());
+                apiMallCarriageRuleInfoVo.setMoreCnt(mallCarriageRuleInfo.getMoreCnt());
+                apiMallCarriageRuleInfoVo.setMorePrice(mallCarriageRuleInfo.getMorePrice());
+                apiMallCarriageRuleInfoVos.add(apiMallCarriageRuleInfoVo);
+            }
+            apiMallCarriageRuleVo.setApiMallCarriageRuleInfoVos(apiMallCarriageRuleInfoVos);
+        }
+        return apiMallCarriageRuleVo;
+    }
+
+    @Override
     public MallGoodsDetailsVo findMallGoodsDetailsById(Long id) {
         MallGoods mallGoods = this.baseMapper.selectGoodsDetailById(id);
         if (mallGoods == null) {
@@ -67,6 +92,22 @@
         List<String> images = goodsImagesMapper.selectGoodsImagesByGoodsId(mallGoods.getId());
         MallGoodsDetailsVo mallGoodsDetailsVo = MallGoodsConversion.INSTANCE.entityToDetailsVo(mallGoods);
 
+        List<GoodsDetailsStyleVo> styles = mallGoodsDetailsVo.getStyles();
+        if(ObjectUtil.isNotEmpty(styles)){
+            for(GoodsDetailsStyleVo goodsDetailsStyleVo : styles){
+                List<GoodsDetailsSkuVo> skus = goodsDetailsStyleVo.getSkus();
+                if(CollUtil.isNotEmpty(skus) ){
+                    for(GoodsDetailsSkuVo goodsDetailsSkuVo : skus){
+                        if(StrUtil.isNotEmpty(goodsDetailsSkuVo.getSample())){
+                            goodsDetailsSkuVo.setSampleFlag(true);
+                        }else{
+                            goodsDetailsSkuVo.setSampleFlag(false);
+                        }
+                    }
+                }
+            }
+        }
+
         if (CollUtil.isNotEmpty(mallGoods.getStyles())) {
             Map<String, BigDecimal> stockAndVolume = this.baseMapper.selectGoodsStockAndVolume(id);
             mallGoodsDetailsVo.setStock(stockAndVolume.get("stock").intValue());

--
Gitblit v1.9.1