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/GoodsServiceImpl.java |   91 ++++++++-------------------------------------
 1 files changed, 17 insertions(+), 74 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
index a049452..ad4b0c8 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -17,10 +17,8 @@
 import com.doumee.dao.business.*;
 import com.doumee.dao.business.join.GoodsJoinMapper;
 import com.doumee.dao.business.model.*;
-import com.doumee.dao.business.model.dto.BatchDisableDTO;
-import com.doumee.dao.business.model.dto.GoodCreatePlatRequest;
-import com.doumee.dao.business.model.dto.GoodsRequest;
-import com.doumee.dao.business.model.dto.PlatGoodsParam;
+import com.doumee.dao.business.model.dto.*;
+import com.doumee.service.business.BaseDataService;
 import com.doumee.service.business.GoodsService;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import org.apache.commons.lang3.StringUtils;
@@ -54,6 +52,9 @@
 
     @Autowired
     private GoodsMapper goodsMapper;
+    @Autowired
+    @Lazy
+    private BaseDataService baseDataService;
     @Autowired
     private BaseGoodsMapper baseGoodsMapper;
     @Autowired
@@ -721,6 +722,7 @@
             Goods g = new Goods();
             g.setIsdeleted(Constants.ZERO);
             g.setRemark(m.getId());
+            g.setCompanyId(user.getCompanyId());
             //鍝佺被鏁版嵁
             g = goodsMapper.selectOne(new QueryWrapper<>(g).last(" limit 1"));
             if(g != null){
@@ -729,6 +731,7 @@
             Category cate = new Category();
             cate.setIsdeleted(Constants.ZERO);
             cate.setName(m.getCategory());
+            cate.setCompanyId(user.getCompanyId());
             //鍝佺被鏁版嵁
             cate = categoryMapper.selectOne(new QueryWrapper<>(cate).last(" limit 1"));
             if(cate == null){
@@ -738,7 +741,9 @@
             brand.setIsdeleted(Constants.ZERO);
             brand.setName(m.getBrand());
             //鍝佺被鏁版嵁
-            brand = brandMapper.selectOne(new QueryWrapper<>(brand).last(" limit 1"));
+            QueryWrapper<Brand> qwrapper = new QueryWrapper<>(brand);
+            qwrapper.lambda().and(wapper-> wapper.eq(Brand::getCompanyId ,user.getCompanyId()).or().eq(Brand::getType,Constants.ONE));
+            brand = brandMapper.selectOne(qwrapper.last(" limit 1"));
             if(brand == null){
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣鍟嗗搧鍝佺墝鏃犳晥锛岃妫�鏌ヨ緭鍏ワ紒");
             }
@@ -751,6 +756,7 @@
             newModel.setBrandId(brand.getId());
             newModel.setIsdeleted(Constants.ZERO);
             newModel.setCreator(user.getId());
+            newModel.setCompanyId(user.getCompanyId());
             newModel.setCreateDate(new Date());
             newModel.setName(m.getName());
             newModel.setStatus(Constants.ZERO);
@@ -769,67 +775,14 @@
             newModel.setPinyin(PinYinUtil.getFullSpell(m.getName()));
             newModel.setShortPinyin(PinYinUtil.getFirstSpell(m.getName()));
 
-            CateAttr ca = new CateAttr();
-            ca.setCategoryId(cate.getId());
-            ca.setIsdeleted(Constants.ZERO);
-            //鏌ヨ鍏ㄩ儴灞炴��1鍜屽睘鎬�2瑙勬牸鍊�
-            List<CateAttr> allAttr = cateAttrMapper.selectList(new QueryWrapper<>(ca));
-            //灞炴��1闆嗗悎
-//            String[] attrs = StringUtils.defaultString(m.getAttrFirstNames(),"").split("\n");
-            //灞炴��2闆嗗悎
-//            String[] attrs2 = StringUtils.defaultString(m.getAttrSecodNames(),"").split("\n");
-            //浜у搧鍙傛暟闆嗗悎
             String[] params =  StringUtils.defaultString(m.getParamStr(),"").split("\n");
-//            if(attrs.length > 0){
-//                String attrids="" ,attrNames="";
-//                for(String s : attrs){
-//                    if(StringUtils.isBlank(s)){
-//                        continue;
-//                    }
-//                    //鏌ヨ灞炴�ц鏍煎璞�
-//                    CateAttr ta = getCateAttrByName(s,Constants.ZERO,allAttr);
-//                    if(ta == null){
-//                        throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒");
-//                    }
-//                    if(StringUtils.isNotBlank(attrids)){
-//                        attrids += ",";
-//                        attrNames += ",";
-//                    }
-//                    attrids+= ta.getId();
-//                    attrNames+= ta.getName();
-//                }
-//                newModel.setAttrFirstIds(attrids);
-//                newModel.setAttrFirstNames(attrNames);
-//            }
-//            if(attrs2.length > 0){
-//                String attrids="" ,attrNames="";
-//                for(String s : attrs2){
-//                    if(StringUtils.isBlank(s)){
-//                        continue;
-//                    }
-//                    //鏌ヨ灞炴�ц鏍煎璞�
-//                    CateAttr ta = getCateAttrByName(s,Constants.ONE,allAttr);
-//                    if(ta == null){
-//                        throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒");
-//                    }
-//                    if(StringUtils.isNotBlank(attrids)){
-//                        attrids += ",";
-//                        attrNames += ",";
-//                    }
-//                    attrids+= ta.getId();
-//                    attrNames+= ta.getName();
-//                }
-//                newModel.setAttrSecodIds(attrids);
-//                newModel.setAttrSecodNames(attrNames);
-//
-//            }
             List<String> mulFiles = null;
             String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode();
 
-            String tf = proDir.substring(0,proDir.length()-1);
             String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GOODS_IMG_DIR).getCode()
                     + proDir;
             if(StringUtils.isNotBlank(path)){
+                OssModel ossModel = baseDataService.initOssModel();
                 File dir =new File(path+File.separator+newModel.getRemark()+File.separator);
                 if(dir!=null && dir.isDirectory()){
                     File[]  files = dir.listFiles();
@@ -837,16 +790,8 @@
                         for(File f:files){
                             if(StringUtils.isBlank(newModel.getImgurl()) && isImgFile(f)){
                                 //鍙栫涓�寮犲浘鐗囦綔涓哄垪琛ㄥ浘
-                                String imgdir =f.getPath().substring(f.getPath().indexOf(tf)+tf.length()+1);
-                                newModel.setImgurl(imgdir.replace(File.separator,"/"));
-//                                 newModel.setImgurl(f.getPath().replace(path.replace(File.separator,"/"),""));
+                                newModel.setImgurl(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),f));
                             }
-//                             else{
-//                                 if(mulFiles==null){
-//                                     mulFiles = new ArrayList<>();
-//                                 }
-//                                 mulFiles.add(f.getPath().replace(path.replace("/",File.separator),""));
-//                             }
                             if((mulFiles ==null || mulFiles.size() == 0) && f.isDirectory()){
                                 //濡傛灉鏄枃浠跺す
                                 File[] fs = f.listFiles();
@@ -856,12 +801,7 @@
                                             if(mulFiles==null){
                                                 mulFiles = new ArrayList<>();
                                             }
-
-                                            String imgdir =mf.getPath().substring(mf.getPath().indexOf(tf)+tf.length()+1);
-                                            mulFiles.add(imgdir.replace(File.separator,"/"));
-//                                             newModel.setImgurl(imgdir);
-////                                             mulFiles.add(mf.getName());
-//                                             mulFiles.add(mf.getPath().replace(path.replace(File.separator,"/"),""));
+                                            mulFiles.add(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),f));
                                         }
                                     }
                                 }
@@ -942,6 +882,9 @@
 
     }
 
+
+
+
     private boolean isImgFile(File f) {
         if(f!=null && f.isFile() ){
             String name = f.getName();

--
Gitblit v1.9.3