| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.Charset; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | goods.setCreateDate(new Date()); |
| | | goods.setCreator(user.getId()); |
| | | goods.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); |
| | | goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName())); |
| | | this.validateSubCategory(goods); |
| | | goodsMapper.insert(goods); |
| | | |
| | | List<Multifile> multifileList = goods.getMultifileList(); |
| | |
| | | if(!Objects.isNull(goodsParamList)&&goodsParamList.size()>0){ |
| | | for (int i = 0; i < goodsParamList.size(); i++) { |
| | | GoodsParam goodsParam = goodsParamList.get(i); |
| | | goodsParam.setId(null); |
| | | goodsParam.setCreator(user.getId()); |
| | | goodsParam.setCreateDate(new Date()); |
| | | goodsParam.setIsdeleted(Constants.ZERO); |
| | |
| | | goods.setEditDate(new Date()); |
| | | goods.setEditor(user.getId()); |
| | | goods.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | goods.setPinyin(PinYinUtil.getFullSpell(goods.getName())); |
| | | goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName())); |
| | | this.validateSubCategory(goods); |
| | | goodsMapper.updateById(goods); |
| | | |
| | | multifileMapper.delete(new QueryWrapper<Multifile>().eq("OBJ_ID",goods.getId()) |
| | |
| | | if(!Objects.isNull(goodsParamList)&&goodsParamList.size()>0){ |
| | | for (int i = 0; i < goodsParamList.size(); i++) { |
| | | GoodsParam goodsParam = goodsParamList.get(i); |
| | | goodsParam.setId(null); |
| | | goodsParam.setCreator(user.getId()); |
| | | goodsParam.setCreateDate(new Date()); |
| | | goodsParam.setIsdeleted(Constants.ZERO); |
| | |
| | | queryWrapper.leftJoin(Category.class, Category::getId, Goods::getCategoryId); |
| | | queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId); |
| | | queryWrapper.eq(Goods::getStatus,Constants.ZERO); |
| | | queryWrapper.eq(Goods::getCompanyId, goods.getCompanyId()); |
| | | queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.like(StringUtils.isNotBlank(goods.getAttrFirstIds()),Goods::getAttrFirstIds,goods.getAttrFirstIds()); |
| | | queryWrapper.like(StringUtils.isNotBlank(goods.getAttrFirstNames()),Goods::getAttrFirstNames,goods.getAttrFirstNames()); |
| | |
| | | queryWrapper.between(!Objects.isNull(goods.getSPrice())&&!Objects.isNull(goods.getEPrice()), |
| | | Goods::getPrice,goods.getSPrice(),goods.getEPrice()); |
| | | queryWrapper.orderByDesc(Goods::getId); |
| | | List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper); |
| | | List<Goods> goodsList = this.goodsMapper.selectListByCollection(goods); |
| | | // List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper); |
| | | if(!Objects.isNull(goodsList)&&goodsList.size()>Constants.ZERO){ |
| | | this.dealGoodsMsg(goodsList); |
| | | } |
| | |
| | | @Override |
| | | public Integer importBatch(MultipartFile file){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | Boolean isGrouping = (Boolean)redisTemplate.opsForValue().get(user.getCompanyId()+Constants.COMPANY_IMPORT_GOODS); |
| | | if(isGrouping!=null && isGrouping ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前已存在产品导入操作,此次操作无效,请稍后重试!"); |
| | | } |
| | | redisTemplate.opsForValue().set(user.getCompanyId()+Constants.COMPANY_IMPORT_GOODS,true,30, TimeUnit.MINUTES); |
| | | int num =1,index =1; |
| | | try { |
| | | ExcelImporter ie = new ExcelImporter(file,0,0);; |
| | | List<GoodsImport> dataList =ie.getDataList(GoodsImport.class,null); |
| | | if(dataList == null || dataList.size() ==0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据为空!"); |
| | | } |
| | | String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode(); |
| | | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GOODS_IMG_DIR).getCode() + proDir + File.separator + user.getCompanyId(); |
| | | //品类数据 |
| | | List<Brand> brandList = brandMapper.selectList(new LambdaQueryWrapper<Brand>() .eq(Brand::getIsdeleted,Constants.ZERO) |
| | | .and(wapper-> wapper.eq(Brand::getCompanyId ,user.getCompanyId()).or().eq(Brand::getType,Constants.ONE))); |
| | | //企业产品数据 |
| | | List<Goods> goodsList = goodsMapper.selectList(new LambdaQueryWrapper<Goods>() .eq(Goods::getIsdeleted,Constants.ZERO) |
| | | .eq(Goods::getCompanyId,user.getCompanyId())); |
| | | //品类数据 |
| | | List<Category> categoryList = categoryMapper.selectList(new LambdaQueryWrapper<Category>() .eq(Category::getIsdeleted,Constants.ZERO) |
| | | .eq(Category::getCompanyId,user.getCompanyId())); |
| | | //查询全部产品参数配置 |
| | | List<CateParam> allParamsList = cateParamMapper.selectList(new LambdaQueryWrapper<CateParam>().eq(CateParam::getIsdeleted,Constants.ZERO)); |
| | | for(GoodsImport m: dataList){ |
| | | if(StringUtils.isBlank(m.getName()) |
| | | &&StringUtils.isBlank(m.getCategory()) |
| | | &&StringUtils.isBlank(m.getZdPrice()) |
| | | &&StringUtils.isBlank(m.getPrice()) |
| | | &&StringUtils.isBlank(m.getId()) |
| | | &&StringUtils.isBlank(m.getBrand())){ |
| | | // 全部空行,跳过处理; |
| | | num++; |
| | | continue; |
| | | } |
| | | if(StringUtils.isBlank(m.getName()) |
| | | ||StringUtils.isBlank(m.getCategory()) |
| | | ||StringUtils.isBlank(m.getZdPrice()) |
| | | ||StringUtils.isBlank(m.getPrice()) |
| | | ||StringUtils.isBlank(m.getId()) |
| | | ||StringUtils.isBlank(m.getBrand())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行数据无效,请检查输入!"); |
| | | } |
| | | Goods g = new Goods(); |
| | | g.setIsdeleted(Constants.ZERO); |
| | | g.setRemark(m.getId()); |
| | | g.setCompanyId(user.getCompanyId()); |
| | | //品类数据 |
| | | g = goodsMapper.selectOne(new QueryWrapper<>(g).last(" limit 1")); |
| | | if(g != null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品图片文件夹重复,请检查输入!"); |
| | | } |
| | | Category cate = getCategroyByNameFromList(m.getCategory(),categoryList); |
| | | if(cate == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品类别无效,请检查输入!"); |
| | | } |
| | | Brand brand = getImportBrandByNameFromList(m.getBrand(),brandList); |
| | | if(brand == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品品牌无效,请检查输入!"); |
| | | } |
| | | if(findGoodsByNameFromList(m.getName(),goodsList) !=null){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"第【"+(num)+"】行产品名称【"+m.getName()+"】已存在"); |
| | | } |
| | | Goods newModel = new Goods(); |
| | | newModel.setRemark(m.getId()); |
| | | newModel.setCategoryId(cate.getId()); |
| | | newModel.setBrandId(brand.getId()); |
| | | newModel.setIsdeleted(Constants.ZERO); |
| | | newModel.setCreator(user.getId()); |
| | | newModel.setCompanyId(user.getCompanyId()); |
| | | newModel.setCreateDate(new Date()); |
| | | newModel.setName(m.getName()); |
| | | newModel.setStatus(Constants.ZERO); |
| | | try { |
| | | newModel.setZdPrice(BigDecimal.valueOf(Double.parseDouble(m.getZdPrice()))); |
| | | newModel.setPrice(BigDecimal.valueOf(Double.parseDouble(m.getPrice()))); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | if(newModel.getZdPrice() == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行指导价无效,请检查输入!"); |
| | | } |
| | | if(newModel.getPrice() == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行入手价无效,请检查输入!"); |
| | | } |
| | | newModel.setPinyin(PinYinUtil.getFullSpell(m.getName())); |
| | | newModel.setShortPinyin(PinYinUtil.getFirstSpell(m.getName())); |
| | | List<String> mulFiles =getGoodsImageFileList(newModel,path); |
| | | //查询商品信息 |
| | | goodsMapper.insert(newModel); |
| | | //加入到已经存在的产品集合中,用于下一个信息去重处理 |
| | | goodsList.add(newModel); |
| | | //处理产品属性业务 |
| | | dealGoodsParamBiz(cate,newModel,m,allParamsList,num); |
| | | //处理产品图片资源业务 |
| | | dealGoodsImagesBiz(mulFiles,newModel); |
| | | |
| | | index++;//记录导入产品成功+1 |
| | | } |
| | | }catch (BusinessException e){ |
| | | throw e; |
| | | }catch (Exception e){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"导入产品数据发生异常,请稍后重试!"); |
| | | }finally { |
| | | redisTemplate.opsForValue().set(user.getCompanyId()+Constants.COMPANY_IMPORT_GOODS,false); |
| | | } |
| | | return index; |
| | | } |
| | | |
| | | private void dealGoodsImagesBiz(List<String> mulFiles, Goods newModel) { |
| | | if(mulFiles !=null && mulFiles.size()>0){ |
| | | List<Multifile> multifileList = new ArrayList<>(); |
| | | for(int i=0;i<mulFiles.size();i++){ |
| | | String s = mulFiles.get(i); |
| | | Multifile f = new Multifile(); |
| | | f.setObjType(Constants.ZERO); |
| | | f.setName(s); |
| | | f.setType(Constants.ZERO); |
| | | f.setObjId(newModel.getId()); |
| | | f.setCreateDate(newModel.getCreateDate()); |
| | | f.setCreator(newModel.getCreator()); |
| | | f.setIsdeleted(Constants.ZERO); |
| | | f.setSortnum(i); |
| | | f.setCompanyId(newModel.getCompanyId()); |
| | | f.setFileurl(s); |
| | | multifileList.add(f); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | } |
| | | } |
| | | |
| | | private List<String> getGoodsImageFileList(Goods newModel, String path) { |
| | | List<String> mulFiles = null; |
| | | if(StringUtils.isNotBlank(path)){ |
| | | OssModel ossModel = baseDataService.initOssModel(); |
| | | File dir =new File(path+File.separator+newModel.getRemark()+File.separator); |
| | | if(dir!=null && dir.isDirectory()){ |
| | | File[] files = dir.listFiles(); |
| | | if(files!=null && files.length>0){ |
| | | for(File f:files){ |
| | | if(StringUtils.isBlank(newModel.getImgurl()) && isImgFile(f)){ |
| | | //取第一张图片作为列表图 |
| | | newModel.setImgurl(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),f)); |
| | | } |
| | | if((mulFiles ==null || mulFiles.size() == 0) && f.isDirectory()){ |
| | | //如果是文件夹 |
| | | File[] fs = f.listFiles(); |
| | | if(fs!=null && fs.length>0){ |
| | | for(File mf : fs){ |
| | | if(isImgFile(mf)){ |
| | | if(mulFiles==null){ |
| | | mulFiles = new ArrayList<>(); |
| | | } |
| | | mulFiles.add(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),mf)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return mulFiles; |
| | | } |
| | | |
| | | private void dealGoodsParamBiz(Category cate, Goods newModel, GoodsImport m, List<CateParam> allParamsList,int num) { |
| | | List<GoodsParam> paramList = new ArrayList<>(); |
| | | String[] params = StringUtils.defaultString(m.getParamStr(),"").split("\n"); |
| | | //查询全部产品参数配置 |
| | | List<CateParam> allParams =getCateParamByCateid(cate.getId(),allParamsList); |
| | | if(params.length > 0){ |
| | | for(String s : params){ |
| | | if(StringUtils.isBlank(s)){ |
| | | continue; |
| | | } |
| | | s = s.replace(":",":"); |
| | | String[] ts = s.split(":"); |
| | | if(ts.length == 0){ |
| | | continue; |
| | | } |
| | | //查询属性规格对象 |
| | | CateParam ta = getCateParamByName(ts[0], allParams); |
| | | if(ta == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行产品参数中【"+s+"】无效,请检查输入!"); |
| | | } |
| | | GoodsParam gp = new GoodsParam(); |
| | | gp.setIsdeleted(Constants.ZERO); |
| | | gp.setCreator(newModel.getCreator()); |
| | | gp.setCreateDate(newModel.getCreateDate()); |
| | | gp.setGoodsId(newModel.getId()); |
| | | gp.setName(ta.getName()); |
| | | gp.setPramaId(ta.getId()); |
| | | gp.setStatus(Constants.ZERO); |
| | | gp.setVal(ts.length>1?ts[1]:null); |
| | | gp.setSortnum(ta.getSortnum()); |
| | | //插入产品参数关联表 |
| | | paramList.add(gp); |
| | | // goodsParamMapper.insert(gp); |
| | | } |
| | | } |
| | | if(paramList.size() >0){ |
| | | goodsParamMapper.insert(paramList); |
| | | } |
| | | |
| | | } |
| | | |
| | | private Goods findGoodsByNameFromList(String name, List<Goods> goodsList) { |
| | | if(goodsList!=null){ |
| | | for(Goods brand :goodsList){ |
| | | if(StringUtils.equals(name.trim(),brand.getName())){ |
| | | return brand; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private List<CateParam> getCateParamByCateid(Integer cateid, List<CateParam> allParamsList) { |
| | | List<CateParam> list = null; |
| | | |
| | | if(allParamsList!=null){ |
| | | for(CateParam brand :allParamsList){ |
| | | if(Constants.equalsInteger(cateid,brand.getCategoryId())){ |
| | | if(list == null){ |
| | | list = new ArrayList<>(); |
| | | } |
| | | list.add(brand); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | private Category getCategroyByNameFromList(String name, List<Category> categoryList) { |
| | | if(categoryList!=null){ |
| | | for(Category brand :categoryList){ |
| | | if(StringUtils.equals(name.trim(),brand.getName())){ |
| | | return brand; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private Brand getImportBrandByNameFromList(String name, List<Brand> brandList) { |
| | | if(brandList!=null){ |
| | | for(Brand brand :brandList){ |
| | | if(StringUtils.equals(name.trim(),brand.getName())){ |
| | | return brand; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = {Exception.class, BusinessException.class}) |
| | | @Override |
| | | public Integer importBatchImg(MultipartFile file){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | ExcelImporter ie = null; |
| | | List<GoodsImport> dataList =null; |
| | | try { |
| | |
| | | |
| | | int num =1; |
| | | for(GoodsImport m: dataList){ |
| | | if(StringUtils.isBlank(m.getName()) |
| | | &&StringUtils.isBlank(m.getCategory()) |
| | | &&StringUtils.isBlank(m.getZdPrice()) |
| | | &&StringUtils.isBlank(m.getPrice()) |
| | | &&StringUtils.isBlank(m.getId()) |
| | | &&StringUtils.isBlank(m.getBrand())){ |
| | | if( StringUtils.isBlank(m.getId()) ){ |
| | | continue; |
| | | } |
| | | if(StringUtils.isBlank(m.getName()) |
| | | ||StringUtils.isBlank(m.getCategory()) |
| | | ||StringUtils.isBlank(m.getZdPrice()) |
| | | ||StringUtils.isBlank(m.getPrice()) |
| | | ||StringUtils.isBlank(m.getId()) |
| | | ||StringUtils.isBlank(m.getBrand())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行数据无效,请检查输入!"); |
| | | } |
| | | Goods g = new Goods(); |
| | | g.setIsdeleted(Constants.ZERO); |
| | |
| | | g.setCompanyId(user.getCompanyId()); |
| | | //品类数据 |
| | | g = goodsMapper.selectOne(new QueryWrapper<>(g).last(" limit 1")); |
| | | if(g != null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品图片文件夹重复,请检查输入!"); |
| | | if(g == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品不存在,请检查输入!"); |
| | | } |
| | | Category cate = new Category(); |
| | | cate.setIsdeleted(Constants.ZERO); |
| | | cate.setName(m.getCategory()); |
| | | cate.setCompanyId(user.getCompanyId()); |
| | | //品类数据 |
| | | cate = categoryMapper.selectOne(new QueryWrapper<>(cate).last(" limit 1")); |
| | | if(cate == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品类别无效,请检查输入!"); |
| | | } |
| | | Brand brand = new Brand(); |
| | | brand.setIsdeleted(Constants.ZERO); |
| | | brand.setName(m.getBrand()); |
| | | //品类数据 |
| | | QueryWrapper<Brand> qwrapper = new QueryWrapper<>(brand); |
| | | qwrapper.lambda().and(wapper-> wapper.eq(Brand::getCompanyId ,user.getCompanyId()).or().eq(Brand::getType,Constants.ONE)); |
| | | brand = brandMapper.selectOne(qwrapper.last(" limit 1")); |
| | | if(brand == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品品牌无效,请检查输入!"); |
| | | } |
| | | if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("ISDELETED",Constants.ZERO).eq("name",m.getName()))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"第【"+(num)+"】行【"+m.getName()+"】已存在"); |
| | | } |
| | | Goods newModel = new Goods(); |
| | | newModel.setRemark(m.getId()); |
| | | newModel.setCategoryId(cate.getId()); |
| | | newModel.setBrandId(brand.getId()); |
| | | newModel.setIsdeleted(Constants.ZERO); |
| | | newModel.setCreator(user.getId()); |
| | | newModel.setCompanyId(user.getCompanyId()); |
| | | newModel.setCreateDate(new Date()); |
| | | newModel.setName(m.getName()); |
| | | newModel.setStatus(Constants.ZERO); |
| | | try { |
| | | newModel.setZdPrice(BigDecimal.valueOf(Double.parseDouble(m.getZdPrice()))); |
| | | newModel.setPrice(BigDecimal.valueOf(Double.parseDouble(m.getPrice()))); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | if(newModel.getZdPrice() == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行指导价无效,请检查输入!"); |
| | | } |
| | | if(newModel.getPrice() == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行入手价无效,请检查输入!"); |
| | | } |
| | | newModel.setPinyin(PinYinUtil.getFullSpell(m.getName())); |
| | | newModel.setShortPinyin(PinYinUtil.getFirstSpell(m.getName())); |
| | | Goods newModel = new Goods(); |
| | | newModel.setId(g.getId()); |
| | | newModel.setEditor(user.getId()); |
| | | newModel.setEditDate(new Date()); |
| | | |
| | | String[] params = StringUtils.defaultString(m.getParamStr(),"").split("\n"); |
| | | List<String> mulFiles = null; |
| | |
| | | } |
| | | } |
| | | //查询商品信息 |
| | | goodsMapper.insert(newModel); |
| | | CateParam cp = new CateParam(); |
| | | cp.setIsdeleted(Constants.ZERO); |
| | | cp.setCategoryId(cate.getId()); |
| | | //查询全部产品参数配置 |
| | | List<CateParam> allParams = cateParamMapper.selectList(new QueryWrapper<>(cp)); |
| | | if(params.length > 0){ |
| | | for(String s : params){ |
| | | if(StringUtils.isBlank(s)){ |
| | | continue; |
| | | } |
| | | s = s.replace(":",":"); |
| | | String[] ts = s.split(":"); |
| | | if(ts.length == 0){ |
| | | continue; |
| | | } |
| | | //查询属性规格对象 |
| | | CateParam ta = getCateParamByName(ts[0], allParams); |
| | | if(ta == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行产品参数中【"+s+"】无效,请检查输入!"); |
| | | } |
| | | GoodsParam gp = new GoodsParam(); |
| | | gp.setIsdeleted(Constants.ZERO); |
| | | gp.setCreator(user.getId()); |
| | | gp.setCreateDate(newModel.getCreateDate()); |
| | | gp.setGoodsId(newModel.getId()); |
| | | gp.setName(ta.getName()); |
| | | gp.setPramaId(ta.getId()); |
| | | gp.setStatus(Constants.ZERO); |
| | | gp.setVal(ts.length>1?ts[1]:null); |
| | | 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); |
| | | // }; |
| | | } |
| | | } |
| | | goodsMapper.updateById(newModel); |
| | | if(mulFiles !=null && mulFiles.size()>0){ |
| | | multifileMapper.update(null,new UpdateWrapper<Multifile>().lambda() |
| | | .set(Multifile::getIsdeleted,Constants.ONE) |
| | | .eq(Multifile::getIsdeleted,Constants.ZERO) |
| | | .eq(Multifile::getObjId,g.getId()) |
| | | .eq(Multifile::getType,Constants.ZERO)); |
| | | for(int i=0;i<mulFiles.size();i++){ |
| | | String s = mulFiles.get(i); |
| | | Multifile f = new Multifile(); |
| | |
| | | queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO); |
| | | |
| | | queryWrapper.eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getCategoryId()), Goods::getCategoryId, pageWrap.getModel().getCategoryId()) |
| | | .eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getSubCategoryId()), Goods::getSubCategoryId, pageWrap.getModel().getSubCategoryId()) |
| | | .eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getBrandId()), Goods::getBrandId, pageWrap.getModel().getBrandId()) |
| | | .and(!Objects.isNull(pageWrap.getModel()) && StringUtils.isNotBlank(pageWrap.getModel().getKeyword()), |
| | | i->i.like(Goods::getPinyin,pageWrap.getModel().getKeyword()) |
| | |
| | | this.dealGoodsMsg(goodsIPage.getRecords()); |
| | | } |
| | | return PageData.from(goodsIPage); |
| | | } |
| | | |
| | | private void validateSubCategory(Goods goods) { |
| | | if (goods.getSubCategoryId() == null) { |
| | | return; |
| | | } |
| | | Category sub = categoryMapper.selectById(goods.getSubCategoryId()); |
| | | if (sub == null || sub.getParentId() == null || !sub.getParentId().equals(goods.getCategoryId())) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "二级类别必须属于所选一级品类"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.eq(Goods::getCompanyId,loginUserInfo.getCompanyId()); |
| | | queryWrapper.eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getCategoryId()), Goods::getCategoryId, goodsRequest.getCategoryId()) |
| | | .eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getSubCategoryId()), Goods::getSubCategoryId, goodsRequest.getSubCategoryId()) |
| | | .eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getBrandId()), Goods::getBrandId, goodsRequest.getBrandId()) |
| | | .and(!Objects.isNull(goodsRequest) && StringUtils.isNotBlank(goodsRequest.getKeyword()), |
| | | i->i.like(Goods::getPinyin,goodsRequest.getKeyword()) |