From 6acf6357094588946b5528f1ef1ed84a0f1037fd Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期五, 13 六月 2025 19:45:27 +0800 Subject: [PATCH] 小程序收付款 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java | 141 +++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 135 insertions(+), 6 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java index daea2a6..968a5ea 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java @@ -32,6 +32,7 @@ import java.math.RoundingMode; import java.time.LocalDateTime; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -74,6 +75,8 @@ private GoodsShopMapper goodsShopMapper; @Resource private GoodsShopService goodsShopService; + @Resource + private GoodsEvaluateMapper goodsEvaluateMapper; /** @@ -224,7 +227,9 @@ public PageInfo<ShopBalanceStatementVO> getShopBalanceStatementList(Integer shopId, LocalDateTime startTime, LocalDateTime endTime, Integer type, Integer pageCurr, Integer pageSize) { PageInfo<ShopBalanceStatementVO> pageInfo = new PageInfo<>(pageCurr, pageSize); List<ShopBalanceStatementVO> ShopBalanceStatementList = shopBalanceStatementMapper.getShopBalanceStatementList(pageInfo, shopId, startTime, endTime, type); + for (ShopBalanceStatementVO shopBalanceStatementVO : ShopBalanceStatementList) { + log.error(shopBalanceStatementVO.toString()); BigDecimal historicalBalance = shopBalanceStatementVO.getHistoricalBalance(); BigDecimal balance = shopBalanceStatementVO.getBalance(); if (historicalBalance != null && balance != null) { @@ -244,7 +249,16 @@ public List<GoodsVO> getGoodsListByShopId(PageInfo<GoodsVO> pageInfo, Integer shopId) { //查询该门店商品 List<GoodsVO> goods = shopMapper.selectListByShopId(pageInfo, shopId); - for (GoodsVO good : goods) { + if(null == goods){ + return null; + } + // 根据id去重 + List<GoodsVO> distinctGoods = goods.stream() + .collect(Collectors.collectingAndThen( + Collectors.toMap(GoodsVO::getGoodsId, Function.identity(), (existing, replacement) -> existing), + map -> new ArrayList<>(map.values()) + )); + for (GoodsVO good : distinctGoods) { //价格 Price price = getPrice( good.getGoodsId()); if(null != price){ @@ -258,7 +272,7 @@ Integer data = orderClient.getGoodsSaleNum(good.getGoodsId(), 1).getData(); good.setSaleNum(data); } - return goods; + return distinctGoods; } @Override @@ -277,10 +291,15 @@ goodsVO.setGoodsId(goods.getId()); goodsVO.setGoodsName(goods.getName()); + //商品活动前售价(编辑商品回显) + goodsVO.setEditPrice(goods.getSellingPrice()); + //限购数量(编辑商品回显) + goodsVO.setEditNum(goods.getPurchaseLimit()); + //计算所需价格和积分 Price price = getPrice( goods.getId()); if(null != price){ - //秒杀活动 + //在秒杀活动时间段内 goodsVO.setSellingPrice(price.getCash()); goodsVO.setIntegral(price.getPoint()); goodsVO.setStartTime(price.getStartTime()); @@ -294,15 +313,41 @@ GoodsShop goodsShop = goodsShopMapper.selectOne(new LambdaQueryWrapper<GoodsShop>() .eq(GoodsShop::getGoodsId, goodsId)); Shop shop1 = shopMapper.selectById(goodsShop.getShopId()); - ArrayList<Shop> shops = new ArrayList<>(); - shops.add(shop1); - goodsVO.setShopList(shops); + goodsVO.setShop(shop1); //已售数量 Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData(); goodsVO.setSaleNum(integer); + //分类id + goodsVO.setGoodsCategoryId(goods.getGoodsCategoryId()); + + //一个商品只有一个秒杀活动 + SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>() + .eq(SeckillActivityInfo::getGoodId, goodsId) + .eq(SeckillActivityInfo::getIsShelves,1) + .eq(SeckillActivityInfo::getDelFlag, 0)); + //商品是否开启秒杀活动 + goodsVO.setIsSkillActivity(0); + if (seckillActivityInfo != null) { + goodsVO.setIsSkillActivity(1); + //活动限购数量 + goodsVO.setEditActivityNum(seckillActivityInfo.getMaxNum()); + GoodsSeckill one = goodsSeckillService.getOne(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); + //有秒杀活动,查看秒杀价格 + goodsVO.setEditActivityPrice(one.getSellingPrice()); + } + + //商品评价 + GoodsEvaluate goodsEvaluateOne = goodsEvaluateMapper.getGoodsEvaluateOne(goods.getId()); + if(goodsEvaluateOne != null){ + AppUser appUserById = appUserClient.getAppUserById(goodsEvaluateOne.getAppUserId()); + goodsEvaluateOne.setUserName(appUserById.getName()); + goodsEvaluateOne.setAvatar(appUserById.getAvatar()); + goodsVO.setGoodsEvaluate(goodsEvaluateOne); + } return goodsVO; } + /** * 发布商品 门店后台-商品管理 @@ -325,6 +370,9 @@ goodsShop.setGoodsId(goods.getId()); goodsShop.setShopId(addGoodsDTO.getShopId()); Shop shop = shopMapper.selectById(addGoodsDTO.getShopId()); + if(shop==null){ + throw new ServiceException("门店不存在"); + } goodsShop.setShopName(shop.getName()); goodsShop.setOwnerName(shop.getShopManager()); goodsShop.setPhone(shop.getPhone()); @@ -352,6 +400,87 @@ return goods.getId(); } + + /** + * 编辑商品 + * @param addGoodsDTO + * @return + */ + + @Override + public Integer editGoodsByShop(AddGoodsDTO addGoodsDTO) { + if(addGoodsDTO.getPurchaseLimit()==null){ + addGoodsDTO.setPurchaseLimit(-1); + } + //先修改商品 + Goods goods = new Goods(); + BeanUtils.copyProperties(addGoodsDTO, goods); + goods.setStatus(GoodsStatus.DOWN.getCode());//下架状态 + goods.setId(addGoodsDTO.getGoodId()); + goods.setIntegral(getPoint(addGoodsDTO.getSellingPrice()));//积分 + goods.setDelFlag(0); + goods.setCreateTime(LocalDateTime.now()); + goodsService.updateById(goods);//添加商品 + + + //门店关系不变 + + //判断是否参加秒杀活动 + if (addGoodsDTO.getIsActivity()==1){//参加 + //一个商品只有一个秒杀活动 + SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>() + .eq(SeckillActivityInfo::getGoodId, addGoodsDTO.getGoodId()) + .eq(SeckillActivityInfo::getDelFlag, 0)); + if (seckillActivityInfo != null) { + //删除原本活动 + goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); + //删除主表 + seckillActivityInfoService.removeById(seckillActivityInfo.getId()); + } + //新增 + //秒杀活动 + SeckillActivityInfo seckillActivityInfo1 = new SeckillActivityInfo(); + seckillActivityInfo1.setDelFlag(0); + seckillActivityInfo1.setCreateTime(LocalDateTime.now()); + seckillActivityInfo1.setGoodId(goods.getId()); + seckillActivityInfo1.setMaxNum(addGoodsDTO.getMaxNum()); + seckillActivityInfo1.setStartTime(addGoodsDTO.getStartTime()); + seckillActivityInfo1.setEndTime(addGoodsDTO.getEndTime()); + seckillActivityInfo1.setIsShelves(1);//默认上架 + seckillActivityInfoService.save(seckillActivityInfo1); + //秒杀活动价格 + GoodsSeckill goodsSeckill = new GoodsSeckill(); + goodsSeckill.setSellingPrice(addGoodsDTO.getActivityPrice()); + goodsSeckill.setIntegral(getPoint(addGoodsDTO.getActivityPrice())); + goodsSeckill.setSeckillActivityInfoId(seckillActivityInfo1.getId()); + goodsSeckillService.save(goodsSeckill); + }else{ + //不参加秒杀活动,删除之前的活动 + //一个商品只有一个秒杀活动 + SeckillActivityInfo seckillActivityInfo = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>() + .eq(SeckillActivityInfo::getGoodId, addGoodsDTO.getGoodId()) + .eq(SeckillActivityInfo::getDelFlag, 0)); + if (seckillActivityInfo != null) { + //删除原本活动 + goodsSeckillService.remove(new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getSeckillActivityInfoId, seckillActivityInfo.getId())); + //删除主表 + seckillActivityInfoService.removeById(seckillActivityInfo.getId()); + } + } + return goods.getId(); + } + + @Override + public PageInfo<ShopBalanceListVO> getBalanceList(String name, Integer pageCurr, Integer pageSize) { + PageInfo<ShopBalanceListVO> pageInfo = new PageInfo<>(pageCurr, pageSize); + + List<ShopBalanceListVO> list = shopMapper.getBalanceList(pageInfo,name); + + + pageInfo.setRecords(list); + return pageInfo; + } + /** * 获取商品当前的价格,就是看当前商品是否在秒杀活动中 */ -- Gitblit v1.7.1