|
|
@@ -3,10 +3,7 @@ package com.izouma.walkchina.service;
|
|
|
import com.github.kevinsawicki.http.HttpRequest;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.izouma.walkchina.constant.AppConstants;
|
|
|
-import com.izouma.walkchina.domain.City;
|
|
|
-import com.izouma.walkchina.domain.JourneyStage;
|
|
|
-import com.izouma.walkchina.domain.UserInfo;
|
|
|
-import com.izouma.walkchina.domain.UserJourney;
|
|
|
+import com.izouma.walkchina.domain.*;
|
|
|
import com.izouma.walkchina.dto.Location;
|
|
|
import com.izouma.walkchina.dto.MapRegion;
|
|
|
import com.izouma.walkchina.dto.UserMap;
|
|
|
@@ -27,6 +24,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Predicate;
|
|
|
|
|
|
import static java.time.temporal.ChronoUnit.DAYS;
|
|
|
|
|
|
@@ -73,8 +71,8 @@ public class MapService {
|
|
|
|
|
|
northeast.setLatitude(northeast.getLatitude() - dLat);
|
|
|
northeast.setLongitude(northeast.getLongitude() - dLng);
|
|
|
- southwest.setLatitude(northeast.getLatitude() - dLat);
|
|
|
- southwest.setLongitude(northeast.getLongitude() - dLng);
|
|
|
+ southwest.setLatitude(southwest.getLatitude() - dLat);
|
|
|
+ southwest.setLongitude(southwest.getLongitude() - dLng);
|
|
|
|
|
|
List<UserMarker> list = userInfoRepository.findInRegion(userId, mapRegion.getSouthwest().getLatitude(), mapRegion.getSouthwest().getLongitude(),
|
|
|
mapRegion.getNortheast().getLongitude(), mapRegion.getNortheast().getLongitude());
|
|
|
@@ -82,7 +80,18 @@ public class MapService {
|
|
|
userMarker.setIcon(ossDomain + "/marker/user/" + userMarker.getUserId() + ".png");
|
|
|
JourneyStage journeyStage = journeyStageRepository.findFirstByUserIdOrderByCreatedAtDesc(userMarker.getUserId()).orElse(null);
|
|
|
if (journeyStage != null) {
|
|
|
- userMarker.setCanSteal(stageAwardRepository.countAllByUserIdAndNeedProgressLessThanAndReceivedEquals(userMarker.getUserId(), journeyStage.getProgress(), false) > 0);
|
|
|
+ List<StageAward> stageAwards = stageAwardRepository.findAllByUserIdAndNeedProgressLessThanAndReceivedEquals(userMarker.getUserId(), journeyStage.getProgress(), false);
|
|
|
+ userMarker.setCanSteal(stageAwards.stream().anyMatch(new Predicate<StageAward>() {
|
|
|
+ @Override
|
|
|
+ public boolean test(StageAward stageAward) {
|
|
|
+ return (stageAward.getArrival() ? stageAward.getReceiveRecords().size() < 10 : stageAward.getReceiveRecords().size() < 3) && stageAward.getReceiveRecords().stream().noneMatch(new Predicate<StageAwardRecord>() {
|
|
|
+ @Override
|
|
|
+ public boolean test(StageAwardRecord stageAwardRecord) {
|
|
|
+ return stageAwardRecord.getUserId().equals(userId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }));
|
|
|
} else {
|
|
|
userMarker.setCanSteal(false);
|
|
|
}
|