|  |  |  | 
|---|
|  |  |  | if (mallGoodsByGoodsNo > 0) { | 
|---|
|  |  |  | return new FebsResponse().fail().message("商品编号不能重复"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer carriageType = addMallGoodsDto.getCarriageType(); | 
|---|
|  |  |  | if(1 == carriageType){ | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(addMallGoodsDto.getCarriageAmount()) | 
|---|
|  |  |  | || BigDecimal.ZERO.compareTo(addMallGoodsDto.getCarriageAmount()) > 0){ | 
|---|
|  |  |  | return new FebsResponse().fail().message("固定邮费不能小于零"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | Long carriageRuleId = addMallGoodsDto.getCarriageRuleId(); | 
|---|
|  |  |  | MallCarriageRule mallCarriageRule = mallCarriageRuleMapper.selectById(carriageRuleId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(mallCarriageRule)){ | 
|---|
|  |  |  | return new FebsResponse().fail().message("邮费模板不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 付费商品 | 
|---|
|  |  |  | if (addMallGoodsDto.getGoodsType() != 2) { | 
|---|
|  |  |  | 
|---|
|  |  |  | if (StrUtil.isEmpty(presentPrice)) { | 
|---|
|  |  |  | return new FebsResponse().fail().message("商品规格现价不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BigDecimal goodsWeight = addSku.getGoodsWeight(); | 
|---|
|  |  |  | if(BigDecimal.ZERO.compareTo(goodsWeight) > 0){ | 
|---|
|  |  |  | return new FebsResponse().fail().message("重量不能小于零"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | MallGoods mallGoods = MallGoodsConversion.INSTANCE.dtoToEntity(addMallGoodsDto); | 
|---|
|  |  |  | mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (mallGoods.getHasCarriage() == 2) { | 
|---|
|  |  |  | mallGoods.setCarriage(BigDecimal.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (mallGoods.getHasCarriage() == 2) { | 
|---|
|  |  |  | //            mallGoods.setCarriage(BigDecimal.ZERO); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | mallGoodsMapper.insert(mallGoods); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String thumbs = addMallGoodsDto.getThumbs(); | 
|---|
|  |  |  | 
|---|
|  |  |  | sku.setSkuVolume(mallGoods.getVolume()); | 
|---|
|  |  |  | sku.setStock(mallGoods.getStock()); | 
|---|
|  |  |  | sku.setStyleId(style.getId()); | 
|---|
|  |  |  | sku.setGoodsWeight(mallGoods.getGoodsWeight()); | 
|---|
|  |  |  | mallGoodsSkuMapper.insert(sku); | 
|---|
|  |  |  | return new FebsResponse().success().message("添加成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | mallGoodsSku.setStyleId(mallGoodsStyleSku.getId()); | 
|---|
|  |  |  | mallGoodsSku.setCostPrice(addMallGoodsSkuDto.getCostPrice()); | 
|---|
|  |  |  | mallGoodsSku.setGoodsId(mallGoods.getId()); | 
|---|
|  |  |  | mallGoodsSku.setGoodsWeight(addMallGoodsSkuDto.getGoodsWeight()); | 
|---|
|  |  |  | mallGoodsSku.setSample(addMallGoodsSkuDto.getSample()); | 
|---|
|  |  |  | mallGoodsSkuMapper.insert(mallGoodsSku); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (mallGoodsByGoodsNo > 0) { | 
|---|
|  |  |  | return new FebsResponse().fail().message("商品编号不能重复"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer carriageType = mallGoodsUpdateDto.getCarriageType(); | 
|---|
|  |  |  | if(1 == carriageType){ | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(mallGoodsUpdateDto.getCarriageAmount()) | 
|---|
|  |  |  | || BigDecimal.ZERO.compareTo(mallGoodsUpdateDto.getCarriageAmount()) > 0){ | 
|---|
|  |  |  | return new FebsResponse().fail().message("固定邮费不能小于零"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | Long carriageRuleId = mallGoodsUpdateDto.getCarriageRuleId(); | 
|---|
|  |  |  | MallCarriageRule mallCarriageRule = mallCarriageRuleMapper.selectById(carriageRuleId); | 
|---|
|  |  |  | if(ObjectUtil.isEmpty(mallCarriageRule)){ | 
|---|
|  |  |  | return new FebsResponse().fail().message("邮费模板不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (mallGoodsUpdateDto.getGoodsType() != 2) { | 
|---|
|  |  |  | Long categoryId = mallGoodsUpdateDto.getCategoryId(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (presentPrice.compareTo(BigDecimal.ZERO) < 0) { | 
|---|
|  |  |  | return new FebsResponse().fail().message("商品规格现价不能小于0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BigDecimal goodsWeight = addSku.getGoodsWeight(); | 
|---|
|  |  |  | if(BigDecimal.ZERO.compareTo(goodsWeight) > 0){ | 
|---|
|  |  |  | return new FebsResponse().fail().message("重量不能小于零"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods); | 
|---|
|  |  |  | if (mallGoods.getHasCarriage() == 2) { | 
|---|
|  |  |  | mallGoods.setCarriage(BigDecimal.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if (mallGoods.getHasCarriage() == 2) { | 
|---|
|  |  |  | //            mallGoods.setCarriage(BigDecimal.ZERO); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallGoodsMapper.updateById(mallGoods); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if( 1 == mallGoods.getCarriageType()){ | 
|---|
|  |  |  | mallGoodsMapper.updateCarriageRuleId(mallGoods.getId()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | mallGoodsMapper.updateCarriageAmount(mallGoods.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId()); | 
|---|
|  |  |  | String thumbs = mallGoodsUpdateDto.getThumbs(); | 
|---|
|  |  |  | 
|---|
|  |  |  | sku.setSkuVolume(mallGoods.getVolume()); | 
|---|
|  |  |  | sku.setStock(mallGoods.getStock()); | 
|---|
|  |  |  | sku.setStyleId(style.getId()); | 
|---|
|  |  |  | sku.setGoodsWeight(mallGoods.getGoodsWeight()); | 
|---|
|  |  |  | mallGoodsSkuMapper.insert(sku); | 
|---|
|  |  |  | return new FebsResponse().success().message("添加成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (ObjectUtil.isEmpty(mallGoodsStyleSku)) { | 
|---|
|  |  |  | styles.add(addStyleDto.getStyleName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | MallGoodsStyle mallGoodsStyle = mallGoodsStyleMapper.selectById(addStyleDto.getStyleId()); | 
|---|
|  |  |  | mallGoodsStyle.setName(addStyleDto.getStyleName()); | 
|---|
|  |  |  | mallGoodsStyleMapper.updateById(mallGoodsStyle); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | mallGoodsSku.setStyleId(addMallGoodsSkuDto.getStyleId()); | 
|---|
|  |  |  | mallGoodsSku.setGoodsId(mallGoods.getId()); | 
|---|
|  |  |  | mallGoodsSku.setCostPrice(addMallGoodsSkuDto.getCostPrice()); | 
|---|
|  |  |  | mallGoodsSku.setGoodsWeight(addMallGoodsSkuDto.getGoodsWeight()); | 
|---|
|  |  |  | mallGoodsSku.setSample(addMallGoodsSkuDto.getSample()); | 
|---|
|  |  |  | mallGoodsSkuMapper.updateById(mallGoodsSku); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //新增商品规格 | 
|---|
|  |  |  | 
|---|
|  |  |  | mallGoodsSku.setStyleId(mallGoodsStyleSku.getId()); | 
|---|
|  |  |  | mallGoodsSku.setCostPrice(addMallGoodsSkuDto.getCostPrice()); | 
|---|
|  |  |  | mallGoodsSku.setGoodsId(mallGoods.getId()); | 
|---|
|  |  |  | mallGoodsSku.setGoodsWeight(addMallGoodsSkuDto.getGoodsWeight()); | 
|---|
|  |  |  | mallGoodsSku.setSample(addMallGoodsSkuDto.getSample()); | 
|---|
|  |  |  | mallGoodsSkuMapper.insert(mallGoodsSku); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<MallCarriageRuleInfo> mallCarriageRuleInfos = mallCarriageRuleInfoMapper.selectMallCarriageRuleInfoByRuleIdAndAreaAddress(id,null); | 
|---|
|  |  |  | if(CollUtil.isNotEmpty(mallCarriageRuleInfos)){ | 
|---|
|  |  |  | StringBuffer areaAddressStr = new StringBuffer(); | 
|---|
|  |  |  | List<AdminMallCarriageRuleInfoVo> adminCarriageRuleInfoVos = new ArrayList<>(); | 
|---|
|  |  |  | for(MallCarriageRuleInfo mallCarriageRuleInfo : mallCarriageRuleInfos){ | 
|---|
|  |  |  | if(StrUtil.isNotEmpty(mallCarriageRuleInfo.getAreaAddress())){ | 
|---|
|  |  |  | 
|---|
|  |  |  | adminMallCarriageRuleInfoVo.setMoreCnt(mallCarriageRuleInfo.getMoreCnt()); | 
|---|
|  |  |  | adminMallCarriageRuleInfoVo.setMorePrice(mallCarriageRuleInfo.getMorePrice()); | 
|---|
|  |  |  | adminCarriageRuleInfoVos.add(adminMallCarriageRuleInfoVo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | areaAddressStr.append(mallCarriageRuleInfo.getAreaAddress()); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //默认规则 | 
|---|
|  |  |  | adminMallCarriageRuleVo.setBasicCntDefault(mallCarriageRuleInfo.getBasicCnt()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | adminMallCarriageRuleVo.setAdminCarriageRuleInfoVos(adminCarriageRuleInfoVos); | 
|---|
|  |  |  | adminMallCarriageRuleVo.setAreaAddressStr(areaAddressStr.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return adminMallCarriageRuleVo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new FebsResponse().fail().message(goodsNameBuffer+"正在使用当前模板,请先下架商品"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallCarriageRule.setName(adminCarriageRuleUpdateDto.getRuleName()); | 
|---|
|  |  |  | mallCarriageRuleMapper.updateById(mallCarriageRule); | 
|---|
|  |  |  | //删除现有的所有运费模板子表数据 | 
|---|
|  |  |  | List<MallCarriageRuleInfo> mallCarriageRuleInfos = mallCarriageRuleInfoMapper.selectMallCarriageRuleInfoByRuleIdAndAreaAddress(id, null); | 
|---|
|  |  |  | if(CollUtil.isNotEmpty(mallCarriageRuleInfos)){ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new FebsResponse().success().message("操作成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<MallCarriageRule> findAllCarriageRuleTree() { | 
|---|
|  |  |  | List<MallCarriageRule> mallCarriageRules = mallCarriageRuleMapper.selectList(new QueryWrapper<>()); | 
|---|
|  |  |  | return mallCarriageRules; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|