Browse Source

加个绑定邀请码的接口

master
nili 6 months ago
parent
commit
442dcfc543
  1. 14
      game-service/src/main/java/awesome/group/game/service/citrus/UserService.java
  2. 7
      game-web/src/main/java/awesome/group/game/web/rest/citrus/UserController.java

14
game-service/src/main/java/awesome/group/game/service/citrus/UserService.java

@ -186,6 +186,20 @@ public class UserService {
return new TeamBo(members); return new TeamBo(members);
} }
public void bindInviteCode(Integer uid, String inviteCode) {
Assert.isTrue(StringUtils.hasText(inviteCode), "邀请码不能为空");
MatrixUser u = userMapper.selectById(uid);
Assert.isTrue(u.getUpUid() == null, "不能重复绑定");
MatrixUser up = userMapper.selectByInviteCode(inviteCode);
Assert.isTrue(up != null, "非法邀请码");
Assert.isTrue(up.getAppId().equals(u.getAppId()), "非法邀请码");
MatrixUser user = new MatrixUser();
user.setId(uid);
user.setUpUid(up.getId());
user.setAdminId(up.getAdminId());
userMapper.updateById(user);
}
public void bindAliPay(Integer uid, String aliPayAccount, String name) { public void bindAliPay(Integer uid, String aliPayAccount, String name) {
Assert.isTrue(StringUtils.hasText(aliPayAccount), "支付宝账号不能为空"); Assert.isTrue(StringUtils.hasText(aliPayAccount), "支付宝账号不能为空");
Assert.isTrue(StringUtils.hasText(name), "支付宝账号姓名不能为空"); Assert.isTrue(StringUtils.hasText(name), "支付宝账号姓名不能为空");

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

@ -43,6 +43,13 @@ public class UserController {
return new R<>(null); return new R<>(null);
} }
@PostMapping("/bindInviteCode")
@RestApi
public R<Void> bindInviteCode(@RequestParam String inviteCode) {
userService.bindInviteCode(RequestContext.getCitrusUid(), inviteCode);
return new R<>(null);
}
@GetMapping("/cashRecords") @GetMapping("/cashRecords")
@RestApi @RestApi
public R<List<CashRecord>> getCashRecord() { public R<List<CashRecord>> getCashRecord() {

Loading…
Cancel
Save