jiangping
2023-09-15 04d88ef5d6e9f4814ad16f51f1550bd5be7c6fe6
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()));
@@ -227,7 +231,7 @@
        goods.setCategoryId(param.getCategoryId());
        //获取入手价格
        goods.setPrice(getPriceFromParam(model,param));
        goods.setZdPrice(model.getZdPrice());g
        goods.setZdPrice(model.getZdPrice());
        goods.setRemark(model.getRemark());
        goods.setImgurl(model.getImgurl());
        goods.setBrandId(model.getBrandId());
@@ -644,9 +648,10 @@
        if (pageWrap.getModel().getBrandId() != null) {
            queryWrapper.eq(Goods::getBrandId, pageWrap.getModel().getBrandId());
        }
        if (pageWrap.getModel().getCompanyId() != null) {
            queryWrapper.eq(Goods::getCompanyId, pageWrap.getModel().getCompanyId());
        }
        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();
@@ -761,54 +766,54 @@
            //查询全部属性1和属性2规格值
            List<CateAttr> allAttr = cateAttrMapper.selectList(new QueryWrapper<>(ca));
            //属性1集合
            String[] attrs = StringUtils.defaultString(m.getAttrFirstNames(),"").split("\n");
//            String[] attrs = StringUtils.defaultString(m.getAttrFirstNames(),"").split("\n");
            //属性2集合
            String[] attrs2 = StringUtils.defaultString(m.getAttrSecodNames(),"").split("\n");
//            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);
            }
//            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();
@@ -890,6 +895,20 @@
                    gp.setSortnum(ta.getSortnum());
                    //插入产品参数关联表
                    goodsParamMapper.insert(gp);
                    //存储 cate_param_select 查询是否已存在
                    if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
                            .eq("PARAM_ID",gp.getPramaId()).eq("NAME",gp.getName()))<=Constants.ZERO){
                        CateParamSelect cateParamSelect = new CateParamSelect();
                        cateParamSelect.setCreator(user.getId());
                        cateParamSelect.setCreateDate(new Date());
                        cateParamSelect.setName(gp.getVal());
                        cateParamSelect.setIsdeleted(Constants.ZERO);
                        cateParamSelect.setStatus(Constants.ZERO);
                        cateParamSelect.setParamId(gp.getPramaId());
                        cateParamSelect.setCategoryId(newModel.getCategoryId());
                        cateParamSelect.setStatus(Constants.ZERO);
                        cateParamSelectMapper.insert(cateParamSelect);
                    };
                }
            }
            if(mulFiles !=null && mulFiles.size()>0){