|
@ -101,4 +101,53 @@ public class AdvRecordService { |
|
|
return new AdvResponse(ecpmReal, user); |
|
|
return new AdvResponse(ecpmReal, user); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public AdvResponse saveRecordV4(Integer uid, MatrixAdvRecordEditBo bo, String ip) { |
|
|
|
|
|
Assert.isTrue((System.currentTimeMillis() / 1000) - bo.timestamp < 30, "非法请求"); |
|
|
|
|
|
Assert.isTrue(StringUtils.hasText(bo.appCode) && StringUtils.hasText(bo.sign), "非法请求"); |
|
|
|
|
|
MatrixApp app = appMapper.queryByCode(bo.appCode); |
|
|
|
|
|
Assert.isTrue(app != null, "非法请求"); |
|
|
|
|
|
String secret = app.getSecret(); |
|
|
|
|
|
String str = bo.getSignStrV3(secret); |
|
|
|
|
|
if (!bo.sign.equalsIgnoreCase(EncryptUtil.sha1(str))) { |
|
|
|
|
|
L.trace("signError", "sign:" + bo.sign + ",str:" + str + ",secret:" + secret); |
|
|
|
|
|
throw new PaganiException(PaganiExceptionCode.GENERAL_ERROR, "非法请求"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
long ecpm = bo.advType > 1000 ? 0 : bo.ecpm; |
|
|
|
|
|
MatrixUser u = userMapper.selectById(uid); |
|
|
|
|
|
Assert.isTrue(u.getAppId().equals(app.getId()), "非法请求"); |
|
|
|
|
|
Assert.isTrue(!u.getStatus().equals(Constants.USER_BANNED), "账号异常,无法获得收益"); |
|
|
|
|
|
|
|
|
|
|
|
MatrixWhiteUser whiteUser = whiteUserMapper.queryByUserId(uid); |
|
|
|
|
|
if (bo.advType == Constants.VIDEO && whiteUser != null && whiteUser.getStatus() == 0) { |
|
|
|
|
|
ecpm = ThreadLocalRandom.current().nextInt(500_00, 1500_00); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
long ecpmReal = 0;//不给普通用户分钱
|
|
|
|
|
|
MatrixAdvRecord record = new MatrixAdvRecord(); |
|
|
|
|
|
record.setDeviceId(bo.deviceId); |
|
|
|
|
|
record.setAppId(u.getAppId()); |
|
|
|
|
|
record.setPlatform(bo.platform); |
|
|
|
|
|
record.setAdvType(bo.advType); |
|
|
|
|
|
record.setEcpm(ecpm); |
|
|
|
|
|
record.setEcpmReal(ecpmReal); |
|
|
|
|
|
record.setUserId(uid); |
|
|
|
|
|
record.setDeviceBrand(bo.deviceBrand); |
|
|
|
|
|
record.setDeviceName(bo.deviceName); |
|
|
|
|
|
record.setIp(ip); |
|
|
|
|
|
record.setAdvId(bo.advId); |
|
|
|
|
|
if (u.getAdminId() != null) { |
|
|
|
|
|
record.setAdminId(u.getAdminId()); |
|
|
|
|
|
if (bo.advType == Constants.VIDEO ) { |
|
|
|
|
|
MatrixAdmin admin = adminMapper.selectById(u.getAdminId()); |
|
|
|
|
|
if (admin.getIncomeRate() != null) { |
|
|
|
|
|
record.setEcpmAdmin(ecpm * admin.getIncomeRate() / 100); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
mapper.insert(record); |
|
|
|
|
|
MatrixUser user = userMapper.selectById(uid); |
|
|
|
|
|
return new AdvResponse(ecpmReal, user); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|