|
@@ -31,6 +31,7 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* created in 2021/9/28
|
|
@@ -738,8 +739,78 @@ public class SunDataServiceImpl implements SunDataService {
|
|
|
|
|
|
@Override
|
|
|
public SunStaticIncome getHistoryIncomeStatic() {
|
|
|
+ Map map = sun2Mapper.selectHistoryIncome();
|
|
|
+ if (map == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ float all_recharge = getFloatFromDb(map.get("all_recharge"));
|
|
|
+ float all_spend = getFloatFromDb(map.get("all_spend"));
|
|
|
+ float roi = 0f;
|
|
|
+ if (all_spend != 0) {
|
|
|
+ roi = all_recharge / all_spend;
|
|
|
+ }
|
|
|
+ return SunStaticIncome.builder()
|
|
|
+ .allRecharge(String.format("%.2f", all_recharge))
|
|
|
+ .allSpend(String.format("%.2f", all_spend))
|
|
|
+ .allRoi(String.format("%.2f", roi))
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map getIncomeByDay(int page, int size) {
|
|
|
+ HashMap<String, Object> resMap = new HashMap<>();
|
|
|
+ SunStaticIncomeExample example = SunStaticIncomeExample.newAndCreateCriteria().example();
|
|
|
+ //总共多少条
|
|
|
+ long l = sunStaticIncomeMapper.countByExample(example);
|
|
|
+ resMap.put("total", l);
|
|
|
+ // 排序查询指定页
|
|
|
+ example.orderBy(SunStaticIncome.Column.staticDate.desc());
|
|
|
+ example.page(page, size);
|
|
|
+ List<SunStaticIncome> sunStaticIncomes = sunStaticIncomeMapper.selectByExample(example);
|
|
|
+
|
|
|
+ //查询另一张表对应的前 60 天的数据
|
|
|
+ List<String> collect = sunStaticIncomes.stream().map(SunStaticIncome::getStaticDate).collect(Collectors.toList());
|
|
|
+ List<SunStaticIncomeHundred> sunStaticIncomeHundreds = sunStaticIncomeHundredMapper.selectByExample(
|
|
|
+ SunStaticIncomeHundredExample.newAndCreateCriteria().andStaticDateIn(collect).andDayNumLessThan(61).example());
|
|
|
|
|
|
- return null;
|
|
|
+
|
|
|
+ ArrayList<Object> objects = new ArrayList<>();
|
|
|
+ for (SunStaticIncome sunStaticIncome : sunStaticIncomes) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("income", sunStaticIncome);
|
|
|
+ map.put("incomeDay", sunStaticIncomeHundreds.stream().filter(x -> sunStaticIncome.getStaticDate().equals(x.getStaticDate())).collect(Collectors.toList()));
|
|
|
+ objects.add(map);
|
|
|
+ }
|
|
|
+ resMap.put("list", objects);
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map getIncomeByDayChannel(int page, int size, String channelId) {
|
|
|
+ HashMap<String, Object> resMap = new HashMap<>();
|
|
|
+ SunStaticIncomeChannelExample example = SunStaticIncomeChannelExample.newAndCreateCriteria().andChannelIdEqualTo(channelId).example();
|
|
|
+ //总共多少条
|
|
|
+ long l = sunStaticIncomeChannelMapper.countByExample(example);
|
|
|
+ resMap.put("total", l);
|
|
|
+ // 排序查询指定页
|
|
|
+ example.orderBy(SunStaticIncomeChannel.Column.staticDate.desc());
|
|
|
+ example.page(page, size);
|
|
|
+ List<SunStaticIncomeChannel> sunStaticIncomes = sunStaticIncomeChannelMapper.selectByExample(example);
|
|
|
+
|
|
|
+ //查询另一张表对应的前 60 天的数据
|
|
|
+ List<String> collect = sunStaticIncomes.stream().map(SunStaticIncomeChannel::getStaticDate).collect(Collectors.toList());
|
|
|
+ List<SunStaticIncomeHundredChannel> sunStaticIncomeHundreds = sunStaticIncomeHundredChannelMapper.selectByExample(
|
|
|
+ SunStaticIncomeHundredChannelExample.newAndCreateCriteria().andStaticDateIn(collect).andChannelIdEqualTo(channelId).andDayNumLessThan(61).example());
|
|
|
+
|
|
|
+ ArrayList<Object> objects = new ArrayList<>();
|
|
|
+ for (SunStaticIncomeChannel sunStaticIncome : sunStaticIncomes) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("income", sunStaticIncome);
|
|
|
+ map.put("incomeDay", sunStaticIncomeHundreds.stream().filter(x -> sunStaticIncome.getStaticDate().equals(x.getStaticDate())).collect(Collectors.toList()));
|
|
|
+ objects.add(map);
|
|
|
+ }
|
|
|
+ resMap.put("list", objects);
|
|
|
+ return resMap;
|
|
|
}
|
|
|
|
|
|
private SunStaticUserDay getSunUserByDate(String startDate, String endDate) {
|