Browse Source

上月收入 & 本月收入

master
nili 9 months ago
parent
commit
aa02361166
  1. 19
      game-service/src/main/java/awesome/group/game/service/AdminService.java
  2. 2
      game-service/src/main/java/awesome/group/game/service/bo/OverviewBo.java

19
game-service/src/main/java/awesome/group/game/service/AdminService.java

@ -32,6 +32,8 @@ import org.springframework.util.StringUtils;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
@ -259,7 +261,22 @@ public class AdminService {
int yesterday = DateUtil.datePlus(today, -1);
int rangeStart = DateUtil.datePlus(today, -7);
bo.yesterdayIncome = aggregationService.getIncome(appIds, yesterday, yesterday);
// bo.recent7DaysIncome = aggregationService.getIncome(appIds, rangeStart, yesterday);
LocalDate now = LocalDate.now();
// 获取上个月的年份和月份
YearMonth lastMonth = YearMonth.from(now).minusMonths(1);
// 获取上个月的第一天和最后一天
LocalDate firstDayOfLastMonth = lastMonth.atDay(1);
LocalDate lastDayOfLastMonth = lastMonth.atEndOfMonth();
bo.lastMonthIncome = aggregationService.getIncome(appIds, DateUtil.date2Number(firstDayOfLastMonth), DateUtil.date2Number(lastDayOfLastMonth));
YearMonth thisMonth = YearMonth.from(now);
// 获取本月的第一天
LocalDate firstDayOfThisMonth = thisMonth.atDay(1);
bo.thisMonthIncome = bo.todayIncome + aggregationService.getIncome(appIds, DateUtil.date2Number(firstDayOfThisMonth), today);
return bo;
}

2
game-service/src/main/java/awesome/group/game/service/bo/OverviewBo.java

@ -5,4 +5,6 @@ public class OverviewBo {
public long totalIncome;
public long yesterdayIncome;
public long lastMonthIncome;
public long thisMonthIncome;
}

Loading…
Cancel
Save