From 8b29c5ca4fac5a50d928c7b06162845cc50b9a53 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Mon, 13 Feb 2023 14:12:32 +0800 Subject: [PATCH] 后台,设置成为合伙人的金额 --- src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java | 101 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 96 insertions(+), 5 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java index 7471bf9..1c89a4b 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallGoodsServiceImpl.java @@ -1,23 +1,32 @@ package cc.mrbird.febs.mall.service.impl; +import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; import cc.mrbird.febs.common.exception.FebsException; +import cc.mrbird.febs.common.utils.AppContants; import cc.mrbird.febs.mall.conversion.MallGoodsConversion; import cc.mrbird.febs.mall.conversion.MallMemberConversion; +import cc.mrbird.febs.mall.dto.ApiMallGoodsCommentDto; import cc.mrbird.febs.mall.dto.MallGoodsQueryDto; -import cc.mrbird.febs.mall.entity.MallGoods; -import cc.mrbird.febs.mall.mapper.MallGoodsImagesMapper; -import cc.mrbird.febs.mall.mapper.MallGoodsMapper; +import cc.mrbird.febs.mall.entity.*; +import cc.mrbird.febs.mall.mapper.*; import cc.mrbird.febs.mall.service.IApiMallGoodsService; -import cc.mrbird.febs.mall.vo.MallGoodsDetailsVo; -import cc.mrbird.febs.mall.vo.MallGoodsListVo; +import cc.mrbird.febs.mall.vo.*; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.checkerframework.checker.units.qual.A; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * @author wzy @@ -29,11 +38,48 @@ public class ApiMallGoodsServiceImpl extends ServiceImpl<MallGoodsMapper, MallGoods> implements IApiMallGoodsService { private final MallGoodsImagesMapper goodsImagesMapper; + private final MallGoodsCommentMapper mallGoodsCommentMapper; + private final DataDictionaryCustomMapper dataDictionaryCustomMapper; + private final MallCarriageRuleMapper mallCarriageRuleMapper; + private final MallCarriageRuleInfoMapper mallCarriageRuleInfoMapper; + @Override public IPage<MallGoodsListVo> findMallGoodsListInPage(MallGoodsQueryDto queryDto) { Page<MallGoodsListVo> page = new Page<>(queryDto.getPageNow(), queryDto.getPageSize()); return this.baseMapper.selectMallGoodsListQueryInPage(queryDto, page); + } + + @Override + public List<MallGoodsListVo> findMallGoodsListNoPage(MallGoodsQueryDto queryDto) { + return this.baseMapper.selectMallGoodsListQueryNoPage(queryDto); + } + + @Override + public ApiMallCarriageRuleVo findMallCarriageRuleById(Long id) { + ApiMallCarriageRuleVo apiMallCarriageRuleVo = new ApiMallCarriageRuleVo(); + + MallCarriageRule mallCarriageRule = mallCarriageRuleMapper.selectById(id); + if(ObjectUtil.isEmpty(mallCarriageRule)){ + throw new FebsException("商品不存在"); + } + apiMallCarriageRuleVo.setName(mallCarriageRule.getName()); + + List<MallCarriageRuleInfo> mallCarriageRuleInfos = mallCarriageRuleInfoMapper.selectMallCarriageRuleInfoByRuleIdAndAreaAddress(id, null); + if(CollUtil.isNotEmpty(mallCarriageRuleInfos)){ + List<ApiMallCarriageRuleInfoVo> apiMallCarriageRuleInfoVos = new ArrayList<>(); + for(MallCarriageRuleInfo mallCarriageRuleInfo : mallCarriageRuleInfos){ + ApiMallCarriageRuleInfoVo apiMallCarriageRuleInfoVo = new ApiMallCarriageRuleInfoVo(); + apiMallCarriageRuleInfoVo.setAreaAddress(mallCarriageRuleInfo.getAreaAddress()); + apiMallCarriageRuleInfoVo.setBasicPrice(mallCarriageRuleInfo.getBasicPrice()); + apiMallCarriageRuleInfoVo.setBasicCnt(mallCarriageRuleInfo.getBasicCnt()); + apiMallCarriageRuleInfoVo.setMoreCnt(mallCarriageRuleInfo.getMoreCnt()); + apiMallCarriageRuleInfoVo.setMorePrice(mallCarriageRuleInfo.getMorePrice()); + apiMallCarriageRuleInfoVos.add(apiMallCarriageRuleInfoVo); + } + apiMallCarriageRuleVo.setApiMallCarriageRuleInfoVos(apiMallCarriageRuleInfoVos); + } + return apiMallCarriageRuleVo; } @Override @@ -44,7 +90,52 @@ } List<String> images = goodsImagesMapper.selectGoodsImagesByGoodsId(mallGoods.getId()); MallGoodsDetailsVo mallGoodsDetailsVo = MallGoodsConversion.INSTANCE.entityToDetailsVo(mallGoods); + + if (CollUtil.isNotEmpty(mallGoods.getStyles())) { + Map<String, BigDecimal> stockAndVolume = this.baseMapper.selectGoodsStockAndVolume(id); + mallGoodsDetailsVo.setStock(stockAndVolume.get("stock").intValue()); + mallGoodsDetailsVo.setVolume(stockAndVolume.get("volume").intValue()); + } mallGoodsDetailsVo.setImages(images); + + QueryWrapper<MallGoodsComment> objectQueryWrapper = new QueryWrapper<>(); + objectQueryWrapper.eq("goods_id",id); + Integer commentCount = mallGoodsCommentMapper.selectCount(objectQueryWrapper); + mallGoodsDetailsVo.setCommentCount(commentCount); return mallGoodsDetailsVo; } + + @Override + public IPage<MallGoodsCommentVo> findMallGoodsCommentByGoodsId(ApiMallGoodsCommentDto queryDto) { + Page<MallGoodsCommentVo> page = new Page<>(queryDto.getPageNow(), queryDto.getPageSize()); + MallGoodsComment mallGoodsComment = new MallGoodsComment(); + mallGoodsComment.setGoodsId(queryDto.getGoodsId()); + mallGoodsComment.setCommentType(queryDto.getCommentType()); + return this.baseMapper.selectMallGoodsCommentListQueryInPage(page,mallGoodsComment); + } + + @Override + public ApiMallGoodsDeliveryVo findDeliverySetting() { + ApiMallGoodsDeliveryVo apiMallGoodsDeliveryVo = new ApiMallGoodsDeliveryVo(); + DataDictionaryCustom deliverySetting = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.HOME_DELIVERY_AMOUNT.getType(), DataDictionaryEnum.HOME_DELIVERY_AMOUNT.getCode()); + if(ObjectUtil.isNotNull(deliverySetting)){ + apiMallGoodsDeliveryVo.setHomeDeliveryServiceAmount(Double.parseDouble(deliverySetting.getValue())); + } + List<DataDictionaryCustom> homeDeliverySettings = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.FRIST_COST_LEVEL.getType()); + if(CollUtil.isNotEmpty(homeDeliverySettings)){ + List<ApiMallGoodsDeliverySettingVo> apiMallGoodsDeliverySettingVos = new ArrayList<>(); + for(DataDictionaryCustom dic : homeDeliverySettings){ + String apiMallGoodsDeliverySettingVoJson = dic.getValue(); + ApiMallGoodsDeliverySettingVo apiMallGoodsDeliverySettingVo = JSONUtil.toBean(apiMallGoodsDeliverySettingVoJson, ApiMallGoodsDeliverySettingVo.class); + apiMallGoodsDeliverySettingVos.add(apiMallGoodsDeliverySettingVo); + } + apiMallGoodsDeliveryVo.setApiMallGoodsDeliverySettingVos(apiMallGoodsDeliverySettingVos); + } + return apiMallGoodsDeliveryVo; + } + + @Override + public MallGoodsCommentVo findMallGoodsCommentLevelByGoodsId(Long id) { + return this.baseMapper.findMallGoodsCommentLevelByGoodsId(id); + } } -- Gitblit v1.9.1