From b61110af489ad1278732bf91ed239fcca8567ac8 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Wed, 31 Aug 2022 17:46:01 +0800 Subject: [PATCH] 20220822 --- src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java | 61 ++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 1 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java index 5ed4b73..a65ff45 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java @@ -12,6 +12,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -109,6 +110,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 +324,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"); } @@ -337,6 +342,10 @@ } BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods); + if (mallGoods.getHasCarriage() == 2) { + mallGoods.setCarriage(BigDecimal.ZERO); + } + mallGoodsMapper.updateById(mallGoods); mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId()); @@ -465,5 +474,55 @@ 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(); + } + + @Override + public IPage<AdminHomeDeliverySettingVo> getDeliveryHomeListInPage(AdminHomeDeliverySettingVo adminHomeDeliverySetting, QueryRequest request) { + Page<DataDictionaryCustom> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<DataDictionaryCustom> dataDictionaryCustomIPage = this.baseMapper.getDeliveryHomeListInPage(page, adminHomeDeliverySetting); + List<DataDictionaryCustom> records = dataDictionaryCustomIPage.getRecords(); + List<AdminHomeDeliverySettingVo> adminHomeDeliverySettingVos = new ArrayList<>(); + if(CollUtil.isNotEmpty(records)){ + for(DataDictionaryCustom dataDictionaryCustom : records){ + AdminHomeDeliverySettingVo adminHomeDeliverySettingVo = JSONUtil.toBean(dataDictionaryCustom.getValue(), AdminHomeDeliverySettingVo.class); + adminHomeDeliverySettingVo.setId(dataDictionaryCustom.getId()); + adminHomeDeliverySettingVos.add(adminHomeDeliverySettingVo); + } + } + IPage<AdminHomeDeliverySettingVo> adminHomeDeliverySettingVoIPage = new Page<>(); + adminHomeDeliverySettingVoIPage.setRecords(adminHomeDeliverySettingVos); + adminHomeDeliverySettingVoIPage.setTotal(dataDictionaryCustomIPage.getTotal()); + return adminHomeDeliverySettingVoIPage; + } + + + private final DataDictionaryCustomMapper dataDictionaryCustomMapper; + @Override + public FebsResponse deliveryHomeUpdate(AdminHomeDeliverySettingVo adminHomeDeliverySettingVo) { + DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectById(adminHomeDeliverySettingVo.getId()); + adminHomeDeliverySettingVo.setId(null); + dataDictionaryCustom.setValue(JSONUtil.toJsonStr(adminHomeDeliverySettingVo)); + dataDictionaryCustomMapper.updateById(dataDictionaryCustom); + return new FebsResponse().success(); + } } -- Gitblit v1.9.1