|
|
@ -120,7 +120,7 @@ public class AdminService { |
|
|
|
int page = param.current; |
|
|
|
int pageSize = param.pageSize; |
|
|
|
PageResult<MatrixAdvRecordBo> res = new PageResult<>(); |
|
|
|
if(page == 1 && StringUtils.hasText(param.deviceId)) { |
|
|
|
if (page == 1 && StringUtils.hasText(param.deviceId)) { |
|
|
|
QueryWrapper<MatrixAdvRecord> sumQuery = wrapper.clone(); |
|
|
|
sumQuery.select("sum(ecpm) as ecpm"); |
|
|
|
MatrixAdvRecord sum = advRecordMapper.selectOne(sumQuery); |
|
|
@ -206,77 +206,46 @@ public class AdminService { |
|
|
|
} |
|
|
|
|
|
|
|
@Async |
|
|
|
public void mockData(String appCode, long yuan, String channel) { |
|
|
|
MatrixApp app = appMapper.queryByCode(appCode); |
|
|
|
if (app == null) { |
|
|
|
public void mockData(Integer scheduleId) { |
|
|
|
MatrixMockSchedule schedule = mockScheduleMapper.selectById(scheduleId); |
|
|
|
long target = schedule.getIncomeYuan() * 100L * 1000; |
|
|
|
if (target <= schedule.getMockIncome()) { |
|
|
|
mockScheduleMapper.updateStatus(2, schedule.getId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
List<MatrixAdvRecord> mockDevice = advRecordMapper.getWhiteDevice(channel); |
|
|
|
if (CollectionUtils.isEmpty(mockDevice)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
long income = 0; |
|
|
|
long target = yuan * 100 * 1000; |
|
|
|
while (income < target) { |
|
|
|
MatrixAdvRecord record = mockDevice.get(ThreadLocalRandom.current().nextInt(0, mockDevice.size())); |
|
|
|
long ecpm = ThreadLocalRandom.current().nextInt(500_00, 1500_00); |
|
|
|
record.setId(null); |
|
|
|
record.setEcpm(ecpm); |
|
|
|
record.setAppId(app.getId()); |
|
|
|
record.setPlatform(2); |
|
|
|
record.setAdvType(3); |
|
|
|
|
|
|
|
income += ecpm; |
|
|
|
advRecordMapper.insert(record); |
|
|
|
|
|
|
|
try { |
|
|
|
Thread.sleep(ThreadLocalRandom.current().nextInt(10_000, 20_000)); |
|
|
|
} catch (Exception e) { |
|
|
|
L.trace("mockData", "error:" + e.getMessage(), e); |
|
|
|
} |
|
|
|
if (schedule.getStatus() == 0) { |
|
|
|
mockScheduleMapper.updateStatus(1, schedule.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Async |
|
|
|
public void mockData(MatrixMockSchedule schedule) { |
|
|
|
mockScheduleMapper.updateStatus(1, schedule.getId()); |
|
|
|
String channel = schedule.getChannel(); |
|
|
|
int yuan = schedule.getIncomeYuan(); |
|
|
|
List<MatrixAdvRecord> mockDevice = advRecordMapper.getWhiteDevice(channel); |
|
|
|
if (CollectionUtils.isEmpty(mockDevice)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
long income = 0; |
|
|
|
long target = yuan * 100L * 1000; |
|
|
|
while (income < target) { |
|
|
|
try { |
|
|
|
Thread.sleep(ThreadLocalRandom.current().nextInt(10_000, 20_000)); |
|
|
|
} catch (Exception e) { |
|
|
|
L.trace("mockData", "error:" + e.getMessage(), e); |
|
|
|
} |
|
|
|
MatrixAdvRecord record = mockDevice.get(ThreadLocalRandom.current().nextInt(0, mockDevice.size())); |
|
|
|
long ecpm = ThreadLocalRandom.current().nextInt(500_00, 1500_00); |
|
|
|
record.setId(null); |
|
|
|
record.setEcpm(ecpm); |
|
|
|
record.setAppId(schedule.getAppId()); |
|
|
|
record.setPlatform(2); |
|
|
|
record.setAdvType(3); |
|
|
|
|
|
|
|
income += ecpm; |
|
|
|
advRecordMapper.insert(record); |
|
|
|
mockScheduleMapper.updateMockIncome(ecpm, schedule.getId()); |
|
|
|
} |
|
|
|
mockScheduleMapper.updateStatus(2, schedule.getId()); |
|
|
|
Random random = new Random(); |
|
|
|
try { |
|
|
|
Thread.sleep(10_000 + random.nextInt(40_000)); |
|
|
|
} catch (Exception e) { |
|
|
|
L.trace("mockData", "error:" + e.getMessage(), e); |
|
|
|
} |
|
|
|
MatrixAdvRecord record = mockDevice.get(ThreadLocalRandom.current().nextInt(0, mockDevice.size())); |
|
|
|
long ecpm = 500_00 + random.nextInt(1000_00); |
|
|
|
record.setId(null); |
|
|
|
record.setEcpm(ecpm); |
|
|
|
record.setAppId(schedule.getAppId()); |
|
|
|
record.setPlatform(2); |
|
|
|
record.setAdvType(3); |
|
|
|
|
|
|
|
advRecordMapper.insert(record); |
|
|
|
mockScheduleMapper.updateMockIncome(ecpm, schedule.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Scheduled(cron = "0 * * * * ?") |
|
|
|
public void mockSchedule() { |
|
|
|
LambdaQueryWrapper<MatrixMockSchedule> queryWrapper = Wrappers.lambdaQuery(); |
|
|
|
queryWrapper.le(MatrixMockSchedule::getScheduleTime, new Timestamp(System.currentTimeMillis())); |
|
|
|
queryWrapper.eq(MatrixMockSchedule::getStatus, 0); |
|
|
|
queryWrapper.lt(MatrixMockSchedule::getStatus, 2); |
|
|
|
List<MatrixMockSchedule> res = mockScheduleMapper.selectList(queryWrapper); |
|
|
|
res.forEach(adminService::mockData); |
|
|
|
res.forEach(x -> adminService.mockData(x.getId())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|