From 29f74cea061ee8b1beb1069812e859239a035ccf Mon Sep 17 00:00:00 2001 From: Derran Date: Fri, 6 Feb 2026 16:57:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BD=BF=E7=94=A8=E8=81=94?= =?UTF-8?q?=E7=B3=BB=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../right/impl/RightQueryServiceImpl.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/right/impl/RightQueryServiceImpl.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/right/impl/RightQueryServiceImpl.java index b069329..78a8c6b 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/right/impl/RightQueryServiceImpl.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/right/impl/RightQueryServiceImpl.java @@ -18,7 +18,9 @@ import com.qniao.dam.domian.aggregate.right.constant.RightTypeEnum; import com.qniao.dam.domian.aggregate.right.constant.RightUnitEnum; import com.qniao.dam.infrastructure.persistent.dao.domain.RightDao; import com.qniao.dam.infrastructure.persistent.dao.domain.RightTermDao; +import com.qniao.dam.query.ccur.ContactCardUsageRecordQueryService; import com.qniao.dam.query.marriageinformation.MarriageInformationQueryService; +import com.qniao.dam.query.mcur.MatchCardUsageRecordQueryService; import com.qniao.dam.query.pcur.ProfileCardUsageRecordQueryService; import com.qniao.dam.query.rewardconfig.RewardConfigQueryService; import com.qniao.dam.query.right.RightQueryService; @@ -29,7 +31,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.Duration; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.stream.Collectors; @@ -51,6 +55,10 @@ public class RightQueryServiceImpl implements RightQueryService { private MarriageInformationQueryService marriageInformationQueryService; @Resource private ProfileCardUsageRecordQueryService profileCardUsageRecordQueryService; + @Resource + private ContactCardUsageRecordQueryService contactCardUsageRecordQueryService; + @Resource + private MatchCardUsageRecordQueryService matchCardUsageRecordQueryService; @Override public List listRightByOperator(UserListRightByOperatorQueryParam queryParam) { @@ -105,6 +113,7 @@ public class RightQueryServiceImpl implements RightQueryService { UserCardInfoVo matchCardInfo = new UserCardInfoVo(RightTypeEnum.MATCH_CARD, 0); //判断是否会员 Right vipRight = getUserVipInfo(userId, miId); + LocalDateTime startTime = null; if (Objects.nonNull(vipRight)) { if (Objects.equals(vipRight.getType(), RightTypeEnum.VIP)) { List vipRightList = rewardConfigQueryService.listVipRight(); @@ -119,6 +128,13 @@ public class RightQueryServiceImpl implements RightQueryService { matchCardInfo.setQuantity(Integer.valueOf(rewardConfig.getValue())); } } + LocalDate now = LocalDate.now(); + int startDay = now.with(TemporalAdjusters.lastDayOfMonth()).getDayOfMonth(); + startDay = Math.min(vipRight.getStartTime().getDayOfMonth(), startDay); + startTime = LocalDate.of(now.getYear(), now.getMonth(), startDay).atTime(vipRight.getStartTime().toLocalTime()); + if (startTime.isAfter(LocalDateTime.now())) { + startTime = startTime.minusMonths(1); + } } else if (Objects.equals(vipRight.getType(), RightTypeEnum.VIP_TRIAL)) { List vipTrialRightList = rewardConfigQueryService.listVipTrialRight(); for (RewardConfig rewardConfig : vipTrialRightList) { @@ -132,6 +148,7 @@ public class RightQueryServiceImpl implements RightQueryService { matchCardInfo.setQuantity(Integer.valueOf(rewardConfig.getValue())); } } + startTime = vipRight.getStartTime(); } } else { //没有会员判断是否实名认证 @@ -139,7 +156,7 @@ public class RightQueryServiceImpl implements RightQueryService { if (StrUtil.isNotBlank(marriageInformation.getIdentityCard())) { profileCardInfo.setQuantity(20); contactCardInfo.setQuantity(3); - }else{ + } else { profileCardInfo.setQuantity(3); } } @@ -148,6 +165,14 @@ public class RightQueryServiceImpl implements RightQueryService { int usageQuantity = profileCardUsageRecordQueryService.countUsageRecord(userId, CardUsageTypeEnum.FREE); profileCardInfo.setQuantity(profileCardInfo.getQuantity() >= usageQuantity ? profileCardInfo.getQuantity() - usageQuantity : 0); } + if (contactCardInfo.getQuantity() > 0) { + int usageQuantity = contactCardUsageRecordQueryService.countUsageRecord(userId, CardUsageTypeEnum.FREE); + contactCardInfo.setQuantity(contactCardInfo.getQuantity() >= usageQuantity ? contactCardInfo.getQuantity() - usageQuantity : 0); + } + if (matchCardInfo.getQuantity() > 0 && Objects.nonNull(startTime)) { + int usageQuantity = matchCardUsageRecordQueryService.countUsageRecord(userId, CardUsageTypeEnum.FREE, startTime); + matchCardInfo.setQuantity(matchCardInfo.getQuantity() >= usageQuantity ? matchCardInfo.getQuantity() - usageQuantity : 0); + } //查询权益卡数量 int profileCardNum = rightDao.countCardRightNum(userId, miId, RightTypeEnum.PROFILE_CARD);