zoujiajian 11 ay önce
ebeveyn
işleme
1a5a86f625

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/model/views/NanoUserQuotaInfoView.java

@@ -63,4 +63,6 @@ public class NanoUserQuotaInfoView {
 	 * 最后使用日期
 	 */
 	private Date lastUsedDate;
+
+	private Boolean isVip;
 }

+ 27 - 2
netflix-service/src/main/java/com/cyksj/service/nano/impl/NanoServiceImpl.java

@@ -1,16 +1,24 @@
 package com.cyksj.service.nano.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.common.constant.Constant;
 import com.cyksj.mapper.GroupsMapper;
 import com.cyksj.mapper.GroupsRelationMapper;
 import com.cyksj.mapper.NanoUserQuotaMapper;
+import com.cyksj.mapper.vip.VipUserMapper;
 import com.cyksj.model.entity.GroupsRelation;
 import com.cyksj.model.entity.GroupsTrips;
 import com.cyksj.model.entity.NanoUserQuota;
+import com.cyksj.model.entity.VipUser;
+import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.views.NanoUserQuotaInfoView;
 import com.cyksj.service.nano.NanoService;
 import com.cyksj.service.user.UserBindRelationService;
+import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.param.Operator;
+import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
@@ -29,14 +37,31 @@ public class NanoServiceImpl implements NanoService {
 	private final GroupsRelationMapper groupsRelationMapper;
 
 	private final GroupsMapper groupsMapper;
+
+	private final VipUserMapper vipUserMapper;
+
+	private final BeanSearcher beanSearcher;
 	@Override
 	public NanoUserQuotaInfoView getUserSubsInfo(long userId) {
 		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
-		NanoUserQuota nanoUserQuota = nanoUserQuotaMapper.selectOne(Wrappers.lambdaQuery(NanoUserQuota.class).in(NanoUserQuota::getUid, userIdList).last("limit 1"));
+		VipUser vipUser = vipUserMapper.selectOne(Wrappers.lambdaQuery(VipUser.class).in(VipUser::getUserId, userIdList).gt(VipUser::getExpiryTime, DateTime.now()));
+		Boolean isVip = vipUser != null;
+		NanoUserQuota nanoUserQuota;
+		if (isVip) {
+			GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
+					.field(GroupsRelationView::getIsVip, Boolean.TRUE)
+					.field(GroupsRelationView::getUserId, userIdList).op(Operator.InList)
+					.field(GroupsRelationView::getGoodsId, Constant.NANO_GOODS_ID)
+					.build());
+			nanoUserQuota = nanoUserQuotaMapper.selectOne(Wrappers.lambdaQuery(NanoUserQuota.class).eq(NanoUserQuota::getRelationId, groupsRelationView.getId()).last("limit 1"));
+		} else {
+			nanoUserQuota = nanoUserQuotaMapper.selectOne(Wrappers.lambdaQuery(NanoUserQuota.class).in(NanoUserQuota::getUid, userIdList).last("limit 1"));
+		}
 		if (nanoUserQuota != null) {
+			NanoUserQuotaInfoView nanoUserQuotaInfoView = new NanoUserQuotaInfoView();
+			nanoUserQuotaInfoView.setIsVip(vipUser != null);
 			GroupsRelation relation = groupsRelationMapper.selectById(nanoUserQuota.getRelationId());
 			GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
-			NanoUserQuotaInfoView nanoUserQuotaInfoView = new NanoUserQuotaInfoView();
 			BeanUtil.copyProperties(nanoUserQuota, nanoUserQuotaInfoView);
 			nanoUserQuotaInfoView.setSkuId(groupsTrips.getSkuId());
 			return nanoUserQuotaInfoView;