jiaosong
2023-09-20 d7e6b515aa68e9d17d8cec9dd3e93d77bc9b2b6e
server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -207,9 +207,9 @@
                        .eq("ISDELETED",Constants.ZERO)
                        .eq("STATUS",Constants.ZERO)
                        .last(" limit 1 "));
                if(Objects.isNull(cateParam)){
                    throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"企业分类数据同步异常请联系管理员");
                }
//                if(Objects.isNull(cateParam)){
//                    throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"企业分类数据同步异常请联系管理员");
//                }
                GoodsParam goodsParam = new GoodsParam();
                goodsParam.setCreator(user.getId());
                goodsParam.setCreateDate(new Date());
@@ -219,24 +219,8 @@
                goodsParam.setGoodsId(goods.getId());
                goodsParam.setVal(bgParam.getVal());
                goodsParam.setName(bgParam.getName());
                goodsParam.setPramaId(cateParam.getId());
                goodsParam.setPramaId(Objects.isNull(cateParam)?null:cateParam.getId());
                goodsParamMapper.insert(goodsParam);
                //存储 cate_param_select 查询是否已存在
//                if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
//                        .eq("PARAM_ID",goodsParam.getPramaId()).eq("NAME",goodsParam.getName()))<=Constants.ZERO){
//                    CateParamSelect cateParamSelect = new CateParamSelect();
//                    cateParamSelect.setCreator(user.getId());
//                    cateParamSelect.setCreateDate(new Date());
//                    cateParamSelect.setName(goodsParam.getVal());
//                    cateParamSelect.setIsdeleted(Constants.ZERO);
//                    cateParamSelect.setStatus(Constants.ZERO);
//                    cateParamSelect.setParamId(goodsParam.getPramaId());
//                    cateParamSelect.setCategoryId(goods.getCategoryId());
//                    cateParamSelect.setStatus(Constants.ZERO);
//                    cateParamSelectMapper.insert(cateParamSelect);
//                };
            }
        }
    }
@@ -245,6 +229,7 @@
        Goods goods = new Goods();
        goods.setIsdeleted(Constants.ZERO);
        goods.setGoodsId(model.getId());
        goods.setCompanyId(user.getCompanyId());
        if(goodsMapper.selectCount(new QueryWrapper<>(goods))>0){
            //如果已经同步过,跳过此次同步
            return  null;
@@ -300,16 +285,16 @@
        if(Constants.equalsInteger(Constants.ONE, param.getType())){
            for(PlatGoodsParam p: param.getGoodsParamList()){
                if(Constants.equalsInteger(model.getId(),p.getGoodsId())){
                    return p.getPrice();
                    return p.getPrice().setScale(0,BigDecimal.ROUND_CEILING);
                }
            }
        }
        //如果没有配置入手价,安装加价系数来计算
        if(model.getCateRatePrice()==null){
            model.setCateRatePrice(systemDictDataBiz.getGoodsPriceRate());
        }
        //返回
        return Constants.formatBigdecimal(model.getPrice()).multiply(model.getCateRatePrice()).multiply(param.getRate());
//        if(model.getCateRatePrice()==null){
//            model.setCateRatePrice(systemDictDataBiz.getGoodsPriceRate());
//        }
        //返回 .multiply(model.getCateRatePrice())
        return (Constants.formatBigdecimal(model.getPrice()).multiply(param.getRate())).setScale(0,BigDecimal.ROUND_CEILING);
    }
@@ -345,6 +330,7 @@
                multifile.setObjId(goods.getId());
                multifile.setType(Constants.ZERO);
                multifile.setObjType(Constants.ZERO);
                multifile.setCompanyId(goods.getCompanyId());
                multifileMapper.insert(multifile);
            }
        }
@@ -359,20 +345,6 @@
                goodsParam.setSortnum(i+Constants.ONE);
                goodsParam.setGoodsId(goods.getId());
                goodsParamMapper.insert(goodsParam);
                //存储 cate_param_select 查询是否已存在
