|
|
@@ -33,26 +33,26 @@ import static java.time.temporal.ChronoUnit.DAYS;
|
|
|
@Slf4j
|
|
|
public class MapService {
|
|
|
@Autowired
|
|
|
- private CityRepository cityRepository;
|
|
|
+ private CityRepository cityRepository;
|
|
|
@Autowired
|
|
|
- private UserJourneyRepository userJourneyRepository;
|
|
|
+ private UserJourneyRepository userJourneyRepository;
|
|
|
@Autowired
|
|
|
private JourneyStageRepository journeyStageRepository;
|
|
|
@Autowired
|
|
|
- private UserInfoRepository userInfoRepository;
|
|
|
+ private UserInfoRepository userInfoRepository;
|
|
|
@Autowired
|
|
|
- private StageAwardRepository stageAwardRepository;
|
|
|
+ private StageAwardRepository stageAwardRepository;
|
|
|
@Value("${aliyun.oss_domain}")
|
|
|
- private String ossDomain;
|
|
|
+ private String ossDomain;
|
|
|
|
|
|
public List<City> citiesInRegion(MapRegion mapRegion) {
|
|
|
Specification<City> specification = (Specification<City>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
return criteriaBuilder.and(criteriaBuilder.between(root.get("longitude"),
|
|
|
- mapRegion.getSouthwest().getLongitude(),
|
|
|
- mapRegion.getNortheast().getLongitude()),
|
|
|
- criteriaBuilder.between(root.get("latitude"),
|
|
|
- mapRegion.getSouthwest().getLatitude(),
|
|
|
- mapRegion.getNortheast().getLatitude()));
|
|
|
+ mapRegion.getSouthwest().getLongitude(),
|
|
|
+ mapRegion.getNortheast().getLongitude()),
|
|
|
+ criteriaBuilder.between(root.get("latitude"),
|
|
|
+ mapRegion.getSouthwest().getLatitude(),
|
|
|
+ mapRegion.getNortheast().getLatitude()));
|
|
|
};
|
|
|
return cityRepository.findAll(specification);
|
|
|
}
|
|
|
@@ -74,7 +74,7 @@ public class MapService {
|
|
|
southwest.setLongitude(southwest.getLongitude() - dLng);
|
|
|
|
|
|
List<UserMarker> list = userInfoRepository.findInRegion(userId, mapRegion.getSouthwest().getLatitude(), mapRegion.getSouthwest().getLongitude(),
|
|
|
- mapRegion.getNortheast().getLongitude(), mapRegion.getNortheast().getLongitude(), PageRequest.of(0, 50));
|
|
|
+ mapRegion.getNortheast().getLongitude(), mapRegion.getNortheast().getLongitude(), PageRequest.of(0, 50));
|
|
|
for (UserMarker userMarker : list) {
|
|
|
userMarker.setIcon(userMarker.getUserIcon());
|
|
|
JourneyStage journeyStage = journeyStageRepository.findFirstByUserIdOrderByCreatedAtDesc(userMarker.getUserId()).orElse(null);
|
|
|
@@ -82,9 +82,9 @@ public class MapService {
|
|
|
List<StageAward> stageAwards = stageAwardRepository.findAllByUserIdAndNeedProgressLessThanAndReceivedEquals(userMarker.getUserId(), journeyStage.getProgress(), false);
|
|
|
userMarker.setCanSteal(stageAwards.stream()
|
|
|
.anyMatch(stageAward -> (stageAward.getArrival() ? stageAward.getReceiveRecords().size() < 10 : stageAward.getReceiveRecords().size() < 3)
|
|
|
- && stageAward.getReceiveRecords().stream()
|
|
|
- .noneMatch(stageAwardRecord -> stageAwardRecord.getUserId().equals(userId))
|
|
|
- && stageAward.getCoin().compareTo(BigDecimal.valueOf(0.01)) > 0));
|
|
|
+ && stageAward.getReceiveRecords().stream()
|
|
|
+ .noneMatch(stageAwardRecord -> stageAwardRecord.getUserId().equals(userId))
|
|
|
+ && stageAward.getCoin().compareTo(BigDecimal.valueOf(0.01)) > 0));
|
|
|
} else {
|
|
|
userMarker.setCanSteal(false);
|
|
|
}
|
|
|
@@ -132,14 +132,14 @@ public class MapService {
|
|
|
userMap.setNearOrigin(latestStage.getOrigin());
|
|
|
userMap.setProgress(latestStage.getProgress());
|
|
|
userMap.setCurrentSteps(latestStage.getCurrentSteps());
|
|
|
- List<StageAward> stageAwards = stageAwardRepository.findAllByUserIdAndReceivedFalse(userId);
|
|
|
+ List<StageAward> stageAwards = stageAwardRepository.findUserStageAward(userId, latestStage.getId());
|
|
|
if (!userId.equals(SecurityUtils.getAuthenticatedUser().getId())) {
|
|
|
stageAwards = stageAwards.stream()
|
|
|
.filter(stageAward -> stageAward.getCoin().compareTo(BigDecimal.valueOf(0.01)) > 0
|
|
|
- && stageAward.getReceiveRecords().size() < 3
|
|
|
- && stageAward.getReceiveRecords()
|
|
|
- .stream()
|
|
|
- .noneMatch(stageAwardRecord -> stageAwardRecord.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())))
|
|
|
+ && stageAward.getReceiveRecords().size() < 3
|
|
|
+ && stageAward.getReceiveRecords()
|
|
|
+ .stream()
|
|
|
+ .noneMatch(stageAwardRecord -> stageAwardRecord.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
for (StageAward stageAward : stageAwards) {
|
|
|
@@ -445,7 +445,7 @@ public class MapService {
|
|
|
private double lineSpace(double x1, double y1, double x2, double y2) {
|
|
|
double lineLength = 0;
|
|
|
lineLength = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2)
|
|
|
- * (y1 - y2));
|
|
|
+ * (y1 - y2));
|
|
|
return lineLength;
|
|
|
}
|
|
|
}
|