From ffb38bc2a78e67e56bfb5bf028a1567204ea59eb Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Thu, 30 May 2024 11:43:54 +0800
Subject: [PATCH] 图片上传

---
 src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java |  114 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 89 insertions(+), 25 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
index 6764092..ede410b 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
@@ -2,6 +2,7 @@
 
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.entity.QueryRequest;
+import cc.mrbird.febs.common.utils.AppContants;
 import cc.mrbird.febs.mall.conversion.MallGoodsConversion;
 import cc.mrbird.febs.mall.dto.*;
 import cc.mrbird.febs.mall.entity.*;
@@ -72,16 +73,18 @@
             return new FebsResponse().fail().message("商品编号不能重复");
         }
         Integer carriageType = addMallGoodsDto.getCarriageType();
-        if(1 == carriageType){
-            if(ObjectUtil.isEmpty(addMallGoodsDto.getCarriageAmount())
-                    || BigDecimal.ZERO.compareTo(addMallGoodsDto.getCarriageAmount()) > 0){
-                return new FebsResponse().fail().message("固定邮费不能小于零");
-            }
-        }else{
-            Long carriageRuleId = addMallGoodsDto.getCarriageRuleId();
-            MallCarriageRule mallCarriageRule = mallCarriageRuleMapper.selectById(carriageRuleId);
-            if(ObjectUtil.isEmpty(mallCarriageRule)){
-                return new FebsResponse().fail().message("邮费模板不能为空");
+        if (addMallGoodsDto.getGoodsType() == 1) {
+            if (1 == carriageType) {
+                if (ObjectUtil.isEmpty(addMallGoodsDto.getCarriageAmount())
+                        || BigDecimal.ZERO.compareTo(addMallGoodsDto.getCarriageAmount()) > 0) {
+                    return new FebsResponse().fail().message("固定邮费不能小于零");
+                }
+            } else {
+                Long carriageRuleId = addMallGoodsDto.getCarriageRuleId();
+                MallCarriageRule mallCarriageRule = mallCarriageRuleMapper.selectById(carriageRuleId);
+                if (ObjectUtil.isEmpty(mallCarriageRule)) {
+                    return new FebsResponse().fail().message("邮费模板不能为空");
+                }
             }
         }
 
@@ -123,11 +126,11 @@
                     if (StrUtil.isEmpty(presentPrice)) {
                         return new FebsResponse().fail().message("商品规格现价不能为空");
                     }
-                    if (StrUtil.isEmpty(addSku.getLevelOnePrice())
-                    || StrUtil.isEmpty(addSku.getLevelTwoPrice())
-                            || StrUtil.isEmpty(addSku.getLevelThreePrice())) {
-                        return new FebsResponse().fail().message("商品规格级别价格不能为空");
-                    }
+//                    if (StrUtil.isEmpty(addSku.getLevelOnePrice())
+//                    || StrUtil.isEmpty(addSku.getLevelTwoPrice())
+//                            || StrUtil.isEmpty(addSku.getLevelThreePrice())) {
+//                        return new FebsResponse().fail().message("商品规格级别价格不能为空");
+//                    }
                     BigDecimal goodsWeight = addSku.getGoodsWeight();
                     if(BigDecimal.ZERO.compareTo(goodsWeight) > 0){
                         return new FebsResponse().fail().message("重量不能小于零");
@@ -236,12 +239,12 @@
                 mallGoodsSku.setStock(addMallGoodsSkuDto.getStock() == null ? 0 : addMallGoodsSkuDto.getStock());
                 mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume() == null ? 0 : addMallGoodsSkuDto.getSkuVolume());
                 mallGoodsSku.setOriginalPrice(new BigDecimal(addMallGoodsSkuDto.getOriginalPrice()));
-//                mallGoodsSku.setPresentPrice(new BigDecimal(addMallGoodsSkuDto.getPresentPrice()));
-                mallGoodsSku.setPresentPrice(new BigDecimal(addMallGoodsSkuDto.getOriginalPrice()));
+                mallGoodsSku.setPresentPrice(new BigDecimal(addMallGoodsSkuDto.getPresentPrice()));
+//                mallGoodsSku.setPresentPrice(new BigDecimal(addMallGoodsSkuDto.getOriginalPrice()));
 
-                mallGoodsSku.setLevelOnePrice(new BigDecimal(addMallGoodsSkuDto.getLevelOnePrice()));
-                mallGoodsSku.setLevelTwoPrice(new BigDecimal(addMallGoodsSkuDto.getLevelTwoPrice()));
-                mallGoodsSku.setLevelThreePrice(new BigDecimal(addMallGoodsSkuDto.getLevelThreePrice()));
+//                mallGoodsSku.setLevelOnePrice(new BigDecimal(addMallGoodsSkuDto.getLevelOnePrice()));
+//                mallGoodsSku.setLevelTwoPrice(new BigDecimal(addMallGoodsSkuDto.getLevelTwoPrice()));
+//                mallGoodsSku.setLevelThreePrice(new BigDecimal(addMallGoodsSkuDto.getLevelThreePrice()));
                 mallGoodsSku.setStyleId(mallGoodsStyleSku.getId());
                 mallGoodsSku.setCostPrice(addMallGoodsSkuDto.getCostPrice());
                 mallGoodsSku.setGoodsId(mallGoods.getId());
@@ -551,8 +554,8 @@
                         mallGoodsSku.setStock(addMallGoodsSkuDto.getStock() == null ? 0 : addMallGoodsSkuDto.getStock());
                         mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume() == null ? 0 : addMallGoodsSkuDto.getSkuVolume());
                         mallGoodsSku.setOriginalPrice(addMallGoodsSkuDto.getOriginalPrice());
-//                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice());
-                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getOriginalPrice());
+                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice());
+//                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getOriginalPrice());
                         mallGoodsSku.setLevelOnePrice(addMallGoodsSkuDto.getLevelOnePrice());
                         mallGoodsSku.setLevelTwoPrice(addMallGoodsSkuDto.getLevelTwoPrice());
                         mallGoodsSku.setLevelThreePrice(addMallGoodsSkuDto.getLevelThreePrice());
