From dcdb0231034810232f2542f3865666ebf72daf11 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 30 四月 2025 16:45:34 +0800
Subject: [PATCH] sf

---
 server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java |   95 +++++++++++++++++++++++++++++++----------------
 1 files changed, 62 insertions(+), 33 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 60ffc27..e45e5e6 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
@@ -85,7 +85,7 @@
 //            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+baseGoods.getName()+"銆戝凡瀛樺湪");
 //        }
 
-        Integer integer = baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO));
+        Long integer = baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO));
         BaseGoods insert = new BaseGoods();
         insert.setCreator(user.getId());
         insert.setCreateDate(new Date());
@@ -150,7 +150,12 @@
 
     @Override
     public void deleteById(Integer id) {
-        baseGoodsMapper.deleteById(id);
+        BaseGoods model = new BaseGoods();
+        model.setId(id);
+        model.setEditDate(new Date());
+        model.setIsdeleted(Constants.ONE);
+        updateById(model);
+//        baseGoodsMapper.deleteById(id);
     }
 
     @Override
@@ -164,7 +169,10 @@
         if (CollectionUtils.isEmpty(ids)) {
             return;
         }
-        baseGoodsMapper.deleteBatchIds(ids);
+        for(Integer id : ids){
+            deleteById(id);
+        }
+//        baseGoodsMapper.deleteBatchIds(ids);
     }
 
 
@@ -301,16 +309,16 @@
         MPJLambdaWrapper<BaseGoods> queryWrapper = new MPJLambdaWrapper<>();
 
         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,BaseGoodsDTO::getBrandName)
-                .selectAs(BaseCategory::getSortnum,BaseGoodsDTO::getCategoryName)
+                .selectAs(BaseCategory::getName,BaseGoodsDTO::getCategoryName)
                 .eq(BaseGoods::getId,id);
 
         BaseGoodsDTO baseGoodsDTO = baseGoodsJoinMapper.selectJoinOne(BaseGoodsDTO.class, queryWrapper);
         String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
                 + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
-        baseGoodsDTO.setImgfullurl(prefixUrl+baseGoodsDTO.getImgurl());
+        baseGoodsDTO.setImgfullurl(StringUtils.isNotBlank(baseGoodsDTO.getImgurl()) ? prefixUrl+baseGoodsDTO.getImgurl() : null);
 
         List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>()
                 .eq("OBJ_ID", id)
@@ -351,8 +359,11 @@
         Utils.MP.blankToNull(pageWrap.getModel());
         queryWrapper.leftJoin(Brand.class,Brand::getId,BaseGoods::getBrandId)
                     .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId)
+//                    .leftJoin(BaseData.class,BaseData::getId,BaseGoods::getBaseDataId)
                     .selectAll(BaseGoods.class)
+                    .selectAs(BaseCategory::getPriceRate,BaseGoods::getCateRatePrice)
                     .selectAs(Brand::getName,BaseGoods::getBrandName)
+//                    .selectAs(BaseData::getPrice,BaseGoods::getJdPrice)
                     .selectAs(BaseCategory::getName,BaseGoods::getCategoryName)
                     .eq(BaseGoods::getIsdeleted, Constants.ZERO)
                     .like(StringUtils.isNotBlank(pageWrap.getModel().getName()), BaseGoods::getName,pageWrap.getModel().getName())
@@ -366,7 +377,11 @@
         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());
+             if(StringUtils.isNotBlank(i.getImgurl())){
+                 i.setFullImgUrl(prefixUrl + i.getImgurl());
+             }
+             i.setJdPrice(i.getPrice());
+             i.setPrice(Constants.formatBigdecimal(i.getPrice()).multiply(Constants.formatBigdecimal(i.getCateRatePrice())));
         });
         return pageData;
     }
@@ -383,6 +398,7 @@
                 .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId)
                 .selectAll(BaseGoods.class)
                 .selectAs(Brand::getName,BaseGoods::getBrandName)
+                .selectAs(BaseCategory::getPriceRate,BaseGoods::getCateRatePrice)
                 .selectAs(BaseCategory::getName,BaseGoods::getCategoryName)
                 .eq(BaseGoods::getStatus, Constants.ZERO)
                 .eq(BaseGoods::getIsdeleted, Constants.ZERO)
@@ -391,13 +407,15 @@
                 .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())
-                .notExists(user.getType().equals(Constants.UserType.COMPANY.getKey())," select 1 from goods g where g.GOODS_ID = t.id and g.TYPE = 1  and  g.company_id = "+user.getCompanyId()+"  ");
+                .notExists(user.getType().equals(Constants.UserType.COMPANY.getKey())," select 1 from goods g where g.GOODS_ID = t.id and g.TYPE = 1 and g.ISDELETED = 0  and  g.company_id = "+user.getCompanyId()+"  ");
         queryWrapper.orderByDesc(Goods::getId);
         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());
+            //鍔犱环绯绘暟
+            i.setPrice(Constants.formatBigdecimal(i.getPrice()).multiply(Constants.formatBigdecimal(i.getCateRatePrice())));
         });
         return pageData;
     }
