From 69c65dda53f5fa7007130e6a7339666b5b5ef52a Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 18 九月 2023 13:39:06 +0800
Subject: [PATCH] 休bug

---
 server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java |   56 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java
index 8a62b1f..726f894 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java
@@ -21,6 +21,7 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -168,12 +169,15 @@
         wrapper.lambda()
                 .eq(BaseGoods::getId,baseGoods.getId())
                 .set(BaseGoods::getName,baseGoods.getName())
-                .set(BaseGoods::getName,baseGoods.getName())
-                .set(BaseGoods::getName,baseGoods.getName())
-                .set(BaseGoods::getName,baseGoods.getName());
+                .set(BaseGoods::getBrandId,baseGoods.getBrandId())
+                .set(BaseGoods::getCategoryId,baseGoods.getCategoryId())
+                .set(BaseGoods::getImgurl,baseGoods.getImgurl())
+                .set(BaseGoods::getPrice,baseGoods.getPrice())
+                .set(BaseGoods::getZdPrice,baseGoods.getZdPrice());
         baseGoodsMapper.update(null,wrapper);
 
-        multifileMapper.delete(new QueryWrapper<Multifile>().eq("OBJ_ID",baseGoods.getId()));
+        multifileMapper.delete(new QueryWrapper<Multifile>().eq("OBJ_ID",baseGoods.getId())
+                                                            .eq("OBJ_TYPE",Constants.ONE));
         List<Multifile> multifileList = baseGoods.getMultifileList();
         if(!Objects.isNull(multifileList)&&multifileList.size()>Constants.ZERO){
             for (int i = 0; i < multifileList.size(); i++) {
@@ -217,13 +221,13 @@
         if (CollectionUtils.isEmpty(idList)){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鍟嗗搧鐘舵�佷笉鑳戒负绌�");
         }
-        idList.forEach(s->updateStatusByIds(s,status));
+        idList.forEach(s->updateStatusById(s,status));
 
     }
 
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
     @Override
-    public void updateStatusByIds(Integer id, Integer status) {
+    public void updateStatusById(Integer id, Integer status) {
 
         if (Objects.isNull(status)){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鍟嗗搧鐘舵�佷笉鑳戒负绌�");
@@ -277,7 +281,8 @@
                 .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getBaseDataId)
                 .selectAll(BaseGoods.class)
                 .selectAs(Brand::getName,BaseGoodsDTO::getBrandName)
-                .selectAs(BaseCategory::getSortnum,BaseGoodsDTO::getCategoryName);
+                .selectAs(BaseCategory::getSortnum,BaseGoodsDTO::getCategoryName)
+                .eq(BaseGoods::getId,id);
 
         BaseGoodsDTO baseGoodsDTO = baseGoodsJoinMapper.selectJoinOne(BaseGoodsDTO.class, queryWrapper);
         String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
@@ -317,31 +322,30 @@
 
     @Override
     public PageData<BaseGoods> findPage(PageWrap<BaseGoods> pageWrap) {
+        pageWrap.getModel().setIsdeleted(Constants.ZERO);
         IPage<BaseGoods> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
         MPJLambdaWrapper<BaseGoods> queryWrapper = new MPJLambdaWrapper<>();
         Utils.MP.blankToNull(pageWrap.getModel());
-
-        if (pageWrap.getModel().getId() != null) {
-            queryWrapper.like(BaseGoods::getId, pageWrap.getModel().getId());
-        }
-        if (pageWrap.getModel().getName() != null) {
-            queryWrapper.eq(BaseGoods::getName, pageWrap.getModel().getName());
-        }
-        if (pageWrap.getModel().getStatus() != null) {
-            queryWrapper.eq(BaseGoods::getStatus, pageWrap.getModel().getStatus());
-        }
-        if (pageWrap.getModel().getCategoryId() != null) {
-            queryWrapper.eq(BaseGoods::getCategoryId, pageWrap.getModel().getCategoryId());
-        }
-        if (pageWrap.getModel().getBrandId() != null) {
-            queryWrapper.eq(BaseGoods::getBrandId, pageWrap.getModel().getBrandId());
-        }
         queryWrapper.leftJoin(Brand.class,Brand::getId,BaseGoods::getBrandId)
-                    .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getBaseDataId)
+                    .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId)
+                    .selectAll(BaseGoods.class)
                     .selectAs(Brand::getName,BaseGoods::getBrandName)
-                    .selectAs(BaseCategory::getSortnum,BaseGoods::getCategoryName);
+                    .selectAs(BaseCategory::getName,BaseGoods::getCategoryName)
+                    .eq(BaseGoods::getIsdeleted, Constants.ZERO)
+                    .like(StringUtils.isNotBlank(pageWrap.getModel().getName()), BaseGoods::getName,pageWrap.getModel().getName())
+                    .eq(pageWrap.getModel().getId()!=null,BaseGoods::getId, pageWrap.getModel().getId())
+                    .eq(pageWrap.getModel().getCategoryId()!=null,BaseGoods::getCategoryId, pageWrap.getModel().getCategoryId())
+                    .eq(pageWrap.getModel().getBrandId()!=null,BaseGoods::getBrandId, pageWrap.getModel().getBrandId())
+                    .eq(pageWrap.getModel().getStatus()!=null,BaseGoods::getStatus, pageWrap.getModel().getStatus());
+
         queryWrapper.orderByDesc(Goods::getId);
-        return PageData.from(baseGoodsJoinMapper.selectJoinPage(page,BaseGoods.class,queryWrapper));
+        PageData<BaseGoods> pageData =PageData.from(baseGoodsJoinMapper.selectJoinPage(page,BaseGoods.class,queryWrapper));
+        String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+                + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
+        pageData.getRecords().forEach(i->{
+            i.setFullImgUrl(prefixUrl + i.getImgurl());
+        });
+        return pageData;
     }
 
     @Override

--
Gitblit v1.9.3