Browse Source

new pay method

master
gsd 1 year ago
parent
commit
1a1616aa1a
  1. 8
      src/main/java/app/controllers/other/ExternalVIPController.java
  2. 8
      src/main/java/app/controllers/user/ProfileController.java
  3. 3
      src/main/java/app/entities/VipGiveMethod.java
  4. 2
      src/main/java/app/entities/VipPrice.java
  5. 5
      src/main/java/app/entities/db/DonateStat.java
  6. 36
      src/main/java/app/services/ProfileService.java
  7. 19
      src/main/java/app/services/db/DonateService.java
  8. 7
      src/main/java/app/services/db/VIPService.java
  9. 1
      src/main/resources/application.yaml

8
src/main/java/app/controllers/other/ExternalVIPController.java

@ -38,10 +38,10 @@ public class ExternalVIPController {
public void setupPrices() {
prices = new ArrayList<>();
prices.add(new VipPrice("1 Месяц", 200, "1 ключ", "site_content/images/vip/VIP_1_MOUNTH.jpg", "month", true, true));
prices.add(new VipPrice("1 Неделя", 100, "40 рефов", "site_content/images/vip/VIP_7_DAYS.jpg", "week", true, true));
prices.add(new VipPrice("1 День", 35, "10 рефов", "site_content/images/vip/VIP_1_DAY.jpg", "day", true, true));
prices.add(new VipPrice("1 День", 0, "бесплатно", "site_content/images/vip/freevip.jpg", "free", true, true));
prices.add(new VipPrice("1 Месяц", 200, "1 ключ", "site_content/images/vip/VIP_1_MOUNTH.jpg", "month", true, true, true, 10));
prices.add(new VipPrice("1 Неделя", 100, "40 рефов", "site_content/images/vip/VIP_7_DAYS.jpg", "week", true, true, true, 10));
prices.add(new VipPrice("1 День", 35, "10 рефов", "site_content/images/vip/VIP_1_DAY.jpg", "day", true, true, true, 10));
prices.add(new VipPrice("1 День", 0, "бесплатно", "site_content/images/vip/freevip.jpg", "free", true, true, true, 10));
}
@PostMapping

8
src/main/java/app/controllers/user/ProfileController.java

@ -27,6 +27,9 @@ public class ProfileController {
@Value("${backend.vip.buy.qiwi}")
private String QIWI_LINK;
@Value("${backend.vip.buy.donationalerts}")
private String DONATIONALERTS_LINK;
@Autowired
public ProfileController(ProfileService profileService,
FreeVIPService freeVIPService,
@ -105,6 +108,11 @@ public class ProfileController {
return ResponseEntity.status(HttpStatus.FOUND)
.header("Location", String.valueOf(QIWI_LINK).replace("(AMOUNT)", String.valueOf(cost)).replace("(COMMENT)", steam2))
.build();
case "donationalerts":{
return ResponseEntity.status(HttpStatus.FOUND)
.header("Location", DONATIONALERTS_LINK)
.build();
}
default:
return ResponseEntity.status(HttpStatus.FOUND)
.header("Location", "http://www.consultant.ru/document/cons_doc_LAW_6300/4e3d0ddc5edee16d48ad06866de7851fa2a55b3e/")

3
src/main/java/app/entities/VipGiveMethod.java

@ -6,7 +6,8 @@ public enum VipGiveMethod {
QIWI("Qiwi"),
MANUAL("Админ"),
AFTERTIME("Убрана"),
TOTAL("Итого");
TOTAL("Итого"),
DONATIONALERTS("Донейшон Алертс");
String human_name;

2
src/main/java/app/entities/VipPrice.java

@ -13,4 +13,6 @@ public class VipPrice {
String period;
boolean steam = true;
boolean qiwi = true;
boolean donationalerts = true;
int da_percent = 10;
}

5
src/main/java/app/entities/db/DonateStat.java

@ -60,7 +60,7 @@ public class DonateStat {
}
public Integer getRubles() {
if (this.giveMethod == VipGiveMethod.QIWI) return Integer.valueOf(this.reserved.split(";")[0].split("=")[1]);
if (this.giveMethod == VipGiveMethod.QIWI || this.giveMethod == VipGiveMethod.DONATIONALERTS) return Integer.valueOf(this.reserved.split(";")[0].split("=")[1]);
return 0;
}
@ -93,6 +93,9 @@ public class DonateStat {
case AFTERTIME -> {
return "Снята";
}
case DONATIONALERTS -> {
return "Оплачено DonationAlerts: " + getRubles().toString() + " рублей";
}
}
return "Неизвестно";
}

36
src/main/java/app/services/ProfileService.java

@ -204,23 +204,23 @@ public class ProfileService {
});
}
//if(requests.contains("killfeed")){
callables.add(() -> {
try {
long start_time = Instant.now().toEpochMilli();
profile.setKillfeed((new Killfeed())
.setKills(killfeedService.getKills(steamID, null))
.setDeads(killfeedService.getDeads(steamID, null))
.setAssists(killfeedService.getAssists(steamID, null))
.setSuicides(killfeedService.getSuicides(steamID, null)));
long end_time = Instant.now().toEpochMilli() - start_time;
profile.getResponse_time().put("killfeed", (double) end_time / 1000);
} catch (Exception err) {
err.printStackTrace();
}
return null;
});
//}
if(requests.contains("killfeed")){
callables.add(() -> {
try {
long start_time = Instant.now().toEpochMilli();
profile.setKillfeed((new Killfeed())
.setKills(killfeedService.getKills(steamID, null))
.setDeads(killfeedService.getDeads(steamID, null))
.setAssists(killfeedService.getAssists(steamID, null))
.setSuicides(killfeedService.getSuicides(steamID, null)));
long end_time = Instant.now().toEpochMilli() - start_time;
profile.getResponse_time().put("killfeed", (double) end_time / 1000);
} catch (Exception err) {
err.printStackTrace();
}
return null;
});
}
//if(requests.contains("messages")){
callables.add(() -> {
@ -249,7 +249,7 @@ public class ProfileService {
}
public PlayerProfile GetProfile(String steam64) {
return GetProfile(steam64, List.of("steam_data,lastplay,usertime,permition,ban,attached_discord,donates,ban_list".split(",")));
return GetProfile(steam64, List.of("steam_data,lastplay,usertime,permition,ban,attached_discord,donates,ban_list,killfeed".split(",")));
}
public PlayerProfile GetProfile(String steam64, String requests) {

19
src/main/java/app/services/db/DonateService.java

@ -57,6 +57,13 @@ public class DonateService {
(rs, n) -> rs.getInt("k")).stream().findFirst().orElse(0);
}
public Integer getSummaryDonationAlertsDonateValue(StatisticRange statisticRange) {
return jdbcTemplate.query("SELECT SUM(CAST(REPLACE(REPLACE(substring_index(`reserved`,';',1), 'rub=',''), ';','') as INT)) as k " +
"FROM `gived_vip` WHERE `givemethod` = ? AND `timestamp` > CAST(DATE_FORMAT(NOW() ,?) as DATE)",
new Object[]{ VipGiveMethod.DONATIONALERTS.ordinal(), StatisticRange.cast(statisticRange)},
(rs, n) -> rs.getInt("k")).stream().findFirst().orElse(0);
}
//no need if use getGivedVipStatistic
public Long getSummaryGivedFreeVip(StatisticRange statisticRange) {
return jdbcTemplate.query("SELECT COUNT(*) as count FROM `gived_vip` WHERE `givemethod` = ? AND `timestamp` > CAST(DATE_FORMAT(NOW() ,?) as DATE)",
@ -74,6 +81,7 @@ public class DonateService {
map.put("steam", new HashMap<>());
map.put("qiwi", new HashMap<>());
map.put("free", new HashMap<>());
map.put("donationalerts", new HashMap<>());
donateStatistics.forEach(ds -> {
switch (ds.getGiveMethod()) {
case FREE -> map.get("free").put("day", ds.getCount());
@ -91,6 +99,13 @@ public class DonateService {
case 2678400, 2592000 -> map.get("qiwi").put("month", ds.getCount());
}
}
case DONATIONALERTS -> {
switch (ds.getAmount()) {
case 86400 -> map.get("donationalerts").put("day", ds.getCount());
case 604800 -> map.get("donationalerts").put("week", ds.getCount());
case 2678400, 2592000 -> map.get("donationalerts").put("month", ds.getCount());
}
}
}
});
@ -106,12 +121,14 @@ public class DonateService {
public HashMap getDonateStatistic(StatisticRange statisticRange) {
Pair<Integer, Integer> summary_steam = getSummarySteamDonateValue(statisticRange);
Integer summary_qiwi = getSummaryQiwiDonateValue(statisticRange);
Integer summary_da = getSummaryDonationAlertsDonateValue(statisticRange);
HashMap statistic = getGivedVipStatistic(statisticRange);
return new HashMap(
Map.of(
"summary", Map.of(
"steam", Map.of("key", summary_steam.getLeft(), "metal", summary_steam.getRight()),
"qiwi", summary_qiwi),
"qiwi", summary_qiwi,
"donationalerts", summary_da),
"statistic", statistic
)
);

7
src/main/java/app/services/db/VIPService.java

@ -121,6 +121,13 @@ public class VIPService {
publishWebhook(steamID, amount, "Admin", false);
}
}
case DONATIONALERTS -> {
result = permitionService.addVIP(steamID, amount);
if (result != 0) {
regesterGiveVIP(steamID, amount, vipGiveMethod, extra, result < 0);
publishWebhook(steamID, amount, "DonationAlerts", false);
}
}
}
if (result != 0) {
serverService.executeRCONOnAllServers("sm_reloadadmins");

1
src/main/resources/application.yaml

@ -51,6 +51,7 @@ backend:
buy:
steam: ${VIP_STEAMTRADE}
qiwi: ${VIP_QIWILINK}
donationalerts: ${VIP_DONATIONALERTS}
a2s:
backend_url: ${A2S_BACKEND_URL}
db:

Loading…
Cancel
Save