|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.FebsResponse; | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.QueryRequest; | 
|---|
|  |  |  | import cc.mrbird.febs.common.utils.AppContants; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.conversion.MallGoodsConversion; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.*; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | public IPage<AdminMallGoodsVo> getCategoryListInPage(MallGoods mallGoods, QueryRequest request) { | 
|---|
|  |  |  | Page<AdminMallGoodsVo> page = new Page<>(request.getPageNum(), request.getPageSize()); | 
|---|
|  |  |  | IPage<AdminMallGoodsVo> adminMallGoodsVos = this.baseMapper.selectMallGoodsInPage(page, mallGoods); | 
|---|
|  |  |  | return adminMallGoodsVos; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<AdminMallGoodsVo> getAppCategoryListInPage(MallGoods mallGoods, QueryRequest request) { | 
|---|
|  |  |  | Page<AdminMallGoodsVo> page = new Page<>(request.getPageNum(), request.getPageSize()); | 
|---|
|  |  |  | IPage<AdminMallGoodsVo> adminMallGoodsVos = this.baseMapper.selectMallAppGoodsInPage(page, mallGoods); | 
|---|
|  |  |  | return adminMallGoodsVos; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //新增商品 | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new FebsResponse().success().message("操作成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public FebsResponse addMallAppGoods(AddMallGoodsDto addMallGoodsDto) { | 
|---|
|  |  |  | String goodsNo = addMallGoodsDto.getGoodsNo(); | 
|---|
|  |  |  | Integer mallGoodsByGoodsNo = mallGoodsMapper.selectMallGoodsCountByGoodsNo(goodsNo); | 
|---|
|  |  |  | if (mallGoodsByGoodsNo > 0) { | 
|---|
|  |  |  | return new FebsResponse().fail().message("商品编号不能重复"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //新增商品 | 
|---|
|  |  |  | MallGoods mallGoods = MallGoodsConversion.INSTANCE.dtoToEntity(addMallGoodsDto); | 
|---|
|  |  |  | mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED); | 
|---|
|  |  |  | mallGoods.setIsApp(AppContants.IS_APP_GOODS); | 
|---|
|  |  |  | mallGoodsMapper.insert(mallGoods); | 
|---|
|  |  |  | return new FebsResponse().success().message("添加成功"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | 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"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods); | 
|---|
|  |  |  | if (mallGoods.getHasCarriage() == 2) { | 
|---|
|  |  |  | mallGoods.setCarriage(BigDecimal.ZERO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallGoodsMapper.updateById(mallGoods); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public FebsResponse updateAppMallGoods(MallGoodsUpdateDto mallGoodsUpdateDto) { | 
|---|
|  |  |  | //新增商品 | 
|---|
|  |  |  | MallGoods mallGoods = mallGoodsMapper.selectById(mallGoodsUpdateDto.getId()); | 
|---|
|  |  |  | BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods); | 
|---|
|  |  |  | mallGoodsMapper.updateById(mallGoods); | 
|---|
|  |  |  | return new FebsResponse().success().message("操作成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<AdminMallGoodsTreeVo> getAllGoodsTree() { | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|