|
@@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -66,6 +67,7 @@ public class AppAgentController extends BaseController {
|
|
|
@ApiOperation(value = "用户代理统计", notes = "用户代理统计")
|
|
|
public HttpRet<AppUserAgentJournalIndexVO> index(@RequestBody AgentIndexDTO agentIndexDto)
|
|
|
{
|
|
|
+ Date now = DateUtil.date();
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
if(null != agentIndexDto.getUserId()){
|
|
|
userId = agentIndexDto.getUserId();
|
|
@@ -76,55 +78,72 @@ public class AppAgentController extends BaseController {
|
|
|
topUserId = appUserAgent.getTopId();
|
|
|
}
|
|
|
AppUserAgentJournalIndexVO vo = new AppUserAgentJournalIndexVO();
|
|
|
- Date nowDate = DateUtil.date();
|
|
|
+ Date curDate = DateUtil.date();
|
|
|
if(agentIndexDto.getType() == 1){
|
|
|
- nowDate = DateUtil.offsetMonth(nowDate,-1);
|
|
|
+ curDate = DateUtil.offsetMonth(curDate,-1);
|
|
|
}
|
|
|
String formatP = "yyyy-MM-dd";
|
|
|
- Date beginDate = DateUtil.beginOfMonth(nowDate);
|
|
|
- Date endDate = DateUtil.endOfMonth(nowDate);
|
|
|
-
|
|
|
- List<AppUserCount> appUserCountList = appUserCountService.getAppUserCountNew(userId,DateUtil.format(beginDate,formatP),DateUtil.format(endDate,formatP));
|
|
|
-
|
|
|
+ Date beginDate = DateUtil.beginOfMonth(curDate);
|
|
|
+ Date endDate = DateUtil.endOfMonth(curDate);
|
|
|
+ Date weekBegin = DateUtil.beginOfWeek(now);
|
|
|
+ Date weekend = DateUtil.endOfWeek(now);
|
|
|
+ List<AppUserCount> appUserCountList = appUserCountService.getAppUserCountNew(userId,DateUtil.format(weekBegin,formatP),DateUtil.format(weekend,formatP));
|
|
|
+ AppUserAgent queryAppUserAgent = new AppUserAgent();
|
|
|
+ queryAppUserAgent.setPid(userId);
|
|
|
+
|
|
|
+ List<AppUserAgent> appUserAgentList = appUserAgentService.selectAllAgentList(userId,null,null,null);
|
|
|
if(null == appUserCountList){
|
|
|
appUserCountList = new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
double money = 0;
|
|
|
- if(null != redisCache.getCacheMapValue(CacheConstants.USER_AGENT_TEAM_PHASE,String.valueOf(topUserId))){
|
|
|
- money = redisCache.getCacheMapValue(CacheConstants.USER_AGENT_TEAM_PHASE,String.valueOf(topUserId));
|
|
|
+ if(null != appUserCountList && appUserCountList.size() > 0 && appUserAgentList != null && appUserAgentList.size()>0){
|
|
|
+ List<AppUserCount> finalAppUserCountList = appUserCountList;
|
|
|
+ money = appUserAgentList.stream().mapToDouble(appUserAgent1 -> {
|
|
|
+ return finalAppUserCountList.stream().mapToDouble(e->{
|
|
|
+ return (e.getGameLoseAmount() - e.getGameWinAmount() - e.getGameCommission() - e.getRechargeGive()) * appUserAgent1.getDividendGuaranteeRate()/100;
|
|
|
+ }).sum();
|
|
|
+ }).sum();
|
|
|
}
|
|
|
- if(null != appUserAgent.getDividendGuaranteeRate()){
|
|
|
+
|
|
|
money = money * appUserAgent.getDividendGuaranteeRate() / 100 ;
|
|
|
- }
|
|
|
+ }else{
|
|
|
+ money = 0;
|
|
|
+ }*/
|
|
|
|
|
|
vo.setMyCommission(BigDecimal.valueOf(money>0?money:0).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
- vo.setLiveCommission(appUserCountList.stream().mapToDouble(e->e.getLiveCommission()).sum());
|
|
|
- vo.setGameCommission(appUserCountList.stream().mapToDouble(e->e.getGameCommission()).sum());
|
|
|
+ vo.setLiveCommission(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getLiveCommission()).sum()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ vo.setGameCommission(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getGameCommission()).sum()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
- vo.setTeamUser(appUserCountList.stream().map(AppUserCount::getUserId).distinct().collect(Collectors.toList()).size());
|
|
|
+ vo.setTeamUser(appUserAgentList.stream().filter(e->
|
|
|
+ compareTime(e.getCreateTime(),beginDate,endDate)
|
|
|
+ ).collect(Collectors.toList()).size());
|
|
|
|
|
|
- vo.setTeamRecharge(appUserCountList.stream().mapToDouble(e->e.getRechargeAmount()).sum());
|
|
|
+ vo.setTeamRecharge(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->{
|
|
|
+ return (e.getRechargeAmount() - e.getRechargeGive()) + e.getRechargeCommission();
|
|
|
+ }).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
- vo.setRechargeGive(appUserCountList.stream().mapToDouble(e->e.getRechargeGive()).sum());
|
|
|
+ vo.setRechargeGive(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getRechargeGive()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
- vo.setRechargeCommission(appUserCountList.stream().mapToDouble(e->e.getRechargeCommission()).sum());
|
|
|
+ vo.setRechargeCommission(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getRechargeCommission()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
- vo.setTeamBetting(appUserCountList.stream().mapToDouble(e->e.getGameBetting()).sum());
|
|
|
+ vo.setTeamBetting(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getGameBetting()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
- vo.setTeamLive(appUserCountList.stream().mapToDouble(e->e.getLiveUseAmount()).sum());
|
|
|
+ vo.setTeamLive(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getLiveUseAmount()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
- vo.setTeamWin(appUserCountList.stream().mapToDouble(e->e.getGameWinAmount()).sum());
|
|
|
+ vo.setTeamWin(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getGameWinAmount()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
- vo.setTeamLose(appUserCountList.stream().mapToDouble(e->e.getGameLoseAmount()).sum());
|
|
|
+ vo.setTeamLose(BigDecimal.valueOf(appUserCountList.stream().mapToDouble(e->e.getGameLoseAmount()).sum()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
|
|
|
vo.setActiveUser(appUserCountList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()-> new TreeSet<>(Comparator.comparing(f->f.getUserId()))), ArrayList::new)).size());
|
|
|
|
|
|
Date yesterDay = DateUtil.offsetDay(DateUtil.date(),-1);
|
|
|
- vo.setYesterdayUser(appUserAgentService.countAgent(topUserId,DateUtil.format(yesterDay,"yyyy-MM-dd").concat(" 00:00:00")
|
|
|
- ,DateUtil.format(yesterDay,"yyyy-MM-dd").concat(" 23:59:59")));
|
|
|
- vo.setMonthUser(appUserAgentService.countAgent(topUserId,DateUtil.format(beginDate,"yyyy-MM-dd").concat(" 00:00:00")
|
|
|
- ,DateUtil.format(endDate,"yyyy-MM-dd").concat(" 23:59:59")));
|
|
|
+ vo.setYesterdayUser(appUserAgentList.stream().filter(e->
|
|
|
+ compareTime(e.getCreateTime(),yesterDay,yesterDay)
|
|
|
+ ).collect(Collectors.toList()).size());
|
|
|
+ vo.setMonthUser(appUserAgentList.stream().filter(e->
|
|
|
+ compareTime(e.getCreateTime(),beginDate,endDate)
|
|
|
+ ).collect(Collectors.toList()).size());
|
|
|
|
|
|
return HttpRet.success(MessageUtils.message("11022"),vo);
|
|
|
}
|
|
@@ -146,7 +165,8 @@ public class AppAgentController extends BaseController {
|
|
|
@ApiOperation(value = "团队列表", notes = "团队列表")
|
|
|
public HttpRetPageArr<AppAgentTeamVo> teamList(@RequestBody AppAgentTeamDto teamDto)
|
|
|
{
|
|
|
- startPage();
|
|
|
+
|
|
|
+ startPageBySize(10);
|
|
|
List<AppAgentTeamVo> list = appUserAgentService.teamList(teamDto);
|
|
|
return HttpRetPageArr.success(MessageUtils.message("11022"),getDataTable(list));
|
|
|
}
|
|
@@ -168,7 +188,7 @@ public class AppAgentController extends BaseController {
|
|
|
return HttpRet.fail("转账失败,受益人不是代理");
|
|
|
}
|
|
|
if(appUserAgent.getPid().longValue() == 0 || isTwoLevel(appUserAgent.getPid())){
|
|
|
- List<AppUserAgent> appUserAgentList = appUserAgentService.selectAllAgentList(userId,transerDto.getToUserId());
|
|
|
+ List<AppUserAgent> appUserAgentList = appUserAgentService.selectAllAgentList(userId,transerDto.getToUserId(),null,null);
|
|
|
if(null == appUserAgentList || appUserAgentList.size() < 1){
|
|
|
return HttpRet.fail("转账失败,只能给团队成员转账");
|
|
|
}
|
|
@@ -266,4 +286,10 @@ public class AppAgentController extends BaseController {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private boolean compareTime(Date curTime,Date beginTime,Date endTime){
|
|
|
+ beginTime = DateUtil.parse(DateUtil.format(beginTime,"yyyy-MM-dd").concat(" 00:00:00"));
|
|
|
+ endTime = DateUtil.parse(DateUtil.format(endTime,"yyyy-MM-dd").concat(" 23:59:59"));
|
|
|
+ return curTime.getTime() >= beginTime.getTime() && curTime.getTime() <= endTime.getTime();
|
|
|
+ }
|
|
|
+
|
|
|
}
|