|
|
@@ -17,6 +17,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -39,47 +40,60 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
@Override
|
|
|
public List<RenewalView> getMyTicket(long userId) {
|
|
|
User u = userMapper.selectById(userId);
|
|
|
+ Long otherUserId = getOtherUserId(u);
|
|
|
+ List<Long> userIdList = new ArrayList<>(2);
|
|
|
+ userIdList.add(u.getId());
|
|
|
+ if (otherUserId != null) {
|
|
|
+ userIdList.add(otherUserId);
|
|
|
+ }
|
|
|
+ List<RenewalView> list = beanSearcher.searchAll(RenewalView.class, MapUtils.builder()
|
|
|
+ .field(RenewalView::getUserId, userIdList).op(Operator.InList)
|
|
|
+ .field(RenewalView::getStatus, List.of("validity", "overdue")).op(Operator.InList)
|
|
|
+ .orderBy(RenewalView::getExpiryTime).asc()
|
|
|
+ .build());
|
|
|
+ //过滤邀请制、已失效的车位
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ List<RenewalView> collect = list.stream().filter(ticket -> {
|
|
|
+ if (ticket.getExpiryTime() != null && ticket.getExpiryTime().before(now)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (ticket.getSecondType() == 1) {
|
|
|
+ ticket.setAccount(null);
|
|
|
+ ticket.setPassword(null);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return collect;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Long getOtherUserId(User user) {
|
|
|
+ Long userId = user.getId();
|
|
|
+ //是否是同一个用户
|
|
|
Boolean isPcUser = false;
|
|
|
- if (StrUtil.isNotBlank(u.getLoginPhone())) {
|
|
|
+ if (StrUtil.isNotBlank(user.getLoginPhone())) {
|
|
|
isPcUser = true;
|
|
|
}
|
|
|
//是否绑定过手机号
|
|
|
LambdaQueryWrapper<UserBindPhone> wrapper = Wrappers.lambdaQuery(UserBindPhone.class).last("limit 1");
|
|
|
if (isPcUser) {
|
|
|
- wrapper.eq(UserBindPhone::getPhone, u.getLoginPhone());
|
|
|
+ wrapper.eq(UserBindPhone::getPhone, user.getLoginPhone());
|
|
|
} else {
|
|
|
wrapper.eq(UserBindPhone::getUserId, userId);
|
|
|
}
|
|
|
UserBindPhone userBindPhone = userBindPhoneMapper.selectOne(wrapper);
|
|
|
- Long otherUserId = 0l;
|
|
|
+ Long otherUserId = null;
|
|
|
if (userBindPhone != null) {
|
|
|
if (isPcUser) {
|
|
|
otherUserId = userBindPhone.getUserId();
|
|
|
}else {
|
|
|
- User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
+ User otherUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
.eq(User::getLoginPhone, userBindPhone.getPhone()).last("limit 1"));
|
|
|
if (user != null) {
|
|
|
- otherUserId = user.getId();
|
|
|
+ otherUserId = otherUser.getId();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<RenewalView> list = beanSearcher.searchAll(RenewalView.class, MapUtils.builder()
|
|
|
- .field(RenewalView::getUserId, userId, otherUserId).op(Operator.InList)
|
|
|
- .field(RenewalView::getStatus, List.of("validity", "overdue")).op(Operator.InList)
|
|
|
- .orderBy(RenewalView::getExpiryTime).asc()
|
|
|
- .build());
|
|
|
- //过滤邀请制、已失效的车位
|
|
|
- DateTime now = DateTime.now();
|
|
|
- List<RenewalView> collect = list.stream().filter(ticket -> {
|
|
|
- if (ticket.getExpiryTime() != null && ticket.getExpiryTime().before(now)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (ticket.getSecondType() == 1) {
|
|
|
- ticket.setAccount(null);
|
|
|
- ticket.setPassword(null);
|
|
|
- }
|
|
|
- return true;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- return collect;
|
|
|
+ return otherUserId;
|
|
|
}
|
|
|
}
|