Browse Source

按设备查,展示表格累计

master
nili 8 months ago
parent
commit
a20dc5da83
  1. 25
      game-service/src/main/java/awesome/group/game/service/AdminService.java
  2. 2
      game-service/src/main/java/awesome/group/game/service/bo/PageResult.java

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

@ -87,7 +87,7 @@ public class AdminService {
public PageResult<MatrixAdvRecordBo> advList(AdvRecordQuery param, Integer adminId) {
List<MatrixApp> appList = appList(adminId);
LambdaQueryWrapper<MatrixAdvRecord> wrapper = Wrappers.lambdaQuery();
QueryWrapper<MatrixAdvRecord> wrapper = Wrappers.query();
Optional<MatrixApp> app = appList.stream().filter(x -> x.getCode().equals(param.code)).findFirst();
if (app.isEmpty()) {
@ -95,33 +95,40 @@ public class AdminService {
}
MatrixAdmin admin = adminMapper.selectById(adminId);
if (admin.getRole() == DEVICE_OWNER) {
wrapper.eq(MatrixAdvRecord::getAdminId, adminId);
wrapper.eq("admin_id", adminId);
}
wrapper.eq(MatrixAdvRecord::getAppId, app.get().getId());
wrapper.eq("app_id", app.get().getId());
if (param.advType != null) {
wrapper.eq(MatrixAdvRecord::getAdvType, param.advType);
wrapper.eq("adv_type", param.advType);
}
if (param.platform != null) {
wrapper.eq(MatrixAdvRecord::getPlatform, param.platform);
wrapper.eq("platform", param.platform);
}
if (StringUtils.hasText(param.deviceId)) {
wrapper.eq(MatrixAdvRecord::getDeviceId, param.deviceId);
wrapper.eq("device_id", param.deviceId);
}
if (!CollectionUtils.isEmpty(param.createdAt)) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date begin = format.parse(param.createdAt.get(0)), end = format.parse(param.createdAt.get(1));
wrapper.between(MatrixAdvRecord::getCreatedAt, new Timestamp(begin.getTime()), new Timestamp(end.getTime() + 86400_000 - 1000));
wrapper.between("created_at", new Timestamp(begin.getTime()), new Timestamp(end.getTime() + 86400_000 - 1000));
} catch (ParseException e) {
throw new PaganiException(PaganiExceptionCode.ILLEGAL_REQUEST, "时间范围有误");
}
}
wrapper.orderByDesc(MatrixAdvRecord::getId);
int page = param.current;
int pageSize = param.pageSize;
IPage<MatrixAdvRecord> iPage = advRecordMapper.selectPage(new Page<>(page, pageSize), wrapper);
PageResult<MatrixAdvRecordBo> res = new PageResult<>();
if(page == 1 && StringUtils.hasText(param.deviceId)) {
QueryWrapper<MatrixAdvRecord> sumQuery = wrapper.clone();
sumQuery.select("sum(ecpm) as ecpm");
MatrixAdvRecord sum = advRecordMapper.selectOne(sumQuery);
res.sum = sum != null ? sum.getEcpm() : 0L;
}
wrapper.orderByDesc("id");
IPage<MatrixAdvRecord> iPage = advRecordMapper.selectPage(new Page<>(page, pageSize), wrapper);
Map<Integer, MatrixApp> appMap = appList.stream().collect(Collectors.toMap(MatrixApp::getId, x -> x));
res.total = iPage.getTotal();
res.data = iPage.getRecords().stream().map(x -> {

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

@ -6,6 +6,8 @@ public class PageResult<T> {
public List<T> data;
public long total;
public Long sum;
public PageResult() {
}

Loading…
Cancel
Save