From 2f1c95401ffa3254931ffc3e17de259976b8210f Mon Sep 17 00:00:00 2001 From: xm <1350250847@qq.com> Date: Sat, 30 May 2026 17:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E8=82=A1?= =?UTF-8?q?=E4=B8=9C=E5=88=86=E7=BA=A2=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ShopGoodsProfitServiceImpl.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java index 4af3ae4..4f81a43 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ShopGoodsProfitServiceImpl.java @@ -2,6 +2,7 @@ package com.gxwebsoft.shop.service.impl; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gxwebsoft.common.core.exception.BusinessException; import com.gxwebsoft.common.core.exception.enums.GlobalErrorCodeConstants; @@ -25,6 +26,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -52,10 +54,8 @@ public class ShopGoodsProfitServiceImpl extends ServiceImpl shopDealerUserList = shopDealerUserMapper.selectList(new LambdaQueryWrapper().in(ShopDealerUser::getUserId, userIdList)); List shopGoodsProfitVOS = BeanUtil.copyToList(list, ShopGoodsProfitVO.class); for(ShopGoodsProfitVO shopGoodsProfitVO : shopGoodsProfitVOS){ - ShopDealerUser dealerUser = shopDealerUserList.stream().filter(shopDealerUser -> shopGoodsProfitVO.getUserId().equals(shopDealerUser.getUserId())).findFirst().orElse(null); - if(dealerUser != null){ - shopGoodsProfitVO.setUserName(dealerUser.getRealName()); - } + shopDealerUserList.stream().filter(shopDealerUser -> shopGoodsProfitVO.getUserId().equals(shopDealerUser.getUserId())).findFirst() + .ifPresent(shopDealerUser -> shopGoodsProfitVO.setUserName(shopDealerUser.getRealName())); } return shopGoodsProfitVOS; } @@ -88,7 +88,16 @@ public class ShopGoodsProfitServiceImpl extends ServiceImpl> userMap = itemList.stream().collect(Collectors.groupingBy(ShopGoodsProfitUpdateItemDto::getUserId)).entrySet().stream() + .filter(entry -> entry.getValue().size() > 1).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + if(!userMap.isEmpty()){ + String userIds = String.join(",", userMap.keySet().stream().map(String::valueOf).toList()); + + throw new BusinessException("用户:【" + userIds + "】存在多条分红数据,请修改后重新提交!"); + } + + //3.查询商品原有分润数据并做超100%管控 ShopGoods shopGoods = shopGoodsMapper.selectById(entity.getGoodsId()); if(shopGoods == null){ throw new BusinessException(GlobalErrorCodeConstants.NOT_FOUND.getMsg()); @@ -102,10 +111,10 @@ public class ShopGoodsProfitServiceImpl extends ServiceImpl shopGoodsProfits = BeanUtil.copyToList(itemList, ShopGoodsProfit.class); shopGoodsProfits.forEach(shopGoodsProfit -> { shopGoodsProfit.setType(entity.getType()); @@ -122,16 +131,9 @@ public class ShopGoodsProfitServiceImpl extends ServiceImpl profitList = lambdaQuery().select(ShopGoodsProfit::getId).eq(ShopGoodsProfit::getGoodsId, goodsId).eq(ShopGoodsProfit::getType, type).list(); - if(CollectionUtils.isNotEmpty(profitList)){ - profitList.forEach(profit -> { - profit.setDeleted(1); - profit.setUpdater(userId); - profit.setUpdateTime(date); - }); - updateBatchById(profitList); - } + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper().eq(ShopGoodsProfit::getGoodsId, goodsId).eq(ShopGoodsProfit::getType, type) + .set(ShopGoodsProfit::getUpdater, userId).set(ShopGoodsProfit::getUpdateTime, date).set(ShopGoodsProfit::getDeleted, 1); + update(updateWrapper); } - }