pp
jiangping
2023-09-20 c166834a4aa5545a30115ea0195dab8dbab59fbd
server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -175,6 +175,8 @@
            //  如果选择平台商品和查询结果对不上,提示错误
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,请正确选择平台商品!");
        }
        List<Multifile> multifileList = new ArrayList<>();
        List<GoodsParam> goodsParamList = new ArrayList<>();
        for(BaseGoods model : goodsList){
            //遍历平台商品信息,进行商品信息同步
            Goods goods = initGoodsPlatParam(user,model,param);
@@ -183,16 +185,21 @@
            }
            goodsMapper.insert(goods);
           //开始处理附件
            dealPlatMultifule(goods.getId(),user,model);
            dealPlatMultifule(goods.getId(),user,model,multifileList);
            //开始处理参数配置
            dealPlatGoodsParam(model,goods,user);
            dealPlatGoodsParam(model,goods,user,goodsParamList);
        }
        if(multifileList.size()>0){
            multifileMapper.insertBatch(multifileList);
        }
        if(goodsParamList.size()>0){
            goodsParamMapper.insertBatch(goodsParamList);
        }
        return 1;
    }
    private void dealPlatGoodsParam(BaseGoods model, Goods goods, LoginUserInfo user) {
    private void dealPlatGoodsParam(BaseGoods model, Goods goods, LoginUserInfo user,List<GoodsParam> paramList) {
        BaseGoodsParam baseGoodsParam = new BaseGoodsParam();
        baseGoodsParam.setGoodsId(model.getId());
        baseGoodsParam.setIsdeleted(Constants.ZERO);
@@ -220,7 +227,8 @@
                goodsParam.setVal(bgParam.getVal());
                goodsParam.setName(bgParam.getName());
                goodsParam.setPramaId(Objects.isNull(cateParam)?null:cateParam.getId());
                goodsParamMapper.insert(goodsParam);
                paramList.add(goodsParam);
//                goodsParamMapper.insert(goodsParam);
            }
        }
    }
@@ -257,7 +265,7 @@
    /**
     *  开始处理平台商品关联附件,复制一套到企业商品上
     */
    private void dealPlatMultifule(Integer id, LoginUserInfo user, BaseGoods model) {
    private void dealPlatMultifule(Integer id, LoginUserInfo user, BaseGoods model,List<Multifile> fileList ) {
        Multifile f = new Multifile();
        f.setObjId(model.getId());
        f.setIsdeleted(Constants.ZERO);
@@ -276,7 +284,8 @@
                multifile.setName(multifile.getName());
                multifile.setSortnum(multifile.getSortnum());
                multifile.setCompanyId(user.getCompanyId());
                multifileMapper.insert(multifile);
                fileList.add(multifile);
//                multifileMapper.insert(multifile);
            }
        }
    }
@@ -547,7 +556,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++;
@@ -1063,6 +1072,8 @@
        String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
                + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
        goodsIPage.getRecords().forEach(i->{
            i.setCategoryImgurl(systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
                    + systemDictDataBiz.queryByCode(Constants.OSS, Constants.CATEGORY_IMG).getCode() + i.getCategoryImgurl());
            i.setPrefixUrl(prefixUrl);
            i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
            i.setGoodsParamList(goodsParamMapper.selectList(new QueryWrapper<GoodsParam>()