diff --git a/src/main/java/app/entities/VipGiveMethod.java b/src/main/java/app/entities/VipGiveMethod.java index 98d0d7a..cbb0fca 100644 --- a/src/main/java/app/entities/VipGiveMethod.java +++ b/src/main/java/app/entities/VipGiveMethod.java @@ -1,17 +1,29 @@ package app.entities; public enum VipGiveMethod { - FREE("Бесплатно"), + FREE("Бесплатно", "Free"), STEAM("Steam"), QIWI("Qiwi"), - MANUAL("Админ"), + MANUAL("Админ", "Admin"), AFTERTIME("Убрана"), TOTAL("Итого"), - DONATIONALERTS("Донейшон Алертс"); + DONATIONALERTS("Донейшон Алертс", "DonationAlerts"), + PROMOCODE("Промокод", "PromoCode"); String human_name; + String webhook_name; + + VipGiveMethod(String human_name, String webhook_name) { + this.human_name = human_name; + this.webhook_name = webhook_name; + } VipGiveMethod(String human_name) { this.human_name = human_name; + this.webhook_name = human_name; + } + + public String getWebhookName() { + return this.webhook_name; } } diff --git a/src/main/java/app/entities/db/DonateStat.java b/src/main/java/app/entities/db/DonateStat.java index 5e5116b..579a407 100644 --- a/src/main/java/app/entities/db/DonateStat.java +++ b/src/main/java/app/entities/db/DonateStat.java @@ -96,6 +96,9 @@ public class DonateStat { case DONATIONALERTS -> { return "Оплачено DonationAlerts: " + getRubles().toString() + " рублей"; } + case PROMOCODE -> { + return "Получена промокодом"; + } } return "Неизвестно"; } diff --git a/src/main/java/app/services/db/VIPService.java b/src/main/java/app/services/db/VIPService.java index 7f29457..3fa3d83 100644 --- a/src/main/java/app/services/db/VIPService.java +++ b/src/main/java/app/services/db/VIPService.java @@ -93,39 +93,18 @@ public class VIPService { public int addVIP(SteamID steamID, int amount, VipGiveMethod vipGiveMethod, String extra) { int result = 0; switch (vipGiveMethod){ - case FREE -> { + case FREE, PROMOCODE -> { result = permitionService.addFreeVIP(steamID, amount); if (result != 0) { - regesterGiveVIP(steamID, amount, vipGiveMethod, extra, false); - publishWebhook(steamID, amount, "Free", true); + regesterGiveVIP(steamID, amount, vipGiveMethod, extra, VipGiveMethod.FREE.equals(vipGiveMethod)?false:result < 0);//такая логика тут нужна бляя + publishWebhook(steamID, amount, vipGiveMethod.getWebhookName(), true); } } - case QIWI -> { + case QIWI, STEAM, MANUAL, DONATIONALERTS -> { result = permitionService.addVIP(steamID, amount); if (result != 0) { regesterGiveVIP(steamID, amount, vipGiveMethod, extra, result < 0); - publishWebhook(steamID, amount, "Qiwi", false); - } - } - case STEAM -> { - result = permitionService.addVIP(steamID, amount); - if (result != 0) { - regesterGiveVIP(steamID, amount, vipGiveMethod, extra, result < 0); - publishWebhook(steamID, amount, "Steam", false); - } - } - case MANUAL -> { - result = permitionService.addVIP(steamID, amount); - if (result != 0) { - regesterGiveVIP(steamID, amount, vipGiveMethod, extra, result < 0); - 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); + publishWebhook(steamID, amount, vipGiveMethod.getWebhookName(), false); } } }