From 64f45c75ea93911b9841bf00bb4c436cd294be3a Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期五, 15 九月 2023 18:30:47 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 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 4e04375..a049452 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
@@ -130,7 +130,7 @@
     @Override
     public  Integer createPlat(GoodCreatePlatRequest param){
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
-        if(Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){
+        if(!Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){
             //闈炰紒涓氱敤鎴蜂笉鑳芥搷浣�
             throw new BusinessException(ResponseStatus.NOT_ALLOWED);
         }
@@ -143,7 +143,7 @@
             throw  new BusinessException(ResponseStatus.BAD_REQUEST);
         }
         Category category = categoryMapper.selectById(param.getCategoryId());
-        if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){
+        if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||!Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){
             throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绫诲埆淇℃伅涓嶆纭紝璇峰埛鏂伴噸璇曪紒");
         }
         if(category.getPlatCateId() == null){
@@ -160,11 +160,14 @@
                 if(p.getGoodsId() == null || p.getPrice() == null){
                     throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇锋纭�夋嫨骞冲彴鍟嗗搧骞堕厤缃叆鎵嬩环锛�");
                 }
+                if(ids == null){
+                    ids = new ArrayList<>();
+                }
                 ids.add(p.getGoodsId());
             }
         }
         goodsList = baseGoodsMapper.selectList(new QueryWrapper<>(bp).lambda().in((ids!=null && ids.size()>0),BaseGoods::getId,ids));
-        if(Constants.equalsInteger(Constants.ONE, param.getType()) || goodsList==null || ids.size()!=goodsList.size()){
+        if(Constants.equalsInteger(Constants.ONE, param.getType()) &&( goodsList==null || ids.size()!=goodsList.size())){
             //  濡傛灉閫夋嫨骞冲彴鍟嗗搧鍜屾煡璇㈢粨鏋滃涓嶄笂锛屾彁绀洪敊璇�
             throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇锋纭�夋嫨骞冲彴鍟嗗搧锛�");
         }
@@ -219,6 +222,7 @@
         goods.setStatus(Constants.ZERO);
         goods.setCreateDate(new Date());
         goods.setCreator(user.getId());
+        goods.setCompanyId(user.getCompanyId());
         goods.setIsdeleted(Constants.ZERO);
         //澶勭悊鎷奸煶闂
         goods.setPinyin(PinYinUtil.getFullSpell(goods.getName()));
@@ -559,8 +563,8 @@
     @Override
     public Goods findById(Integer id) {
         Goods goods = goodsMapper.selectById(id);
-        String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
-                + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+        String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+                + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
         goods.setPrefixUrl(prefixUrl);
         Brand brand = brandMapper.selectById(goods.getBrandId());
         if(!Objects.isNull(brand)){
@@ -603,8 +607,8 @@
                 Goods::getPrice,goods.getSPrice(),goods.getEPrice());
         queryWrapper.orderByDesc(Goods::getId);
         List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper);
-        String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
-                + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+        String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+                + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
         goodsList.forEach(i->{
             i.setPrefixUrl(prefixUrl);
             i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
@@ -621,11 +625,16 @@
         queryWrapper.selectAll(Goods.class);
 
         queryWrapper.selectAs(Category::getName, Goods::getCategoryName);
+        queryWrapper.selectAs(BaseGoods::getZdPrice, Goods::getBaseZdPrice);
+        queryWrapper.selectAs(BaseGoods::getPrice, Goods::getBasePrice);
         queryWrapper.selectAs(Brand::getName, Goods::getBrandName);
         queryWrapper.selectAs(Category::getAttrFirst, Goods::getAttrFirst);
         queryWrapper.selectAs(Category::getAttrSecond, Goods::getAttrSecond);
+        queryWrapper.selectAs(BaseCategory::getPriceRate,Goods::getBasePriceRate);
         queryWrapper.leftJoin(Category.class, Category::getId, Goods::getCategoryId);
         queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId);
+        queryWrapper.leftJoin(BaseGoods.class,BaseGoods::getId,Goods::getGoodsId);
+        queryWrapper.leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId);
 
         queryWrapper.eq(Goods::getIsdeleted, Constants.ZERO);
         if (pageWrap.getModel().getId() != null) {
@@ -649,10 +658,14 @@
         }
         queryWrapper.orderByDesc(Goods::getId);
         IPage<Goods> goodsIPage =  goodsJoinMapper.selectJoinPage(page, Goods.class, queryWrapper);
-        String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
-                + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+        String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+                + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
         goodsIPage.getRecords().forEach(i->{
             i.setPrefixUrl(prefixUrl);
+            if(i.getType().equals(Constants.ONE)){
+                i.setBasePrice(i.getBasePrice().multiply(i.getBasePriceRate()));
+            }
+
         });
         return PageData.from(goodsIPage);
     }

--
Gitblit v1.9.3