|
|
@ -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 |
|
|
|
) |
|
|
|
); |
|
|
|