| | |
| | | @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); |
| | | } |
| | |
| | | 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){ |
| | |
| | | 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(),"对不起,请正确选择平台商品!"); |
| | | } |
| | |
| | | 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())); |
| | |
| | | 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(); |
| | |
| | | //查询全部属性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(); |
| | | |
| | |
| | | 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){ |