|
|
@@ -16,9 +16,12 @@ import com.ytpm.general.Result;
|
|
|
import com.ytpm.general.StatusCode;
|
|
|
import com.ytpm.handle.CustomerException;
|
|
|
import com.ytpm.middle.view.AppRankingListVO;
|
|
|
+import com.ytpm.middle.view.AppRevenueHourVO;
|
|
|
+import com.ytpm.middle.view.AppUserHourVO;
|
|
|
import com.ytpm.middle.view.DashboardAppRevenueVO;
|
|
|
import com.ytpm.middle.view.DashboardRankingListVO;
|
|
|
import com.ytpm.middle.view.DashboardRevenueVO;
|
|
|
+import com.ytpm.middle.view.DashboardRiskVO;
|
|
|
import com.ytpm.middle.view.UserRankingListVO;
|
|
|
import com.ytpm.service.dyz.AdService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -36,6 +39,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class AdServiceImpl implements AdService {
|
|
|
@@ -108,20 +112,40 @@ public class AdServiceImpl implements AdService {
|
|
|
//查询出各应用的用户及收益数据
|
|
|
List<String> appIdList = Arrays.asList(apkIds.split(","));
|
|
|
int index = appIdList.size();
|
|
|
- index--;
|
|
|
// 由于子表数据庞大导致range查询低于const
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(index);
|
|
|
+ DashboardAppRevenueVO appRevenueVO;
|
|
|
+ String appId;
|
|
|
do {
|
|
|
- String appId = appIdList.get(index);
|
|
|
- //根据应用ID查询收益数据及个小时数据
|
|
|
- DashboardAppRevenueVO appRevenueVO = adRecordMapper.getHourRevenue(appId);
|
|
|
+ --index;
|
|
|
+ appId = appIdList.get(index);
|
|
|
+ //根据应用ID查询收益数据及个小时数据 1-今日
|
|
|
+ List<AppRevenueHourVO> todayRevenues = adRecordMapper.getHourRevenue(appId,1);
|
|
|
+ Map<String, BigDecimal> todayHourMap = todayRevenues.stream().collect(Collectors.toMap(AppRevenueHourVO::getHour, AppRevenueHourVO::getRevenue));
|
|
|
+ appRevenueVO = new DashboardAppRevenueVO();
|
|
|
+ appRevenueVO.setAppId(appId);
|
|
|
+ //统计今日数据
|
|
|
+ BigDecimal todayRevenue = todayHourMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ appRevenueVO.setTodayHourRevenueMap(todayHourMap);
|
|
|
+ appRevenueVO.setTodayRevenue(todayRevenue);
|
|
|
+ //统计昨日数据
|
|
|
+ List<AppRevenueHourVO> yesterdayRevenues = adRecordMapper.getHourRevenue(appId,2);
|
|
|
+ Map<String, BigDecimal> yesterdayHourMap = yesterdayRevenues.stream().collect(Collectors.toMap(AppRevenueHourVO::getHour, AppRevenueHourVO::getRevenue));
|
|
|
+ appRevenueVO.setYesterdayHourRevenueMap(yesterdayHourMap);
|
|
|
+ BigDecimal yesterdayRevenue = yesterdayHourMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ appRevenueVO.setYesterdayRevenue(yesterdayRevenue);
|
|
|
+ //统计本月数据
|
|
|
+ List<AppRevenueHourVO> monthRevenues = adRecordMapper.getHourRevenue(appId,3);
|
|
|
+ BigDecimal monthRevenue = monthRevenues.stream().map(AppRevenueHourVO::getRevenue).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ appRevenueVO.setMonthRevenue(monthRevenue);
|
|
|
appRevenueList.add(appRevenueVO);
|
|
|
countDownLatch.countDown();
|
|
|
- }while (index<0);
|
|
|
+ }while (index>0);
|
|
|
vo.setAppRevenueList(appRevenueList);
|
|
|
- vo.setTodayTotalRevenue(adRecordMapper.getRevenueByType(apkIds,1));
|
|
|
- vo.setYesterdayTotalRevenue(adRecordMapper.getRevenueByType(apkIds,2));
|
|
|
- vo.setMonthTotalRevenue(adRecordMapper.getRevenueByType(apkIds,3));
|
|
|
+ //直接统计各应用的收益
|
|
|
+ vo.setTodayTotalRevenue(appRevenueList.stream().map(DashboardAppRevenueVO::getTodayRevenue).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ vo.setYesterdayTotalRevenue(appRevenueList.stream().map(DashboardAppRevenueVO::getYesterdayRevenue).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ vo.setMonthTotalRevenue(appRevenueList.stream().map(DashboardAppRevenueVO::getMonthRevenue).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
@@ -138,6 +162,30 @@ public class AdServiceImpl implements AdService {
|
|
|
return view;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询用户风控分时数据统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public DashboardRiskVO userStatics(String appId) {
|
|
|
+ DashboardRiskVO vo = new DashboardRiskVO();
|
|
|
+ vo.setTodayRegistryCount(appUserMapper.countRegistryUser(appId,1));
|
|
|
+ vo.setYesterdayRegistryCount(appUserMapper.countRegistryUser(appId,2));
|
|
|
+ vo.setMonthRegistryCount(appUserMapper.countRegistryUser(appId,3));
|
|
|
+
|
|
|
+ vo.setTodayLoginCount(appUserMapper.countLoginUser(appId,1));
|
|
|
+ vo.setYesterdayLoginCount(appUserMapper.countLoginUser(appId,2));
|
|
|
+ vo.setMonthLoginCount(appUserMapper.countLoginUser(appId,3));
|
|
|
+
|
|
|
+ List<AppUserHourVO> registryHour = appUserMapper.countRegistryHour(appId,1);
|
|
|
+ Map<String, Integer> registryMap = registryHour.stream().collect(Collectors.toMap(AppUserHourVO::getTime, AppUserHourVO::getCount));
|
|
|
+ vo.setTodayRegistryHourMap(registryMap);
|
|
|
+
|
|
|
+ List<AppUserHourVO> loginHour = appUserMapper.countLoginHour(appId,1);
|
|
|
+ Map<String, Integer> loginMap = loginHour.stream().collect(Collectors.toMap(AppUserHourVO::getTime, AppUserHourVO::getCount));
|
|
|
+ vo.setTodayLoginHourMap(loginMap);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存记录
|
|
|
* 始终创建新的事务以保障子方法的独立事务
|