@@ -571,8 +574,8 @@
                         mallGoodsSku.setStock(addMallGoodsSkuDto.getStock() == null ? 0 : addMallGoodsSkuDto.getStock());
                         mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume() == null ? 0 : addMallGoodsSkuDto.getSkuVolume());
                         mallGoodsSku.setOriginalPrice(addMallGoodsSkuDto.getOriginalPrice());
-//                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice());
-                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getOriginalPrice());
+                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice());
+//                        mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getOriginalPrice());
                         mallGoodsSku.setLevelOnePrice(addMallGoodsSkuDto.getLevelOnePrice());
                         mallGoodsSku.setLevelTwoPrice(addMallGoodsSkuDto.getLevelTwoPrice());
                         mallGoodsSku.setLevelThreePrice(addMallGoodsSkuDto.getLevelThreePrice());
@@ -863,8 +866,28 @@
         mallGoodsCoupon.setName(name);
         mallGoodsCoupon.setExpireDay(couponRuleAddDto.getExpireDay());
         mallGoodsCoupon.setCostAmount(couponRuleAddDto.getCostAmount());
+        mallGoodsCoupon.setType(couponRuleAddDto.getType());
         mallGoodsCoupon.setRealAmount(couponRuleAddDto.getRealAmount());
         mallGoodsCouponMapper.insert(mallGoodsCoupon);
