Browse Source

用户封禁/解封

master
nili 7 months ago
parent
commit
c4ae5fc431
  1. 1
      game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java
  2. 3
      game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixUserMapper.java
  3. 3
      game-service/src/main/java/awesome/group/game/service/bo/citrus/UserBo.java
  4. 2
      game-service/src/main/java/awesome/group/game/service/citrus/AdvRecordService.java
  5. 4
      game-service/src/main/java/awesome/group/game/service/citrus/UserService.java
  6. 11
      game-service/src/main/java/awesome/group/game/service/matrix/MatrixUserService.java
  7. 6
      game-service/src/main/java/awesome/group/game/service/util/Constants.java
  8. 9
      game-web/src/main/java/awesome/group/game/web/rest/matrix/MatrixUserController.java

1
game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java

@ -25,5 +25,6 @@ public class MatrixUser {
private Long income;//分,累计收益
private Long contributeIncome;//贡献给上级的收益,分,ecpm
private Integer env;//用户设备环境检测
private Integer status;//0正常,-1封禁
private Timestamp createdAt;
}

3
game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixUserMapper.java

@ -30,4 +30,7 @@ public interface MatrixUserMapper extends BaseMapper<MatrixUser> {
@Update("update matrix_user set env = #{env} where id = #{userId}")
int updateEnv(int userId, int env);
@Update("update matrix_user set status = #{status} where id = #{userId}")
int updateStatus(int userId, int status);
}

3
game-service/src/main/java/awesome/group/game/service/bo/citrus/UserBo.java

@ -19,6 +19,8 @@ public class UserBo {
public Integer env;
public Integer status;
public String wxOpenId;//微信openId
public long createdAt;
@ -40,6 +42,7 @@ public class UserBo {
this.goldCoin = u.getIncome() - (u.getMoney() * 1000);
this.wxOpenId = u.getWxOpenId();
this.env = u.getEnv();
this.status = u.getStatus();
this.createdAt = u.getCreatedAt().getTime();
if (!StringUtils.hasText(nickname)) {

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

@ -12,6 +12,7 @@ import awesome.group.game.service.bo.matrix.AppNormalConfig;
import awesome.group.game.service.common.exception.PaganiException;
import awesome.group.game.service.common.exception.PaganiExceptionCode;
import awesome.group.game.service.common.log.L;
import awesome.group.game.service.util.Constants;
import awesome.group.game.service.util.EncryptUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -45,6 +46,7 @@ public class AdvRecordService {
AppNormalConfig config = new AppNormalConfig(app);
MatrixUser u = userMapper.selectById(uid);
Assert.isTrue(u.getAppId().equals(app.getId()), "非法请求");
Assert.isTrue(!u.getStatus().equals(Constants.USER_BANNED), "账号异常,无法获得收益");
long ecpmReal = ecpm * config.getRate(u) / 100;
ecpmReal = Math.min(config.maxIncomeEachVideo * 1000L, ecpmReal);
long contribute = 0;

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

@ -12,6 +12,7 @@ import awesome.group.game.service.bo.citrus.*;
import awesome.group.game.service.bo.matrix.UmengConfigBo;
import awesome.group.game.service.common.exception.PaganiException;
import awesome.group.game.service.common.exception.PaganiExceptionCode;
import awesome.group.game.service.util.Constants;
import awesome.group.game.service.util.DateUtil;
import awesome.group.game.service.util.EncryptUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -101,6 +102,9 @@ public class UserService {
UmengConfigBo configBo = gson.fromJson(app.getUmeng(), UmengConfigBo.class);
String mobile = uMengService.getMobile(token, configBo);
MatrixUser user = userMapper.selectByAppIdAndMobile(app.getId(), mobile);
if(user != null && user.getStatus() == Constants.USER_BANNED) {
throw new PaganiException(PaganiExceptionCode.GENERAL_ERROR, "账号异常,无法登录");
}
MatrixUser upUser = null;
if (StringUtils.hasText(inviteCode)) {
upUser = userMapper.selectByInviteCode(inviteCode);

11
game-service/src/main/java/awesome/group/game/service/matrix/MatrixUserService.java

@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
@ -27,6 +28,9 @@ public class MatrixUserService {
@Autowired
private MatrixAppMapper appMapper;
@Autowired
private AdminService adminService;
public PageResult<UserBo> list(UserQuery query) {
MatrixApp app = appMapper.queryByCode(query.appCode);
LambdaQueryWrapper<MatrixUser> wrapper = new LambdaQueryWrapper<>();
@ -51,4 +55,11 @@ public class MatrixUserService {
List<MatrixUser> list = userMapper.selectList(wrapper);
return list.stream().collect(Collectors.toMap(MatrixUser::getId, x -> x));
}
public void changeStatus(Integer adminId, Integer userId, Integer status) {
MatrixUser u = userMapper.selectById(userId);
List<Integer> appIds = adminService.getAdminAppIds(adminId);
Assert.isTrue(appIds.contains(u.getAppId()), "非法请求");
userMapper.updateStatus(userId, status);
}
}

6
game-service/src/main/java/awesome/group/game/service/util/Constants.java

@ -0,0 +1,6 @@
package awesome.group.game.service.util;
public class Constants {
public static final int USER_BANNED = -1;
}

9
game-web/src/main/java/awesome/group/game/web/rest/matrix/MatrixUserController.java

@ -5,8 +5,8 @@ import awesome.group.game.service.bo.citrus.UserBo;
import awesome.group.game.service.bo.matrix.UserQuery;
import awesome.group.game.service.common.response.R;
import awesome.group.game.service.matrix.MatrixUserService;
import awesome.group.game.web.RequestContext;
import awesome.group.game.web.aop.RestApi;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -22,4 +22,11 @@ public class MatrixUserController {
public R<PageResult<UserBo>> list(@RequestBody UserQuery query) {
return new R<>(userService.list(query));
}
@PostMapping("/changeStatus")
@RestApi
public R<Void> changeStatus(@RequestParam Integer userId, @RequestParam Integer status) {
userService.changeStatus(RequestContext.getAdminID(), userId, status);
return new R<>(null);
}
}

Loading…
Cancel
Save