From 6e3fcdbde6ad62832753ddc8d3e1429f29ea58ee Mon Sep 17 00:00:00 2001 From: Administrator <15274802129@163.com> Date: Mon, 28 Apr 2025 17:31:42 +0800 Subject: [PATCH] refactor(mall): 优化活动报名相关功能 --- src/main/java/cc/mrbird/febs/mall/service/impl/HappyActivityServiceImpl.java | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/HappyActivityServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/HappyActivityServiceImpl.java index 7b36573..b2d0db8 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/HappyActivityServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/HappyActivityServiceImpl.java @@ -415,6 +415,7 @@ new LambdaQueryWrapper<HappyActivityConnect>() .eq(HappyActivityConnect::getMemberId, memberId) .eq(HappyActivityConnect::getName, dto.getName()) + .eq(HappyActivityConnect::getPhone, dto.getPhone()) ); if(CollUtil.isNotEmpty(happyActivityConnects)){ throw new FebsException("已经添加过该联系人"); @@ -504,6 +505,24 @@ } Long activityId = dto.getActivityId(); + + List<HappyActivityOrderItem> happyActivityOrderItems = happyActivityOrderItemMapper.selectList( + new LambdaQueryWrapper<HappyActivityOrderItem>() + .eq(HappyActivityOrderItem::getActivityId, activityId) + .in(HappyActivityOrderItem::getConnectId, connectIds) + ); + if(CollUtil.isNotEmpty(happyActivityOrderItems)){ + //stream流操作happyActivityOrderItems,返回一个orderId的Set集合 + Set<Long> orderIdSet = happyActivityOrderItems.stream().map(HappyActivityOrderItem::getOrderId).collect(Collectors.toSet()); + List<HappyActivityOrder> happyActivityOrders = happyActivityOrderMapper.selectList( + new LambdaQueryWrapper<HappyActivityOrder>() + .in(HappyActivityOrder::getId, orderIdSet) + .in(HappyActivityOrder::getState, Arrays.asList(StateUpDownEnum.ORDER_STATE_WAIT_PAY.getCode(),StateUpDownEnum.ORDER_STATE_WAIT_USE.getCode())) + ); + if(CollUtil.isNotEmpty(happyActivityOrders)){ + throw new FebsException("有报名人重复报名了活动,请重新选择"); + } + } HappyActivity happyActivity = this.baseMapper.selectById(activityId); if (ObjectUtil.isEmpty(happyActivity)) { throw new FebsException("活动不存在"); -- Gitblit v1.9.1