|
@@ -1,16 +1,24 @@
|
|
|
package com.cyksj.service.nano.impl;
|
|
package com.cyksj.service.nano.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.mapper.GroupsMapper;
|
|
import com.cyksj.mapper.GroupsMapper;
|
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
import com.cyksj.mapper.NanoUserQuotaMapper;
|
|
import com.cyksj.mapper.NanoUserQuotaMapper;
|
|
|
|
|
+import com.cyksj.mapper.vip.VipUserMapper;
|
|
|
import com.cyksj.model.entity.GroupsRelation;
|
|
import com.cyksj.model.entity.GroupsRelation;
|
|
|
import com.cyksj.model.entity.GroupsTrips;
|
|
import com.cyksj.model.entity.GroupsTrips;
|
|
|
import com.cyksj.model.entity.NanoUserQuota;
|
|
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.model.views.NanoUserQuotaInfoView;
|
|
|
import com.cyksj.service.nano.NanoService;
|
|
import com.cyksj.service.nano.NanoService;
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
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 lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -29,14 +37,31 @@ public class NanoServiceImpl implements NanoService {
|
|
|
private final GroupsRelationMapper groupsRelationMapper;
|
|
private final GroupsRelationMapper groupsRelationMapper;
|
|
|
|
|
|
|
|
private final GroupsMapper groupsMapper;
|
|
private final GroupsMapper groupsMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final VipUserMapper vipUserMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final BeanSearcher beanSearcher;
|
|
|
@Override
|
|
@Override
|
|
|
public NanoUserQuotaInfoView getUserSubsInfo(long userId) {
|
|
public NanoUserQuotaInfoView getUserSubsInfo(long userId) {
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
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) {
|
|
if (nanoUserQuota != null) {
|
|
|
|
|
+ NanoUserQuotaInfoView nanoUserQuotaInfoView = new NanoUserQuotaInfoView();
|
|
|
|
|
+ nanoUserQuotaInfoView.setIsVip(vipUser != null);
|
|
|
GroupsRelation relation = groupsRelationMapper.selectById(nanoUserQuota.getRelationId());
|
|
GroupsRelation relation = groupsRelationMapper.selectById(nanoUserQuota.getRelationId());
|
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
|
|
|
- NanoUserQuotaInfoView nanoUserQuotaInfoView = new NanoUserQuotaInfoView();
|
|
|
|
|
BeanUtil.copyProperties(nanoUserQuota, nanoUserQuotaInfoView);
|
|
BeanUtil.copyProperties(nanoUserQuota, nanoUserQuotaInfoView);
|
|
|
nanoUserQuotaInfoView.setSkuId(groupsTrips.getSkuId());
|
|
nanoUserQuotaInfoView.setSkuId(groupsTrips.getSkuId());
|
|
|
return nanoUserQuotaInfoView;
|
|
return nanoUserQuotaInfoView;
|