From 74d80f67e70666dbd38b1f0b5e4c0c7772fa5b8c Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 18 九月 2023 15:03:50 +0800
Subject: [PATCH] 休bug

---
 server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java |   77 ++++++++++++++++++++++----------------
 1 files changed, 45 insertions(+), 32 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..b6e046d 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++) {
@@ -213,29 +217,36 @@
 
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
     @Override
-    public void updateStatusByIds(List<Integer> idList, Integer status) {
-        if (CollectionUtils.isEmpty(idList)){
-            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鍟嗗搧鐘舵�佷笉鑳戒负绌�");
+    public void updateStatusByIds(BaseGoods param) {
+        if (CollectionUtils.isEmpty(param.getIdList())
+                || param.getStatus() == null
+               || !(Constants.equalsInteger(param.getStatus(), Constants.ONE)||Constants.equalsInteger(param.getStatus()  ,Constants.ZERO))){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
-        idList.forEach(s->updateStatusByIds(s,status));
-
+        param.getIdList().forEach(s->updateStatusById(s,param.getStatus()));
     }
 
     @Transactional(rollbackFor = {Exception.class,BusinessException.class})
     @Override
-    public void updateStatusByIds(Integer id, Integer status) {
-
+    public void updateStatusById(Integer id, Integer status) {
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         if (Objects.isNull(status)){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"鍟嗗搧鐘舵�佷笉鑳戒负绌�");
         }
         if (Constants.equalsInteger(status,Constants.ZERO)){
+            //濡傛灉鍚敤
             BaseGoods baseGoods = new BaseGoods();
             baseGoods.setId(id);
+            baseGoods.setEditDate(new Date());
+            baseGoods.setEditor(user.getId());
             baseGoods.setStatus(status);
             baseGoodsMapper.updateById(baseGoods);
         }else if (Constants.equalsInteger(status,Constants.ONE)){
+            //濡傛灉绂佺敤
             BaseGoods baseGoods = new BaseGoods();
             baseGoods.setId(id);
+            baseGoods.setEditDate(new Date());
+            baseGoods.setEditor(user.getId());
             baseGoods.setStatus(status);
             baseGoodsMapper.updateById(baseGoods);
 
@@ -243,7 +254,9 @@
             goodsUpdate.lambda()
                         .eq(Goods::getType,Constants.ONE)
                         .eq(Goods::getGoodsId,id)
-                        .set(Goods::getStatus,Constants.ONE);
+                        .set(Goods::getStatus,Constants.ONE)
+                        .set(Goods::getEditor,user.getId())
+                        .set(Goods::getEditDate,new Date());
             goodsMapper.update(null,goodsUpdate);
         }
     }
@@ -277,7 +290,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 +331,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