Browse Source

按设备查,展示表格累计

master
nili 9 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) { public PageResult<MatrixAdvRecordBo> advList(AdvRecordQuery param, Integer adminId) {
List<MatrixApp> appList = appList(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(); Optional<MatrixApp> app = appList.stream().filter(x -> x.getCode().equals(param.code)).findFirst();
if (app.isEmpty()) { if (app.isEmpty()) {
@ -95,33 +95,40 @@ public class AdminService {
} }
MatrixAdmin admin = adminMapper.selectById(adminId); MatrixAdmin admin = adminMapper.selectById(adminId);
if (admin.getRole() == DEVICE_OWNER) { 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) { if (param.advType != null) {
wrapper.eq(MatrixAdvRecord::getAdvType, param.advType); wrapper.eq("adv_type", param.advType);
} }
if (param.platform != null) { if (param.platform != null) {
wrapper.eq(MatrixAdvRecord::getPlatform, param.platform); wrapper.eq("platform", param.platform);
} }
if (StringUtils.hasText(param.deviceId)) { if (StringUtils.hasText(param.deviceId)) {
wrapper.eq(MatrixAdvRecord::getDeviceId, param.deviceId); wrapper.eq("device_id", param.deviceId);
} }
if (!CollectionUtils.isEmpty(param.createdAt)) { if (!CollectionUtils.isEmpty(param.createdAt)) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try { try {
Date begin = format.parse(param.createdAt.get(0)), end = format.parse(param.createdAt.get(1)); 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) { } catch (ParseException e) {
throw new PaganiException(PaganiExceptionCode.ILLEGAL_REQUEST, "时间范围有误"); throw new PaganiException(PaganiExceptionCode.ILLEGAL_REQUEST, "时间范围有误");
} }
} }
wrapper.orderByDesc(MatrixAdvRecord::getId);
int page = param.current; int page = param.current;
int pageSize = param.pageSize; int pageSize = param.pageSize;
IPage<MatrixAdvRecord> iPage = advRecordMapper.selectPage(new Page<>(page, pageSize), wrapper);
PageResult<MatrixAdvRecordBo> res = new PageResult<>(); 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)); Map<Integer, MatrixApp> appMap = appList.stream().collect(Collectors.toMap(MatrixApp::getId, x -> x));
res.total = iPage.getTotal(); res.total = iPage.getTotal();
res.data = iPage.getRecords().stream().map(x -> { 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 List<T> data;
public long total; public long total;
public Long sum;
public PageResult() { public PageResult() {
} }

Loading…
Cancel
Save