|
|
@ -1,13 +1,7 @@ |
|
|
|
package awesome.group.game.service; |
|
|
|
|
|
|
|
import awesome.group.game.dao.bean.MatrixAdmin; |
|
|
|
import awesome.group.game.dao.bean.MatrixAdvAggregation; |
|
|
|
import awesome.group.game.dao.bean.MatrixAdvRecord; |
|
|
|
import awesome.group.game.dao.bean.MatrixApp; |
|
|
|
import awesome.group.game.dao.mapper.MatrixAdminMapper; |
|
|
|
import awesome.group.game.dao.mapper.MatrixAdvAggregationMapper; |
|
|
|
import awesome.group.game.dao.mapper.MatrixAdvRecordMapper; |
|
|
|
import awesome.group.game.dao.mapper.MatrixAppMapper; |
|
|
|
import awesome.group.game.dao.bean.*; |
|
|
|
import awesome.group.game.dao.mapper.*; |
|
|
|
import awesome.group.game.service.bo.*; |
|
|
|
import awesome.group.game.service.common.exception.PaganiException; |
|
|
|
import awesome.group.game.service.common.exception.PaganiExceptionCode; |
|
|
@ -23,6 +17,7 @@ import com.google.common.base.Joiner; |
|
|
|
import org.apache.commons.lang.RandomStringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -56,6 +51,16 @@ public class AdminService { |
|
|
|
@Autowired |
|
|
|
private AggregationService aggregationService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MatrixWhiteDeviceMapper whiteDeviceMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MatrixMockScheduleMapper mockScheduleMapper; |
|
|
|
|
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
private AdminService adminService; |
|
|
|
|
|
|
|
public static final int SUPER_ADMIN = 1;//超级管理员
|
|
|
|
public static final int NORMAL_ADMIN = 2;//普通管理员
|
|
|
|
public static final int OTHER = 3;//普通账号
|
|
|
@ -226,6 +231,76 @@ public class AdminService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@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()); |
|
|
|
} |
|
|
|
|
|
|
|
@Scheduled(cron = "0 * * * * ?") |
|
|
|
public void mockSchedule() { |
|
|
|
LambdaQueryWrapper<MatrixMockSchedule> queryWrapper = Wrappers.lambdaQuery(); |
|
|
|
queryWrapper.le(MatrixMockSchedule::getScheduleTime, new Timestamp(System.currentTimeMillis())); |
|
|
|
queryWrapper.eq(MatrixMockSchedule::getStatus, 0); |
|
|
|
List<MatrixMockSchedule> res = mockScheduleMapper.selectList(queryWrapper); |
|
|
|
res.forEach(adminService::mockData); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void addWhiteList(String deviceId, String channel) { |
|
|
|
if (whiteDeviceMapper.queryWhitelist(deviceId) > 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
whiteDeviceMapper.insertWhiteList(deviceId, channel); |
|
|
|
} |
|
|
|
|
|
|
|
public void deleteWhiteList(String deviceId) { |
|
|
|
whiteDeviceMapper.deleteByDeviceId(deviceId); |
|
|
|
} |
|
|
|
|
|
|
|
public List<MatrixWhiteDevice> whiteDeviceList() { |
|
|
|
return whiteDeviceMapper.selectList(null); |
|
|
|
} |
|
|
|
|
|
|
|
public List<MatrixMockSchedule> mockScheduleList() { |
|
|
|
return mockScheduleMapper.selectList(null); |
|
|
|
} |
|
|
|
|
|
|
|
public void addMockSchedule(AddMockScheduleReq bo) { |
|
|
|
MatrixMockSchedule schedule = new MatrixMockSchedule(); |
|
|
|
schedule.setAppId(bo.appId); |
|
|
|
schedule.setScheduleTime(new Timestamp(bo.scheduleTime)); |
|
|
|
schedule.setChannel(bo.channel); |
|
|
|
schedule.setIncomeYuan(bo.incomeYuan); |
|
|
|
mockScheduleMapper.insert(schedule); |
|
|
|
} |
|
|
|
|
|
|
|
public OverviewBo incomeOverview(int adminId, String code) { |
|
|
|
if (StringUtils.hasText(code)) { |
|
|
|
MatrixApp app = appMapper.queryByCode(code); |
|
|
|