From 63b4f6147d7b1cf99662a9a1297e4efaebb533b4 Mon Sep 17 00:00:00 2001 From: PQZ Date: Mon, 31 Mar 2025 17:50:36 +0800 Subject: [PATCH] 1 --- .../member/service/IMemberCardService.java | 20 +++++++++--- .../member/service/IMemberRightsService.java | 11 ++++++- .../service/impl/MemberCardServiceImpl.java | 30 ++++++++++++++++++ .../service/impl/MemberRightsServiceImpl.java | 31 +++++++++++++++++++ .../service/impl/MemberUserServiceImpl.java | 6 ++-- 5 files changed, 90 insertions(+), 8 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberCardService.java b/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberCardService.java index 3a5d799..be1d4d3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberCardService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberCardService.java @@ -39,11 +39,23 @@ public interface IMemberCardService extends IService { /** * 查当前会员权益列表 + * + * @param userType 用户类型 + * @param userId 用户id * @author vinjor-M * @date 11:26 2025/3/26 - * @param userType 用户类型 - * @param userId 用户id - **/ - Map> selectMemberRights(Long userId, String userType); + **/ + Map> selectMemberRights(Long userId, String userType); + + /** + * 获取报名次数 + * + * @param userId 用户id + * @param userType 类型 + * @return java.lang.Integer + * @author PQZ + * @date 17:27 2025/3/31 + **/ + Integer getCardReport(Long userId, String userType); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberRightsService.java b/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberRightsService.java index 462355f..6c7eadc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberRightsService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/member/service/IMemberRightsService.java @@ -23,5 +23,14 @@ public interface IMemberRightsService extends IService { * @author PQZ * @date 15:45 2025/3/27 **/ - void dealRights(Long userId, String userType,List rights); + void dealRights(Long userId, String userType, List rights); + + /** + * @param userId 用户id + * @param carId 卡id + * @return java.lang.Integer + * @author PQZ + * @date 17:15 2025/3/31 + **/ + Integer getReport(Long userId, String carId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberCardServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberCardServiceImpl.java index f3b8e3f..fd6c179 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberCardServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberCardServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.base.domain.BaseCard; import com.ruoyi.base.service.IBaseCardService; import com.ruoyi.base.vo.BaseCardVO; +import com.ruoyi.common.config.DlRightsConfig; import com.ruoyi.common.core.domain.DlBaseEntity; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.constant.DictConstants; @@ -202,6 +203,35 @@ public class MemberCardServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper + .eq(MemberCard::getUserType, userType) + .eq(MemberCard::getUserId, userId) + .eq(DlBaseEntity::getDelFlag, 0) + .lt(MemberCard::getStartDate, time) + .ge(MemberCard::getEndDate, time) + .orderByDesc(DlBaseEntity::getCreateTime); + List memberCards = list(lambdaQueryWrapper); + if (memberCards.isEmpty()) { + return 0; + } else { + return rightsService.getReport(memberCards.get(0).getUserId(),memberCards.get(0).getCardId()); + } + } + /** * @param memberRightsMap 会员权益map * @param item 这个权益 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberRightsServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberRightsServiceImpl.java index a048e58..cf9c0ff 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberRightsServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberRightsServiceImpl.java @@ -1,7 +1,9 @@ package com.ruoyi.member.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.base.vo.CardRightsVO; +import com.ruoyi.common.config.DlRightsConfig; import com.ruoyi.member.domain.MemberCard; import com.ruoyi.member.domain.MemberRights; import com.ruoyi.member.mapper.MemberRightsMapper; @@ -11,6 +13,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * 会员权益(定时任务重置剩余值),用户id、会员卡id、权益对应1Service业务层处理 @@ -22,6 +25,8 @@ import java.util.List; public class MemberRightsServiceImpl extends ServiceImpl implements IMemberRightsService { @Autowired private MemberRightsMapper memberRightsMapper; + @Autowired + private DlRightsConfig dlRightsConfig; /** @@ -49,4 +54,30 @@ public class MemberRightsServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper + .eq(MemberRights::getUserId,userId) + .eq(MemberRights::getCardId,cardId); + List rights = list(lambdaQueryWrapper); + if (rights.isEmpty()){ + return dlRightsConfig.getReport(); + } else { + List filterRights = rights.stream() + .filter(item -> "report".equals(item.getRightsCode())) + .collect(Collectors.toList()); + return filterRights.get(0).getRemaining(); + } + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberUserServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberUserServiceImpl.java index 0acdff2..5dcaa63 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberUserServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/member/service/impl/MemberUserServiceImpl.java @@ -103,9 +103,9 @@ public class MemberUserServiceImpl extends ServiceImpl