From 80fd41ea0dc602ac3ca33778f17fce5bc2e817b1 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 16 一月 2026 18:58:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java |   58 ++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
index 5cf1b0e..2d8af53 100644
--- a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
+++ b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -89,6 +89,8 @@
 
     @Autowired
     private SystemDictDataBiz systemDictDataBiz;
+    @Autowired
+    private ShopMapper shopMapper;
 
     @Autowired
     private GoodsSkuAttrJoinMapper goodsSkuAttrJoinMapper;
@@ -156,7 +158,7 @@
         goodsSku.setGoodsId(goods.getId());
         goodsSku.setName(goods.getName());
         goodsSku.setPrice(goods.getSkuPrice());
-        goodsSku.setShowPrice(goods.getPrice());
+        goodsSku.setShowPrice(goods.getShowPrice());
         goodsSku.setStock(goods.getStockNum());
         goodsSku.setIntegralRate(goods.getDeductRata());
         goodsSku.setUnitName(goods.getUnitName());
@@ -211,13 +213,19 @@
                     || goods.getBrandList() == null
                     || goods.getBrandList().size() == 0
                     || goods.getWeight() == null
+                    || goods.getDeductRata() == null
                     || goods.getPrice() == null
                     || goods.getSkuPrice() == null
-                    || StringUtils.isBlank(goods.getImgurl())
-                    || org.apache.commons.collections.CollectionUtils.isEmpty(goods.getFileList())) {
+//                    || StringUtils.isBlank(goods.getImgurl())
+//                    || org.apache.commons.collections.CollectionUtils.isEmpty(goods.getFileList())
+            ) {
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage());
             }
 
+            if(goods.getDeductRata().compareTo(new BigDecimal(0.1)) <Constants.ZERO ||
+                    goods.getDeductRata().compareTo(new BigDecimal(100)) >Constants.ZERO){
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝绉垎鍙姷鎵i噾棰濇瘮渚嬭璁剧疆[0.1,100]涔嬮棿~");
+            }
             //鏌ヨ鍒嗙被
             Labels cate = labelsMapper.selectById(goods.getCategoryId());
             if(cate == null || Constants.equalsInteger(cate.getIsdeleted(),Constants.ONE)
@@ -225,7 +233,7 @@
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鍒嗙被淇℃伅涓嶅瓨鍦�");
             }
             if(goods.getBrandId()!=null){
-                Labels brand = labelsMapper.selectById(goods.getCategoryId());
+                Labels brand = labelsMapper.selectById(goods.getBrandId());
                 if(brand == null || Constants.equalsInteger(brand.getIsdeleted(),Constants.ONE)
                         ||! Constants.equalsInteger(brand.getType(),Constants.LabelsType.GOODSBRAND.getKey())){
                     throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鍝佺墝淇℃伅涓嶅瓨鍦�");
@@ -234,7 +242,7 @@
             List<Integer> bIds = new ArrayList<>();
             for(Labels b : goods.getBrandList()){
                 bIds.add(b.getId());
-                if(b.getChildIdList() == null || b.getChildIdList().size() ==0){
+                if(b.getChildIdList() != null && b.getChildIdList().size() >=0){
                     bIds.addAll(b.getChildIdList());
                 }
             }
@@ -251,9 +259,9 @@
                      throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇烽�夋嫨姝g‘鐨勯�傜敤鍝佺墝");
                  }
                  idsBrand.add("["+b.getId()+"]");
-                if(b.getChildIdList() == null || b.getChildIdList().size() ==0){
+                if(b.getChildIdList()!= null && b.getChildIdList().size() >=0){
                    for(Integer c :b.getChildIdList()){
-                       Labels cb = findLabelFromListByid(allBrands,b.getId(),Constants.LabelsType.SERIES_BRAND.getKey(),b.getId());
+                       Labels cb = findLabelFromListByid(allBrands,c,Constants.LabelsType.SERIES_BRAND.getKey(),b.getId());
                        if(cb == null){
                            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鍝佺墝銆�"+tb.getName() +"銆戜笅鎵�灞炵郴鍒椾笉姝g‘");
                        }
@@ -265,7 +273,6 @@
             if(idsSerial.size()>0){
                 goods.setSerialIds(String.join(",",idsSerial));
             }
-
     }
 
     private Labels findLabelFromListByid(List<Labels> allBrands, Integer id, int type,Integer parentId) {
@@ -274,13 +281,13 @@
         }
         for(Labels labels:allBrands){
             if(!Constants.equalsInteger(id,labels.getId())){
-                return null;
+               continue;
             }
             if(!Constants.equalsInteger(type,labels.getType())){
-                return null;
+              continue;
             }
             if(parentId !=null && !Constants.equalsInteger(parentId,labels.getParentId())){
-                return null;
+               continue;
             }
             return labels;
         }
@@ -364,11 +371,11 @@
         skuMapper.update(null,new UpdateWrapper<Sku>().lambda()
                 .set(Sku::getIsdeleted,Constants.ONE)
                 .eq(Sku::getIsdeleted,Constants.ZERO)
-                .eq(Sku::getGoodsId,goods.getSkuId()));
+                .eq(Sku::getGoodsId,goods.getId()));
         goodsSkuMapper.update(null,new UpdateWrapper<GoodsSku>().lambda()
                 .set(GoodsSku::getIsdeleted,Constants.ONE)
                 .eq(GoodsSku::getIsdeleted,Constants.ZERO)
-                .eq(GoodsSku::getGoodsId,goods.getSkuId()));
+                .eq(GoodsSku::getGoodsId,goods.getId()));
         dealDefaultGoodsSku(goods);//鏂板缓sku淇℃伅
         dealBatchMultiFiles(goods, goods.getFileList(), user,true);
     }
@@ -526,7 +533,8 @@
     @Override
     public Goods findById(Integer id) {
         MPJLambdaWrapper<Goods> queryWrapper = new MPJLambdaWrapper<>();
-        String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.ACTIVITY_FILE).getCode();
+        String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+                + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_FILE).getCode();
 
         queryWrapper.eq(Goods::getId,id);
         queryWrapper.selectAll(Goods.class);
