KKSU
2024-07-30 c1af5cf94920702b6aa962881365116542e88ab0
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
@@ -109,6 +109,10 @@
        //新增商品
        MallGoods mallGoods = MallGoodsConversion.INSTANCE.dtoToEntity(addMallGoodsDto);
        mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED);
        if (mallGoods.getHasCarriage() == 2) {
            mallGoods.setCarriage(BigDecimal.ZERO);
        }
        mallGoodsMapper.insert(mallGoods);
        String thumbs = addMallGoodsDto.getThumbs();
@@ -319,7 +323,7 @@
                        return new FebsResponse().fail().message("商品规格原价不能小于0");
                    }
                    BigDecimal presentPrice = addSku.getPresentPrice();
                    if (presentPrice.compareTo(BigDecimal.ZERO) <= 0) {
                    if (presentPrice.compareTo(BigDecimal.ZERO) < 0) {
                        return new FebsResponse().fail().message("商品规格现价不能小于0");
                    }
@@ -331,12 +335,16 @@
        MallGoods mallGoods = mallGoodsMapper.selectById(mallGoodsUpdateDto.getId());
        // 若原来不为多规格或编辑后也不为多规格,则清空样式和规格
        if (mallGoods.getIsSku() == 2 || mallGoodsUpdateDto.getIsSku() == 2) {
        if (2 == mallGoodsUpdateDto.getIsSku()|| 2 == (mallGoods.getIsSku() == null ? 1 : mallGoods.getIsSku())) {
            mallGoodsSkuMapper.deleteByGoodsId(mallGoods.getId());
            mallGoodsStyleMapper.deleteByGoodsId(mallGoods.getId());
        }
        BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods);
        if (2 == mallGoods.getHasCarriage()) {
            mallGoods.setCarriage(BigDecimal.ZERO);
        }
        mallGoodsMapper.updateById(mallGoods);
        mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId());
@@ -465,5 +473,27 @@
        return mallGoodsMapper.getAllGoodsTree();
    }
    @Override
    public FebsResponse goodsHot(Long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoods)) {
            return new FebsResponse().fail().message("商品不存在,请刷新当前页面");
        }
        mallGoods.setIsHot(MallGoods.ISHOT_STATE_YES);
        mallGoodsMapper.updateById(mallGoods);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse goodsNotHot(Long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoods)) {
            return new FebsResponse().fail().message("商品不存在,请刷新当前页面");
        }
        mallGoods.setIsHot(MallGoods.ISHOT_STATE_NO);
        mallGoodsMapper.updateById(mallGoods);
        return new FebsResponse().success();
    }
}