Browse Source

promocode init

master
gsd 1 year ago
parent
commit
612e011c17
  1. 18
      src/main/java/app/entities/VipGiveMethod.java
  2. 3
      src/main/java/app/entities/db/DonateStat.java
  3. 31
      src/main/java/app/services/db/VIPService.java

18
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;
}
}

3
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 "Неизвестно";
}

31
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);
}
}
}

Loading…
Cancel
Save