Browse Source

saveAdvRecordV4

master
nili 6 months ago
parent
commit
db56dcfa74
  1. 49
      game-service/src/main/java/awesome/group/game/service/citrus/AdvRecordService.java
  2. 7
      game-web/src/main/java/awesome/group/game/web/rest/citrus/UserController.java

49
game-service/src/main/java/awesome/group/game/service/citrus/AdvRecordService.java

@ -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);
}
} }

7
game-web/src/main/java/awesome/group/game/web/rest/citrus/UserController.java

@ -63,6 +63,13 @@ public class UserController {
return new R<>(res); return new R<>(res);
} }
@PostMapping("/saveAdvRecordV4")
@RestApi
public R<AdvResponse> saveAdvRecordV4(@RequestBody MatrixAdvRecordEditBo bo) {
AdvResponse res = advRecordService.saveRecordV4(RequestContext.getCitrusUid(), bo, RequestContext.getIpAddr(RequestContext.getRequest()));
return new R<>(res);
}
@PostMapping("/bindWx") @PostMapping("/bindWx")
@RestApi @RestApi
public R<Void> bindWx(@RequestParam String accessToken, @RequestParam String openId) { public R<Void> bindWx(@RequestParam String accessToken, @RequestParam String openId) {

Loading…
Cancel
Save