//                if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
//                        .eq("PARAM_ID",goodsParam.getPramaId()).eq("NAME",goodsParam.getName()))<=Constants.ZERO){
//                    CateParamSelect cateParamSelect = new CateParamSelect();
//                    cateParamSelect.setCreator(user.getId());
//                    cateParamSelect.setCreateDate(new Date());
//                    cateParamSelect.setName(goodsParam.getVal());
//                    cateParamSelect.setIsdeleted(Constants.ZERO);
//                    cateParamSelect.setStatus(Constants.ZERO);
//                    cateParamSelect.setParamId(goodsParam.getPramaId());
//                    cateParamSelect.setCategoryId(goods.getCategoryId());
//                    cateParamSelect.setStatus(Constants.ZERO);
//                    cateParamSelectMapper.insert(cateParamSelect);
//                };
            }
        }
        return goods.getId();
@@ -457,7 +429,8 @@
        }else{
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前登录用户类别错误,无法进行该操作");
        }
        if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("COMPANY_ID",user.getCompanyId()).eq("ISDELETED",Constants.ZERO).ne("id",goods.getId()).eq("name",goods.getName()))>0){
        if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("COMPANY_ID",user.getCompanyId())
                .eq("ISDELETED",Constants.ZERO).ne("id",goods.getId()).eq("name",goods.getName()))>0){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+goods.getName()+"】已存在");
        };
        goods.setStatus(Constants.ZERO);
@@ -481,6 +454,7 @@
                multifile.setSortnum(i+Constants.ONE);
                multifile.setObjId(goods.getId());
                multifile.setType(Constants.ZERO);
                multifile.setCompanyId(goods.getCompanyId());
                multifile.setObjType(Constants.ZERO);
                multifileMapper.insert(multifile);
            }
@@ -535,7 +509,7 @@
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        //拉式商品 且 上架时,需要限制 平台商品是否已下架
        if(dbGoods.getType().equals(Constants.goodsType.PULL)&&goods.getStatus().equals(Constants.ZERO)){
        if(dbGoods.getType().equals(Constants.goodsType.PULL.getValue())&&goods.getStatus().equals(Constants.ZERO)){
            BaseGoods baseGoods = baseGoodsMapper.selectById(dbGoods.getGoodsId());
            if(Objects.isNull(baseGoods)){
                throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到平台商品信息");
@@ -573,7 +547,7 @@
                continue;
            }
            //拉式商品 且 上架时,需要限制 平台商品是否已下架
            if(dbGoods.getType().equals(Constants.goodsType.PULL)&&batchDisableDTO.getStatus().equals(Constants.ZERO)){
            if(dbGoods.getType().equals(Constants.goodsType.PULL.getValue())&&batchDisableDTO.getStatus().equals(Constants.ZERO)){
                BaseGoods baseGoods = baseGoodsMapper.selectById(dbGoods.getGoodsId());
                if(Objects.isNull(baseGoods)||!baseGoods.getStatus().equals(Constants.ZERO)){
                    errNum++;
@@ -1091,7 +1065,9 @@
        goodsIPage.getRecords().forEach(i->{
            i.setPrefixUrl(prefixUrl);
            i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
            i.setGoodsParamList(goodsParamMapper.selectList(new QueryWrapper<GoodsParam>().eq("GOODS_ID",i.getId()).orderByAsc(" SORTNUM ")));
            i.setGoodsParamList(goodsParamMapper.selectList(new QueryWrapper<GoodsParam>()
                    .eq("GOODS_ID",i.getId())
                    .orderByAsc(" SORTNUM ")));
        });
        return PageData.from(goodsIPage);
    }
@@ -1133,7 +1109,10 @@
        goodsList.forEach(i->{
            i.setPrefixUrl(prefixUrl);
            i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
            i.setGoodsParamList(goodsParamMapper.selectList(new QueryWrapper<GoodsParam>().eq("GOODS_ID",i.getId()).orderByAsc(" SORTNUM ")));
            i.setGoodsParamList(goodsParamMapper.selectList(
                    new QueryWrapper<GoodsParam>().eq("GOODS_ID",i.getId())
                            .apply(" name in ( select cp.NAME from cate_param cp where cp.CATEGORY_ID = "+i.getCategoryId()+" and cp.ISSHOW = 1 and cp.ISDELETED = 0 and cp.STATUS = 0 ) ")
                            .orderByAsc(" SORTNUM ")));
        });
        return goodsList;
    }