|
|
|
@ -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<UserListRightByOperatorVo> 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<RewardConfig> 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<RewardConfig> 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); |
|
|
|
|