|
@ -40,14 +40,20 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
private StatisticsMapper statisticsMapper; |
|
|
private StatisticsMapper statisticsMapper; |
|
|
@Override |
|
|
@Override |
|
|
public WorkbenchCard getCard(String token) { |
|
|
public WorkbenchCard getCard(String token) { |
|
|
Date date=new Date(); |
|
|
|
|
|
|
|
|
Date date=new Date();//当天 |
|
|
|
|
|
Date yday=generalService.getYesterday(); |
|
|
// 获取开始时间和结束时间(当天) |
|
|
// 获取开始时间和结束时间(当天) |
|
|
LocalDateTime startOfDay = date.toInstant() |
|
|
LocalDateTime startOfDay = date.toInstant() |
|
|
.atZone(ZoneId.systemDefault()) |
|
|
.atZone(ZoneId.systemDefault()) |
|
|
.toLocalDateTime() |
|
|
.toLocalDateTime() |
|
|
.with(LocalTime.MIN); |
|
|
.with(LocalTime.MIN); |
|
|
|
|
|
|
|
|
LocalDateTime endOfDay = startOfDay.plusDays(1).minusSeconds(1); |
|
|
LocalDateTime endOfDay = startOfDay.plusDays(1).minusSeconds(1); |
|
|
|
|
|
// 获取开始时间和结束时间(当天) |
|
|
|
|
|
LocalDateTime startOfYday = yday.toInstant() |
|
|
|
|
|
.atZone(ZoneId.systemDefault()) |
|
|
|
|
|
.toLocalDateTime() |
|
|
|
|
|
.with(LocalTime.MIN); |
|
|
|
|
|
LocalDateTime endOfYday = startOfYday.plusDays(1).minusSeconds(1); |
|
|
// 获取当前日期 |
|
|
// 获取当前日期 |
|
|
LocalDate today = LocalDate.now(); |
|
|
LocalDate today = LocalDate.now(); |
|
|
// 获取当前年份的第一天 |
|
|
// 获取当前年份的第一天 |
|
@ -61,13 +67,18 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
.filter(market -> market != null && !market.trim().isEmpty()) |
|
|
.filter(market -> market != null && !market.trim().isEmpty()) |
|
|
.map(market -> { |
|
|
.map(market -> { |
|
|
// 根据市场名称和日期范围查询统计信息 |
|
|
// 根据市场名称和日期范围查询统计信息 |
|
|
Statistics statistics = statisticsMapper.selectByMarketAndDate( |
|
|
|
|
|
|
|
|
Statistics currentStatistics = statisticsMapper.selectByMarketAndDate( |
|
|
market, |
|
|
market, |
|
|
Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant()), |
|
|
Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant()), |
|
|
Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant()) |
|
|
Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant()) |
|
|
); |
|
|
); |
|
|
|
|
|
Statistics ydayStatistics = statisticsMapper.selectByMarketAndDate( |
|
|
|
|
|
market, |
|
|
|
|
|
Date.from(startOfYday.atZone(ZoneId.systemDefault()).toInstant()), |
|
|
|
|
|
Date.from(endOfYday.atZone(ZoneId.systemDefault()).toInstant()) |
|
|
|
|
|
); |
|
|
// 创建并返回市场卡片对象 |
|
|
// 创建并返回市场卡片对象 |
|
|
return createWorkbenchMarketCard(market, statistics, yearlyStartDate, date); |
|
|
|
|
|
|
|
|
return createWorkbenchMarketCard(market, currentStatistics,ydayStatistics, yearlyStartDate, date); |
|
|
}) |
|
|
}) |
|
|
// 收集并行流结果为列表 |
|
|
// 收集并行流结果为列表 |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
@ -137,48 +148,48 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
获取卡片数据 |
|
|
获取卡片数据 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public WorkbenchMarketCard createWorkbenchMarketCard(String market, Statistics statistics, Date yearlyStartDate, Date currentDate) { |
|
|
|
|
|
|
|
|
public WorkbenchMarketCard createWorkbenchMarketCard(String market,Statistics currentStatistics, Statistics ydayStatistics, Date yearlyStartDate, Date currentDate) { |
|
|
Date date=new Date(); |
|
|
Date date=new Date(); |
|
|
WorkbenchMarketCard card = new WorkbenchMarketCard(); |
|
|
WorkbenchMarketCard card = new WorkbenchMarketCard(); |
|
|
card.setMarket(market); |
|
|
card.setMarket(market); |
|
|
if (statistics != null) { |
|
|
|
|
|
|
|
|
if (currentStatistics != null&& ydayStatistics != null) { |
|
|
// 一次性获取全年统计数据(从年初到今天) |
|
|
// 一次性获取全年统计数据(从年初到今天) |
|
|
Map<String, Integer> yearlyStats = calculateAllSum(market, yearlyStartDate, date); |
|
|
Map<String, Integer> yearlyStats = calculateAllSum(market, yearlyStartDate, date); |
|
|
|
|
|
|
|
|
// 卡片一:当前金币相关 |
|
|
// 卡片一:当前金币相关 |
|
|
card.setCurrentPermanent(statistics.getCurrentPermanent());//余量-永久金币 |
|
|
|
|
|
card.setCurrentFreeJune(statistics.getCurrentFreeJune()); //余量-免费六月金币 |
|
|
|
|
|
card.setCurrentFreeDecember(statistics.getCurrentFreeDecember()); //余量-免费十二月金币 |
|
|
|
|
|
card.setCurrentTask(statistics.getCurrentTask()); //余量-任务金币 |
|
|
|
|
|
|
|
|
card.setCurrentPermanent(currentStatistics.getCurrentPermanent());//余量-永久金币 |
|
|
|
|
|
card.setCurrentFreeJune(currentStatistics.getCurrentFreeJune()); //余量-免费六月金币 |
|
|
|
|
|
card.setCurrentFreeDecember(currentStatistics.getCurrentFreeDecember()); //余量-免费十二月金币 |
|
|
|
|
|
card.setCurrentTask(currentStatistics.getCurrentTask()); //余量-任务金币 |
|
|
card.setCurrentFree(card.getCurrentFreeJune() + card.getCurrentFreeDecember()); //余量-免费金币 |
|
|
card.setCurrentFree(card.getCurrentFreeJune() + card.getCurrentFreeDecember()); //余量-免费金币 |
|
|
card.setCurrentGold(card.getCurrentPermanent() + card.getCurrentFree() + card.getCurrentTask()); //余量-总金币 |
|
|
card.setCurrentGold(card.getCurrentPermanent() + card.getCurrentFree() + card.getCurrentTask()); //余量-总金币 |
|
|
card.setDailyChange(statistics.getDailyChange()); //较前一日变化 |
|
|
|
|
|
|
|
|
card.setDailyChange(currentStatistics.getDailyChange()); //较前一日变化 |
|
|
// 卡片二:充值相关 |
|
|
// 卡片二:充值相关 |
|
|
card.setRecharge(statistics.getRecharge()); //充值-当日充值 |
|
|
|
|
|
card.setMoney(statistics.getMoney()); //充值-当日金额(永久) |
|
|
|
|
|
|
|
|
card.setRecharge(ydayStatistics.getRecharge()); //充值-昨日充值 |
|
|
|
|
|
card.setMoney(ydayStatistics.getMoney()); //充值-昨日金额(永久) |
|
|
card.setYearlyRecharge(yearlyStats.getOrDefault("recharge", 0)); // 充值-全年累计充值 |
|
|
card.setYearlyRecharge(yearlyStats.getOrDefault("recharge", 0)); // 充值-全年累计充值 |
|
|
card.setYearlyMoney(yearlyStats.getOrDefault("money", 0)); // 充值-全年累计金额(永久)//充值-全年累计金额(永久) |
|
|
card.setYearlyMoney(yearlyStats.getOrDefault("money", 0)); // 充值-全年累计金额(永久)//充值-全年累计金额(永久) |
|
|
// 卡片三:消费与退款 |
|
|
// 卡片三:消费与退款 |
|
|
card.setConsumePermanent(statistics.getConsumePermanent());//消费-永久金币 |
|
|
|
|
|
card.setConsumeFreeJune(statistics.getConsumeFreeJune());//消费-免费六月金币 |
|
|
|
|
|
card.setConsumeFreeDecember(statistics.getConsumeFreeDecember());//消费-免费十二月金币 |
|
|
|
|
|
card.setConsumeTask(statistics.getConsumeTask());//消费-任务金币 |
|
|
|
|
|
card.setRefundPermanent(statistics.getRefundPermanent());//退款-永久金币 |
|
|
|
|
|
card.setRefundFreeJune(statistics.getRefundFreeJune());//退款-免费六月金币 |
|
|
|
|
|
card.setRefundFreeDecember(statistics.getRefundFreeDecember());//退款-免费十二月金币 |
|
|
|
|
|
card.setRefundTask(statistics.getRefundTask());//退款-任务金币 |
|
|
|
|
|
//当日总消费 |
|
|
|
|
|
|
|
|
card.setConsumePermanent(ydayStatistics.getConsumePermanent());//昨日消费-永久金币 |
|
|
|
|
|
card.setConsumeFreeJune(ydayStatistics.getConsumeFreeJune());//昨日消费-免费六月金币 |
|
|
|
|
|
card.setConsumeFreeDecember(ydayStatistics.getConsumeFreeDecember());//昨日消费-免费十二月金币 |
|
|
|
|
|
card.setConsumeTask(ydayStatistics.getConsumeTask());//昨日消费-任务金币 |
|
|
|
|
|
card.setRefundPermanent(ydayStatistics.getRefundPermanent());//昨日退款-永久金币 |
|
|
|
|
|
card.setRefundFreeJune(ydayStatistics.getRefundFreeJune());//昨日退款-免费六月金币 |
|
|
|
|
|
card.setRefundFreeDecember(ydayStatistics.getRefundFreeDecember());//昨日退款-免费十二月金币 |
|
|
|
|
|
card.setRefundTask(ydayStatistics.getRefundTask());//昨日退款-任务金币 |
|
|
|
|
|
//昨日总消费 |
|
|
int totalConsume = card.getConsumePermanent() + card.getConsumeFreeJune() + card.getConsumeFreeDecember() + card.getConsumeTask(); |
|
|
int totalConsume = card.getConsumePermanent() + card.getConsumeFreeJune() + card.getConsumeFreeDecember() + card.getConsumeTask(); |
|
|
//当日总退款 |
|
|
|
|
|
|
|
|
//昨日总退款 |
|
|
int totalRefund = card.getRefundPermanent() + card.getRefundFreeJune() + card.getRefundFreeDecember() + card.getRefundTask(); |
|
|
int totalRefund = card.getRefundPermanent() + card.getRefundFreeJune() + card.getRefundFreeDecember() + card.getRefundTask(); |
|
|
card.setDailyReduce(totalConsume - totalRefund);//当日总消耗 |
|
|
|
|
|
|
|
|
card.setDailyReduce(totalConsume - totalRefund);//昨日总消耗 |
|
|
card.setYearlyConsume(yearlyStats.getOrDefault("consume", 0)); // 年累计消费 |
|
|
card.setYearlyConsume(yearlyStats.getOrDefault("consume", 0)); // 年累计消费 |
|
|
card.setYearlyRefund(yearlyStats.getOrDefault("refund", 0)); // 年累计退款 |
|
|
card.setYearlyRefund(yearlyStats.getOrDefault("refund", 0)); // 年累计退款 |
|
|
|
|
|
|
|
|
card.setYearlyReduce(card.getYearlyConsume() - card.getYearlyRefund());//年累计消耗 |
|
|
card.setYearlyReduce(card.getYearlyConsume() - card.getYearlyRefund());//年累计消耗 |
|
|
// 卡片四:人头数相关 |
|
|
// 卡片四:人头数相关 |
|
|
card.setRechargeNum(statistics.getRechargeNum()); |
|
|
|
|
|
card.setFirstRecharge(statistics.getFirstRecharge()); |
|
|
|
|
|
|
|
|
card.setRechargeNum(currentStatistics.getRechargeNum()); |
|
|
|
|
|
card.setFirstRecharge(currentStatistics.getFirstRecharge()); |
|
|
card.setYearlyRechargeNum(yearlyStats.getOrDefault("rechargeNum", 0)); |
|
|
card.setYearlyRechargeNum(yearlyStats.getOrDefault("rechargeNum", 0)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|