Browse Source

деньги мне неси

master
gsd 2 years ago
parent
commit
b0eec19dcd
  1. 24
      src/main/java/app/controllers/other/ExternalVIPController.java
  2. 2
      src/main/java/app/entities/DonateStatistic.java
  3. 14
      src/main/java/app/entities/VipPrice.java
  4. 18
      src/main/java/app/services/db/DonateService.java
  5. 2
      src/main/java/app/services/db/FreeVIPService.java

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

@ -3,18 +3,16 @@ package app.controllers.other;
import app.annotations.enums.AuthMethod;
import app.annotations.interfaces.CheckWebAccess;
import app.entities.VipGiveMethod;
import app.entities.VipPrice;
import app.services.db.VIPService;
import app.utils.SteamIDConverter;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashSet;
import java.util.*;
@RestController
@RequestMapping("api/external/vip")
@ -23,10 +21,21 @@ public class ExternalVIPController {
HashSet<String> unique_set;
List<VipPrice> prices;
@Autowired
public ExternalVIPController(VIPService vipService) {
this.vipService = vipService;
this.unique_set = new HashSet();
setupPrices();
}
public void setupPrices() {
prices = new ArrayList<>();
prices.add(new VipPrice("1 Месяц", 200, "1 ключ", "site_content/images/vip/VIP_1_MOUNTH.jpg", "month"));
prices.add(new VipPrice("1 Неделя", 100, "40 рефов", "site_content/images/vip/VIP_7_DAYS.jpg", "week"));
prices.add(new VipPrice("1 День", 35, "10 рефов", "site_content/images/vip/VIP_1_DAY.jpg", "day"));
prices.add(new VipPrice("1 День", 0, "бесплатно", "site_content/images/vip/freevip.jpg", "free"));
}
@PostMapping
@ -50,4 +59,9 @@ public class ExternalVIPController {
extra);
return new ResponseEntity(result, HttpStatus.OK);
}
@GetMapping
public ResponseEntity getPrices() {
return new ResponseEntity(prices, HttpStatus.OK);
}
}

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

@ -7,11 +7,13 @@ public class DonateStatistic {
VipGiveMethod giveMethod;
Integer count;
String reserved;
Integer amount;
//sub
public DonateStatistic(Object[] raw) {
giveMethod = VipGiveMethod.values()[(int) raw[0]];
count = ((Long) raw[1]).intValue();
reserved = raw[2]==null?"": (String) raw[2];
amount = (int) raw[3];
}
public DonateStatistic(Object o) {

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

@ -0,0 +1,14 @@
package app.entities;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class VipPrice {
String human_duration;
int money_price;
String item_price;
String img_url;
String period;
}

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

@ -68,7 +68,7 @@ public class DonateService {
}
public HashMap getGivedVipStatistic(StatisticRange statisticRange) {
List<Object[]> raw_donateStatistics = entityManager.createNativeQuery("SELECT `givemethod`,COUNT(*) as count,`reserved` FROM `gived_vip` WHERE `givemethod` IN (0,1,2) AND `timestamp` > CAST(DATE_FORMAT(NOW() ,?1) as DATE) GROUP BY `givemethod`, `reserved`")
List<Object[]> raw_donateStatistics = entityManager.createNativeQuery("SELECT `givemethod`,COUNT(*) as count,`reserved`, `amount` FROM `gived_vip` WHERE `givemethod` IN (0,1,2) AND `timestamp` > CAST(DATE_FORMAT(NOW() ,?1) as DATE) GROUP BY `givemethod`, `amount`")
.setParameter(1, StatisticRange.cast(statisticRange))
.getResultList();
List<DonateStatistic> donateStatistics = raw_donateStatistics.stream().map(DonateStatistic::new).toList();
@ -81,17 +81,17 @@ public class DonateService {
switch (ds.getGiveMethod()) {
case FREE -> map.get("free").put("day", ds.getCount());
case STEAM -> {
switch (ds.getReserved()) {
case "keys=0;metal=20;" -> map.get("steam").put("week", ds.getCount());
case "keys=0;metal=5;" -> map.get("steam").put("day", ds.getCount());
case "keys=1;metal=0;" -> map.get("steam").put("month", ds.getCount());
switch (ds.getAmount()) {
case 86400 -> map.get("steam").put("day", ds.getCount());
case 604800 -> map.get("steam").put("week", ds.getCount());
case 2678400, 2592000 -> map.get("steam").put("month", ds.getCount());
}
}
case QIWI -> {
switch (ds.getReserved()) {
case "rub=150;" -> map.get("qiwi").put("month", ds.getCount());
case "rub=75;" -> map.get("qiwi").put("week", ds.getCount());
case "rub=20;" -> map.get("qiwi").put("day", ds.getCount());
switch (ds.getAmount()) {
case 86400 -> map.get("qiwi").put("day", ds.getCount());
case 604800 -> map.get("qiwi").put("week", ds.getCount());
case 2678400, 2592000 -> map.get("qiwi").put("month", ds.getCount());
}
}
}

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

@ -89,7 +89,7 @@ public class FreeVIPService{
//1.имеются ли уже права
if (vipService.CheckCurrentPermition(steamID) != null) return 0L;
long current_server_time = getDBServerUTime();
long timeout = 60 * 60 * 24 * 30;
long timeout = 60 * 60 * 24 * 30 * 3; // лимит месяцев
long need_usertime = 60 * 60 * 24 * 2;
////////////////////////////////////////////////////////////////
long last_free_vip_gived = getLastGivedFreeVIP(socialAuth);

Loading…
Cancel
Save