Browse Source

change freevip impl

master
gsd 2 years ago
parent
commit
a20c5a0570
  1. 18
      src/main/java/app/services/db/FreeVIPService.java

18
src/main/java/app/services/db/FreeVIPService.java

@ -60,9 +60,15 @@ public class FreeVIPService {
}
}
public Map<Integer, Long> addFreeVIP(SteamID steamID, SocialAuth socialAuth) {
public Long addFreeVIP(SteamID steamID, SocialAuth socialAuth) {
/*
0 - права уже есть
1 - права выданы
> 1 - стоит подождать пока можно получить новые
< 0 - недостаточно наиграно на сервере времени
*/
//1.имеются ли уже права
if (permitionService.getPermition(steamID) != null) return Map.of(1, 0L);
if (permitionService.getPermition(steamID) != null) return 0L;
long current_server_time = getDBServerUTime();
long timeout = 60 * 60 * 24 * 30;
long need_usertime = 60 * 60 * 24 * 2;
@ -70,13 +76,13 @@ public class FreeVIPService {
long last_free_vip_gived = getLastGivedFreeVIP(socialAuth);
if (last_free_vip_gived != 0L && current_server_time - last_free_vip_gived < timeout) {
//2.Права из под социального аккаунта уже имеются
return Map.of(2, timeout - (current_server_time - last_free_vip_gived));
return timeout - (current_server_time - last_free_vip_gived);
}
////////////////////////////////////////////////////////////////
last_free_vip_gived = getLastGivedFreeVIP(steamID);
if (last_free_vip_gived != 0L && current_server_time - last_free_vip_gived < timeout) {
//3.Права из под steam аккаунта уже имеются
return Map.of(3, timeout - (current_server_time - last_free_vip_gived));
return timeout - (current_server_time - last_free_vip_gived);
}
////////////////////////////////////////////////////////////////
BigDecimal total_usertime = BigDecimal.valueOf(0);
@ -87,9 +93,9 @@ public class FreeVIPService {
}
if (total_usertime.longValue() < need_usertime) {
//4.недостаточно наиграл
return Map.of(4, need_usertime - total_usertime.longValue());
return -1 * (need_usertime - total_usertime.longValue());
}
permitionService.addFreeVIP(steamID, 86400);
return Map.of(0, 0L);
return 1L;
}
}

Loading…
Cancel
Save