+
+        Long couponId = mallGoodsCoupon.getId();
+        QueryWrapper<CouponGoods> objectQueryWrapperCoupon = new QueryWrapper<>();
+        objectQueryWrapperCoupon.eq("coupon_id",couponId);
+        List<CouponGoods> couponGoodsList = couponGoodsMapper.selectList(objectQueryWrapperCoupon);
+        if(CollUtil.isNotEmpty(couponGoodsList)){
+            for(CouponGoods couponGoods : couponGoodsList){
+                couponGoodsMapper.deleteById(couponGoods);
+            }
+        }
+        if(CollUtil.isNotEmpty(couponRuleAddDto.getGoodsIds())){
+            List<Long> goodsIds = couponRuleAddDto.getGoodsIds();
+            for(Long goodsId : goodsIds){
+                CouponGoods couponGoods = new CouponGoods();
+                couponGoods.setGoodsId(goodsId);
+                couponGoods.setCouponId(couponId);
+                couponGoodsMapper.insert(couponGoods);
+            }
+        }
         return new FebsResponse().success().message("操作成功");
     }
 
@@ -906,7 +929,10 @@
 
     @Override
     public AdminMallGoodsCouponVo selectGoodsCouponById(long id) {
-        return mallGoodsCouponMapper.selectGoodsCouponById(id);
+        List<Long> goodsIds = couponGoodsMapper.selectByCouponId(id);
+        AdminMallGoodsCouponVo adminMallGoodsCouponVo = mallGoodsCouponMapper.selectGoodsCouponById(id);
+        adminMallGoodsCouponVo.setGoodsIds(goodsIds);
+        return adminMallGoodsCouponVo;
     }
 
     @Override
@@ -923,8 +949,28 @@
         mallGoodsCoupon.setName(adminMallGoodsCouponVo.getName());
         mallGoodsCoupon.setExpireDay(adminMallGoodsCouponVo.getExpireDay());
         mallGoodsCoupon.setCostAmount(adminMallGoodsCouponVo.getCostAmount());
+        mallGoodsCoupon.setType(adminMallGoodsCouponVo.getType());
         mallGoodsCoupon.setRealAmount(adminMallGoodsCouponVo.getRealAmount());
         mallGoodsCouponMapper.updateById(mallGoodsCoupon);
+
+        Long couponId = mallGoodsCoupon.getId();
+        QueryWrapper<CouponGoods> objectQueryWrapperCoupon = new QueryWrapper<>();
+        objectQueryWrapperCoupon.eq("coupon_id",couponId);
+        List<CouponGoods> couponGoodsList = couponGoodsMapper.selectList(objectQueryWrapperCoupon);
+        if(CollUtil.isNotEmpty(couponGoodsList)){
+            for(CouponGoods couponGoods : couponGoodsList){
+                couponGoodsMapper.deleteById(couponGoods);
+            }
+        }
+        if(CollUtil.isNotEmpty(adminMallGoodsCouponVo.getGoodsIds())){
+            List<Long> goodsIds = adminMallGoodsCouponVo.getGoodsIds();
+            for(Long goodsId : goodsIds){
+                CouponGoods couponGoods = new CouponGoods();
+                couponGoods.setGoodsId(goodsId);
+                couponGoods.setCouponId(couponId);
+                couponGoodsMapper.insert(couponGoods);
+            }
+        }
         return new FebsResponse().success().message("操作成功");
     }
 
@@ -963,4 +1009,22 @@
         }
         return objects;
     }
+
+    @Override
+    public List<AdminMallGoodsCouponTreeListVo> findAdminMallGoodsVoTreeList() {
+        QueryWrapper<MallGoods> objectQueryWrapper = new QueryWrapper<>();
+        objectQueryWrapper.eq("is_sale",1);
+        List<MallGoods> mallGoodsList = mallGoodsMapper.selectList(objectQueryWrapper);
+
+        List<AdminMallGoodsCouponTreeListVo> objects = new ArrayList<>();
+        if(CollUtil.isNotEmpty(mallGoodsList)){
+            for(MallGoods mallGoods : mallGoodsList){
+                AdminMallGoodsCouponTreeListVo adminMallGoodsCouponTreeListVo = new AdminMallGoodsCouponTreeListVo();
+                adminMallGoodsCouponTreeListVo.setId(mallGoods.getId());
+                adminMallGoodsCouponTreeListVo.setName(mallGoods.getGoodsName());
+                objects.add(adminMallGoodsCouponTreeListVo);
+            }
+        }
+        return objects;
+    }
 }

--
Gitblit v1.9.1