From ff811ae8df41273d7ab0011b6b7f1f278f03bbd2 Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期四, 12 十二月 2024 18:06:05 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 106 insertions(+), 3 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java index 7176262..6e1ea7f 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java @@ -1,29 +1,34 @@ package com.ruoyi.other.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.order.feignClient.RemoteOrderGoodsClient; +import com.ruoyi.order.vo.Price; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.enums.GoodsStatus; import com.ruoyi.other.mapper.GoodsAreaMapper; import com.ruoyi.other.mapper.GoodsMapper; import com.ruoyi.other.mapper.GoodsShopMapper; import com.ruoyi.other.mapper.ShopMapper; -import com.ruoyi.other.service.GoodsService; -import com.ruoyi.other.service.GoodsVipService; -import com.ruoyi.other.service.VipSettingService; +import com.ruoyi.other.service.*; import com.ruoyi.other.vo.GoodsVO; import com.ruoyi.system.api.model.LoginUser; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -53,7 +58,15 @@ @Resource private GoodsShopMapper goodsShopMapper; @Resource + private GoodsShopService goodsShopService; + @Resource + private GoodsAppUserService goodsAppUserService; + @Resource private ShopMapper shopMapper; + @Resource + private GoodsAreaService goodsAreaService; + @Resource + private RemoteOrderGoodsClient remoteOrderGoodsClient; @Override public List<GoodsVO> goodsList(Goods search) { @@ -63,11 +76,18 @@ .like(StringUtils.isNotEmpty(search.getName()), Goods::getName, search.getName())); List<GoodsVO> result = new ArrayList<>(); + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); for (Goods goods : goodsList) { GoodsVO goodsVO = new GoodsVO(); BeanUtils.copyBeanProp(goodsVO, goods); goodsVO.setGoodsId(goods.getId()); goodsVO.setGoodsName(goods.getName()); + R<Price> r = remoteOrderGoodsClient.getGoodsPrice(loginUserApplet.getUserid(), goods.getId(), null); + if (R.isSuccess(r)){ + Price price = r.getData(); + goodsVO.setSellingPrice(price.getCash()); + goodsVO.setIntegral(price.getPoint()); + } result.add(goodsVO); } return result; @@ -131,4 +151,87 @@ return goodsMapper.selectListByShopId(shopId, vipSetting.getId()); } + @Override + public IPage<Goods> getManageGoodsList(Page<Goods> page, Goods goods) { + return goodsMapper.selectManageGoodsList(page, goods); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void addGoods(Goods goods) { + goods.setSaleNum(0); + goods.setStatus(GoodsStatus.DOWN.getCode()); + goodsMapper.insert(goods); + + // 指定门店 + Integer appointStore = goods.getAppointStore(); + if (appointStore == 1){ + List<GoodsShop> goodsShopList = goods.getGoodsShopList(); + if (CollectionUtils.isEmpty(goodsShopList)){ + throw new NullPointerException("请选择指定门店"); + } + goodsShopService.saveBatch(goodsShopList); + } + + // 指定用户 + List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList(); + if (!CollectionUtils.isEmpty(goodsAppUserList)){ + goodsAppUserService.saveBatch(goodsAppUserList); + } + + // 会员价格配置 + List<GoodsVip> goodsVipList = goods.getGoodsVipList(); + goodsVipService.saveBatch(goodsVipList); + + // 特殊地区售价设置 + List<GoodsArea> goodsAreaList = goods.getGoodsAreaList(); + if (!CollectionUtils.isEmpty(goodsAreaList)){ + goodsAreaService.saveBatch(goodsAreaList); + } + } + + @Override + public void updateManageGoods(Goods goods) { + goodsMapper.updateById(goods); + // 指定门店 + List<GoodsShop> goodsShopList = goods.getGoodsShopList(); + goodsShopService.updateBatchById(goodsShopList); + + // 指定用户 + List<GoodsAppUser> goodsAppUserList = goods.getGoodsAppUserList(); + goodsAppUserService.updateBatchById(goodsAppUserList); + + // 会员价格配置 + List<GoodsVip> goodsVipList = goods.getGoodsVipList(); + goodsVipService.updateBatchById(goodsVipList); + + // 特殊地区售价设置 + List<GoodsArea> goodsAreaList = goods.getGoodsAreaList(); + goodsAreaService.updateBatchById(goodsAreaList); + } + + @Override + public Goods getManageGoodsDetail(Long goodsId) { + Goods goods = getById(goodsId); + // 指定门店 + List<GoodsShop> goodsShops = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>() + .eq(GoodsShop::getGoodsId, goodsId)); + goods.setGoodsShopList(goodsShops); + + // 指定用户 + List<GoodsAppUser> goodsAppUserList = goodsAppUserService.list(new LambdaQueryWrapper<GoodsAppUser>() + .eq(GoodsAppUser::getGoodsId, goodsId)); + goods.setGoodsAppUserList(goodsAppUserList); + + // 会员价格 + List<GoodsVip> goodsVipList = goodsVipService.list(new LambdaQueryWrapper<GoodsVip>() + .eq(GoodsVip::getGoodsId, goodsId)); + goods.setGoodsVipList(goodsVipList); + + // 特殊地区售价设置 + List<GoodsArea> goodsAreaList = goodsAreaService.list(new LambdaQueryWrapper<GoodsArea>() + .eq(GoodsArea::getGoodsId, goodsId)); + goods.setGoodsAreaList(goodsAreaList); + return goods; + } } -- Gitblit v1.7.1