@@ -421,9 +439,10 @@
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝褰曞叆鏁版嵁涓虹┖锛�");
             }
             //澶勭悊鎵归噺涓婁紶
-            String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLATFORM).getCode();
+            String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode();
+            String platformDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLATFORM).getCode();
             String basePath = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GOODS_IMG_DIR).getCode()
-                    + proDir + File.separator ;
+                    + proDir + platformDir ;
             OssModel ossModel = baseDataService.initOssModel();
             for (int index = 0; index < dataList.size(); index++) {
                 BaseGoodsImportDTO  s = dataList.get(index);
@@ -507,13 +526,15 @@
 //                baseGoods.setImgurl();
                 baseGoods.setCategoryId(baseCategory.getId());
                 baseGoods.setBrandId(brand.getId());
+                baseGoods.setPinyin(PinYinUtil.getFullSpell(s.getName()));
+                baseGoods.setShortPinyin(PinYinUtil.getFirstSpell(s.getName()));
                 baseGoodsMapper.insert(baseGoods);
 
                 if(mulFiles !=null && mulFiles.size()>0){
                     for(int i=0;i<mulFiles.size();i++){
                         String str = mulFiles.get(i);
                         Multifile f = new Multifile();
-                        f.setObjType(Constants.ZERO);
+                        f.setObjType(Constants.ONE);
                         f.setName(str);
                         f.setType(Constants.ZERO);
                         f.setObjId(baseGoods.getId());
@@ -529,30 +550,38 @@
 
                 String baseGoodsParamString = s.getBaseGoodsParamString();
                 List<List<String>> collect = Arrays.asList(baseGoodsParamString.split("\n"))
-                        .stream().map(s1 -> Arrays.asList(s1.split("[锛�,:]")) ).collect(Collectors.toList());
-                if (!CollectionUtils.isEmpty(collect)) {
-                    for (int i = 0; i < collect.size(); i++) {
-                        if (!CollectionUtils.isEmpty(baseCategory.getBaseCateParamList())) {
-                            List<String> s2 = collect.get(i);
-                            BaseCateParam baseCateParam = baseCategory.getBaseCateParamList()
-                                    .stream().filter(s3 -> s3.getName().equals(s2.get(0))).findFirst()
-                                    .orElseThrow(() -> new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "閰嶇疆鍙傛暟銆愩�戜笉瀛樺湪"));
-                            BaseGoodsParam baseGoodsParam = new BaseGoodsParam();
-                            baseGoodsParam.setCreator(user.getId());
-                            baseGoodsParam.setCreateDate(new Date());
-                            baseGoodsParam.setEditor(user.getId());
-                            baseGoodsParam.setEditDate(new Date());
-                            baseGoodsParam.setIsdeleted(Constants.ZERO);
-                            baseGoodsParam.setName(baseCateParam.getName());
-                            baseGoodsParam.setRemark(baseCateParam.getRemark());
-                            baseGoodsParam.setStatus(Constants.ZERO);
-                            baseGoodsParam.setSortnum(i + Constants.ONE);
-                            baseGoodsParam.setPramaId(baseCateParam.getId());
-                            baseGoodsParam.setVal(s2.size() > 1 ? s2.get(1) : null);
-                            baseGoodsParam.setGoodsId(baseGoods.getId());
-                            baseGoodsParamMapper.insert(baseGoodsParam);
+                        .stream()
+                        .map(s1 -> Arrays.asList(s1.split("[锛�,:]")) )
+                        .filter(s1->!CollectionUtils.isEmpty(s1))
+                        .collect(Collectors.toList());
 
+                if (!CollectionUtils.isEmpty(baseCategory.getBaseCateParamList())) {
+                    for (int i = 0; i < baseCategory.getBaseCateParamList().size(); i++) {
+
+                        BaseCateParam baseCateParam = baseCategory.getBaseCateParamList().get(i);
+
+                        BaseGoodsParam baseGoodsParam = new BaseGoodsParam();
+                        baseGoodsParam.setCreator(user.getId());
+                        baseGoodsParam.setCreateDate(new Date());
+                        baseGoodsParam.setEditor(user.getId());
+                        baseGoodsParam.setEditDate(new Date());
+                        baseGoodsParam.setIsdeleted(Constants.ZERO);
+                        baseGoodsParam.setName(baseCateParam.getName());
+                        baseGoodsParam.setRemark(baseCateParam.getRemark());
+                        baseGoodsParam.setStatus(Constants.ZERO);
+                        baseGoodsParam.setSortnum(i + Constants.ONE);
+                        baseGoodsParam.setPramaId(baseCateParam.getId());
+                        baseGoodsParam.setGoodsId(baseGoods.getId());
+
+                        if (!CollectionUtils.isEmpty(collect)) {
+                            List<String> list = collect.stream()
+                                    .filter(s3 -> s3.get(0).equals(baseCateParam.getName()))
+                                    .findFirst()
+                                    .orElse(new ArrayList<>());
+                            baseGoodsParam.setVal(list.size() > 1 ? list.get(1) : null);
                         }
+
+                        baseGoodsParamMapper.insert(baseGoodsParam);
                     }
                     ;
                 }

--
Gitblit v1.9.3