@@ -554,6 +562,7 @@
             //榛樿sku淇℃伅
             GoodsSku goodsSku = goodsSkuList.get(0);
             goods.setSkuPrice(goodsSku.getPrice());
+            goods.setShowPrice(goodsSku.getShowPrice());
             goods.setWeight(goodsSku.getWeight());
             goods.setStockNum(goodsSku.getStock());
             goods.setUnitName(goodsSku.getUnitName());
@@ -592,6 +601,7 @@
                     }
                 }
             }
+            goods.setBrandList(brandList);
         }
     }
 
@@ -703,6 +713,9 @@
     @Override
     public List<Goods> findList(Goods goods) {
         QueryWrapper<Goods> wrapper = new QueryWrapper<>(goods);
+        wrapper.lambda()
+            .in(goods.getIdList() != null && goods.getIdList().size()>0, Goods::getId, goods.getIdList())
+            .eq( Goods::getIsdeleted, Constants.ZERO);
         return goodsMapper.selectList(wrapper);
     }
 
@@ -711,9 +724,7 @@
         IPage<Goods> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
         MPJLambdaWrapper<Goods> queryWrapper = new MPJLambdaWrapper<>();
         Utils.MP.blankToNull(pageWrap.getModel());
-
         queryWrapper.selectAll(Goods.class);
-
         queryWrapper.select("t1.name",Goods::getCategoryName);
         queryWrapper.select("t2.name" ,Goods::getBrandName);
         queryWrapper.select("t3.name" ,Goods::getParentName);
@@ -721,7 +732,8 @@
         queryWrapper.leftJoin(Labels.class,Labels::getId,Goods::getBrandId);
         queryWrapper.leftJoin(Labels.class,Labels::getId,Goods::getParentCategoryId);
         //搴撳瓨閲�
-         queryWrapper.select("(select sum(STOCK) from goods_sku where ISDELETED=0 and GOODS_ID=t.id) as stockNum ");
+        queryWrapper.select("(select sum(STOCK) from goods_sku where ISDELETED=0 and GOODS_ID=t.id) as stockNum ");
+        queryWrapper.select("(select count(id) from shop_goods_relation s where s.ISDELETED=0 and s.GOODS_ID=t.id) as pricedShopNum ");
         //瀹為檯閿�閲�
         queryWrapper.select("(select sum(gd.GOODS_NUM) from  goodsorder_detail gd" +
                 "        inner join  goods_sku gs on gs.id=gd.GOODS_SKU_ID" +
@@ -743,8 +755,8 @@
         queryWrapper.eq(pageWrap.getModel().getParentCategoryId() != null, Goods::getParentCategoryId, pageWrap.getModel().getParentCategoryId());
         queryWrapper.eq(pageWrap.getModel().getBrandId() != null, Goods::getBrandId, pageWrap.getModel().getBrandId());
         queryWrapper.eq(pageWrap.getModel().getStatus() != null, Goods::getStatus, pageWrap.getModel().getStatus());
-
-        queryWrapper.orderByDesc(Goods::getCreateDate);
+        queryWrapper.in(pageWrap.getModel().getIdList() != null && pageWrap.getModel().getIdList().size()>0, Goods::getId, pageWrap.getModel().getIdList());
+        queryWrapper.orderByDesc(Goods::getId);
         IPage<Goods> result = goodsAdminJoinMapper.selectJoinPage(page, Goods.class, queryWrapper);
         initResult(result.getRecords());
         return PageData.from(result);
@@ -773,8 +785,12 @@
         if (list == null || list.size() == 0) {
             return;
         }
-        String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_FILE).getCode();
+       long shopNum = shopMapper.selectCount(new QueryWrapper<Shop>().lambda()
+                .eq(Shop::getIsdeleted,Constants.ZERO));
+        String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+                + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_FILE).getCode();
         for (Goods goods : list) {
+            goods.setShopNum(shopNum);
             goods.setResourcePath(path);
             //鏌ヨsku
             MPJLambdaWrapper<GoodsSku> queryWrapper = new MPJLambdaWrapper<GoodsSku>()
@@ -788,9 +804,11 @@
                 //榛樿sku淇℃伅
                 goods.setSkuPrice(goodsSku.getPrice());
                 goods.setWeight(goodsSku.getWeight());
+                goods.setShowPrice(goodsSku.getShowPrice());
                 goods.setStockNum(goodsSku.getStock());
                 goods.setUnitName(goodsSku.getUnitName());
             }
+//            initGoodsApplyBrandAndSerial(goods);
         }
     }
 

--
Gitblit v1.9.3