| | |
| | | goodsSku.setGoodsId(goods.getId()); |
| | | goodsSku.setName(goods.getName()); |
| | | goodsSku.setPrice(goods.getSkuPrice()); |
| | | goodsSku.setShowPrice(goods.getPrice()); |
| | | goodsSku.setShowPrice(goods.getShowPrice()); |
| | | goodsSku.setStock(goods.getStockNum()); |
| | | goodsSku.setIntegralRate(goods.getDeductRata()); |
| | | goodsSku.setUnitName(goods.getUnitName()); |
| | |
| | | || goods.getBrandList() == null |
| | | || goods.getBrandList().size() == 0 |
| | | || goods.getWeight() == null |
| | | || goods.getDeductRata() == null |
| | | || goods.getPrice() == null |
| | | || goods.getSkuPrice() == null |
| | | || StringUtils.isBlank(goods.getImgurl()) |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); |
| | | } |
| | | |
| | | if(goods.getDeductRata().compareTo(new BigDecimal(0.1)) <Constants.ZERO || |
| | | goods.getDeductRata().compareTo(new BigDecimal(100)) >Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,积分可抵扣金额比例请设置[0.1,100]之间~"); |
| | | } |
| | | //查询分类 |
| | | Labels cate = labelsMapper.selectById(goods.getCategoryId()); |
| | | if(cate == null || Constants.equalsInteger(cate.getIsdeleted(),Constants.ONE) |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,分类信息不存在"); |
| | | } |
| | | if(goods.getBrandId()!=null){ |
| | | Labels brand = labelsMapper.selectById(goods.getCategoryId()); |
| | | Labels brand = labelsMapper.selectById(goods.getBrandId()); |
| | | if(brand == null || Constants.equalsInteger(brand.getIsdeleted(),Constants.ONE) |
| | | ||! Constants.equalsInteger(brand.getType(),Constants.LabelsType.GOODSBRAND.getKey())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,品牌信息不存在"); |
| | |
| | | List<Integer> bIds = new ArrayList<>(); |
| | | for(Labels b : goods.getBrandList()){ |
| | | bIds.add(b.getId()); |
| | | if(b.getChildIdList() == null || b.getChildIdList().size() ==0){ |
| | | if(b.getChildIdList() != null && b.getChildIdList().size() >=0){ |
| | | bIds.addAll(b.getChildIdList()); |
| | | } |
| | | } |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,请选择正确的适用品牌"); |
| | | } |
| | | idsBrand.add("["+b.getId()+"]"); |
| | | if(b.getChildIdList() == null || b.getChildIdList().size() ==0){ |
| | | if(b.getChildIdList()!= null && b.getChildIdList().size() >=0){ |
| | | for(Integer c :b.getChildIdList()){ |
| | | Labels cb = findLabelFromListByid(allBrands,b.getId(),Constants.LabelsType.SERIES_BRAND.getKey(),b.getId()); |
| | | Labels cb = findLabelFromListByid(allBrands,c,Constants.LabelsType.SERIES_BRAND.getKey(),b.getId()); |
| | | if(cb == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,品牌【"+tb.getName() +"】下所属系列不正确"); |
| | | } |
| | |
| | | if(idsSerial.size()>0){ |
| | | goods.setSerialIds(String.join(",",idsSerial)); |
| | | } |
| | | |
| | | } |
| | | |
| | | private Labels findLabelFromListByid(List<Labels> allBrands, Integer id, int type,Integer parentId) { |
| | |
| | | } |
| | | for(Labels labels:allBrands){ |
| | | if(!Constants.equalsInteger(id,labels.getId())){ |
| | | return null; |
| | | continue; |
| | | } |
| | | if(!Constants.equalsInteger(type,labels.getType())){ |
| | | return null; |
| | | continue; |
| | | } |
| | | if(parentId !=null && !Constants.equalsInteger(parentId,labels.getParentId())){ |
| | | return null; |
| | | continue; |
| | | } |
| | | return labels; |
| | | } |
| | |
| | | skuMapper.update(null,new UpdateWrapper<Sku>().lambda() |
| | | .set(Sku::getIsdeleted,Constants.ONE) |
| | | .eq(Sku::getIsdeleted,Constants.ZERO) |
| | | .eq(Sku::getGoodsId,goods.getSkuId())); |
| | | .eq(Sku::getGoodsId,goods.getId())); |
| | | goodsSkuMapper.update(null,new UpdateWrapper<GoodsSku>().lambda() |
| | | .set(GoodsSku::getIsdeleted,Constants.ONE) |
| | | .eq(GoodsSku::getIsdeleted,Constants.ZERO) |
| | | .eq(GoodsSku::getGoodsId,goods.getSkuId())); |
| | | .eq(GoodsSku::getGoodsId,goods.getId())); |
| | | dealDefaultGoodsSku(goods);//新建sku信息 |
| | | dealBatchMultiFiles(goods, goods.getFileList(), user,true); |
| | | } |
| | |
| | | @Override |
| | | public Goods findById(Integer id) { |
| | | MPJLambdaWrapper<Goods> queryWrapper = new MPJLambdaWrapper<>(); |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.ACTIVITY_FILE).getCode(); |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_FILE).getCode(); |
| | | |
| | | queryWrapper.eq(Goods::getId,id); |
| | | queryWrapper.selectAll(Goods.class); |
| | |
| | | //默认sku信息 |
| | | GoodsSku goodsSku = goodsSkuList.get(0); |
| | | goods.setSkuPrice(goodsSku.getPrice()); |
| | | goods.setShowPrice(goodsSku.getShowPrice()); |
| | | goods.setWeight(goodsSku.getWeight()); |
| | | goods.setStockNum(goodsSku.getStock()); |
| | | goods.setUnitName(goodsSku.getUnitName()); |
| | |
| | | } |
| | | } |
| | | } |
| | | goods.setBrandList(brandList); |
| | | } |
| | | } |
| | | |
| | |
| | | queryWrapper.leftJoin(Labels.class,Labels::getId,Goods::getBrandId); |
| | | queryWrapper.leftJoin(Labels.class,Labels::getId,Goods::getParentCategoryId); |
| | | //库存量 |
| | | queryWrapper.select("(select sum(STOCK) from goods_sku where ISDELETED=0 and GOODS_ID=t.id) as stockNum "); |
| | | queryWrapper.select("(select sum(STOCK) from goods_sku where ISDELETED=0 and GOODS_ID=t.id) as stockNum "); |
| | | //实际销量 |
| | | queryWrapper.select("(select sum(gd.GOODS_NUM) from goodsorder_detail gd" + |
| | | " inner join goods_sku gs on gs.id=gd.GOODS_SKU_ID" + |
| | |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_FILE).getCode(); |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_FILE).getCode(); |
| | | for (Goods goods : list) { |
| | | goods.setResourcePath(path); |
| | | //查询sku |
| | |
| | | //默认sku信息 |
| | | goods.setSkuPrice(goodsSku.getPrice()); |
| | | goods.setWeight(goodsSku.getWeight()); |
| | | goods.setShowPrice(goodsSku.getShowPrice()); |
| | | goods.setStockNum(goodsSku.getStock()); |
| | | goods.setUnitName(goodsSku.getUnitName()); |
| | | } |
| | | // initGoodsApplyBrandAndSerial(goods); |
| | | } |
| | | } |
| | | |