| | |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IAdminMallGoodsService; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | if (CollUtil.isNotEmpty(addMallGoodsSkuDtos)) { |
| | | for (AddMallGoodsSkuDto addMallGoodsSkuDto : addMallGoodsSkuDtos) { |
| | | MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addMallGoodsSkuDto.getStyleName(), mallGoods.getId()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public MallGoods selectGoodsById(long id) { |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(id); |
| | | |
| | | List<MallGoodsSku> skus = mallGoodsSkuMapper.selectSkuByGoodsId(mallGoods.getId()); |
| | | List<String> thumbs = mallGoodsImagesMapper.selectByGoodId(mallGoods.getId()); |
| | | mallGoods.setImages(thumbs); |
| | | mallGoods.setSkus(skus); |
| | | return mallGoods; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public FebsResponse updateMallGoods(MallGoodsUpdateDto mallGoodsUpdateDto) { |
| | | String goodsName = mallGoodsUpdateDto.getGoodsName(); |
| | |
| | | } |
| | | //新增商品 |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(mallGoodsUpdateDto.getId()); |
| | | mallGoods.setGoodsNo(mallGoodsUpdateDto.getGoodsNo()); |
| | | mallGoods.setGoodsName(mallGoodsUpdateDto.getGoodsName()); |
| | | mallGoods.setGoodsIntrodution(mallGoodsUpdateDto.getGoodsIntrodution()); |
| | | mallGoods.setUnit(mallGoodsUpdateDto.getUnit()); |
| | | mallGoods.setThumb(mallGoodsUpdateDto.getThumb()); |
| | | mallGoods.setGoodsDetails(mallGoodsUpdateDto.getGoodsDetails()); |
| | | mallGoods.setOriginalPrice(mallGoodsUpdateDto.getOriginalPrice()); |
| | | mallGoods.setCategoryId(mallGoodsUpdateDto.getCategoryId()); |
| | | mallGoods.setPresentPrice(mallGoodsUpdateDto.getPresentPrice()); |
| | | mallGoods.setIsHot(mallGoodsUpdateDto.getIsHot()); |
| | | // mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED); |
| | | BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods); |
| | | mallGoodsMapper.updateById(mallGoods); |
| | | |
| | | mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId()); |
| | | |
| | | String thumbs = mallGoodsUpdateDto.getThumbs(); |
| | | if (StrUtil.isNotEmpty(thumbs)) { |
| | | List<String> imgs = StrUtil.splitTrim(thumbs, ","); |
| | |
| | | } |
| | | } |
| | | |
| | | // 删除已存在sku |
| | | List<Long> delSkuIds = mallGoodsUpdateDto.getDelSkuId(); |
| | | if (CollUtil.isNotEmpty(delSkuIds)) { |
| | | mallGoodsSkuMapper.delSkuByIds(delSkuIds); |
| | | |
| | | // 如果该样式下sku全删除,则删除该样式 |
| | | List<MallGoodsStyle> styles = mallGoodsStyleMapper.selectByGoodsId(mallGoods.getId()); |
| | | for (MallGoodsStyle style : styles) { |
| | | if (CollUtil.isEmpty(style.getSkus())) { |
| | | mallGoodsStyleMapper.deleteById(style.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<MailGoodsSkuDto> mailGoodsSkuDto = mallGoodsUpdateDto.getMailGoodsSkuDto(); |
| | | Set<String> styles = new HashSet<>(); |
| | | if (CollUtil.isNotEmpty(mailGoodsSkuDto)) { |
| | | for (MailGoodsSkuDto addStyleDto : mailGoodsSkuDto) { |
| | | if (ObjectUtil.isNotEmpty(addStyleDto.getDelLog())) { |
| | | mallGoodsSkuMapper.deleteById(addStyleDto.getId()); |
| | | // if (ObjectUtil.isNotEmpty(addStyleDto.getDelLog())) { |
| | | // mallGoodsSkuMapper.deleteById(addStyleDto.getId()); |
| | | // mallShoppingCartMapper.deleteByGoodsIdAndSkuId(addStyleDto.getId(), addStyleDto.getGoodsId()); |
| | | // } |
| | | |
| | | mallShoppingCartMapper.deleteByGoodsIdAndSkuId(addStyleDto.getId(), addStyleDto.getGoodsId()); |
| | | } |
| | | if (ObjectUtil.isEmpty(addStyleDto.getStyleId())) { |
| | | MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addStyleDto.getStyleName(), mallGoods.getId()); |
| | | if (ObjectUtil.isEmpty(mallGoodsStyleSku)) { |
| | |
| | | mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice()); |
| | | mallGoodsSku.setStyleId(addMallGoodsSkuDto.getStyleId()); |
| | | mallGoodsSku.setGoodsId(mallGoods.getId()); |
| | | mallGoodsSku.setCostPrice(addMallGoodsSkuDto.getCostPrice()); |
| | | mallGoodsSkuMapper.updateById(mallGoodsSku); |
| | | } else { |
| | | //新增商品规格 |
| | |
| | | mallGoodsSku.setOriginalPrice(addMallGoodsSkuDto.getOriginalPrice()); |
| | | mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice()); |
| | | mallGoodsSku.setStyleId(mallGoodsStyleSku.getId()); |
| | | mallGoodsSku.setCostPrice(addMallGoodsSkuDto.getCostPrice()); |
| | | mallGoodsSku.setGoodsId(mallGoods.getId()); |
| | | mallGoodsSkuMapper.insert(mallGoodsSku); |
| | | } |