Browse Source

加点数据

master
nili 7 months ago
parent
commit
80997d8cbe
  1. 15
      game-service/src/main/java/awesome/group/game/service/AdminService.java
  2. 32
      game-service/src/main/java/awesome/group/game/service/AggregationService.java
  3. 2
      game-service/src/main/java/awesome/group/game/service/bo/OverviewBo.java

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

@ -19,8 +19,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.gson.Gson; import com.google.common.base.Joiner;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -29,7 +28,6 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.google.common.base.Joiner;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
@ -53,6 +51,9 @@ public class AdminService {
@Autowired @Autowired
private MatrixAdvAggregationMapper aggregationMapper; private MatrixAdvAggregationMapper aggregationMapper;
@Autowired
private AggregationService aggregationService;
public static final int SUPER_ADMIN = 1;//超级管理员 public static final int SUPER_ADMIN = 1;//超级管理员
public static final int NORMAL_ADMIN = 2;//普通管理员 public static final int NORMAL_ADMIN = 2;//普通管理员
public static final int OTHER = 3;//普通账号 public static final int OTHER = 3;//普通账号
@ -252,7 +253,13 @@ public class AdminService {
LambdaQueryWrapper<MatrixApp> appQuery = new QueryWrapper<MatrixApp>().select("sum(income) as income").lambda(); LambdaQueryWrapper<MatrixApp> appQuery = new QueryWrapper<MatrixApp>().select("sum(income) as income").lambda();
appQuery.in(MatrixApp::getId, appIds); appQuery.in(MatrixApp::getId, appIds);
bo.totalIncome = appMapper.selectOne(appQuery).getIncome() + bo.todayIncome; bo.totalIncome = appMapper.selectOne(appQuery).getIncome();
int today = DateUtil.currentDate();
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);
return bo; return bo;
} }

32
game-service/src/main/java/awesome/group/game/service/AggregationService.java

@ -0,0 +1,32 @@
package awesome.group.game.service;
import awesome.group.game.dao.bean.MatrixAdvAggregation;
import awesome.group.game.dao.mapper.MatrixAdvAggregationMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
@Service
public class AggregationService {
@Resource
private MatrixAdvAggregationMapper aggregationMapper;
public long getIncome(List<Integer> appIds, int startDate, int endDate) {
if (CollectionUtils.isEmpty(appIds)) {
return 0L;
}
LambdaQueryWrapper<MatrixAdvAggregation> query = new QueryWrapper<MatrixAdvAggregation>()
.select("sum(income) as income").lambda();
query.in(MatrixAdvAggregation::getAppId, appIds);
query.between(MatrixAdvAggregation::getDate, startDate, endDate);
MatrixAdvAggregation data = aggregationMapper.selectOne(query);
if (data == null) {
return 0L;
}
return data.getIncome();
}
}

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

@ -3,4 +3,6 @@ package awesome.group.game.service.bo;
public class OverviewBo { public class OverviewBo {
public long todayIncome; public long todayIncome;
public long totalIncome; public long totalIncome;
public long yesterdayIncome;
} }

Loading…
Cancel
Save