1.实名认证接口修改
This commit is contained in:
@@ -127,6 +127,11 @@ public class ApiAccessLimitUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeKey(String id, String key) {
|
||||
String redisKey = generateRedisKey(key, id);
|
||||
redisUtils.delete(redisKey);
|
||||
}
|
||||
|
||||
|
||||
public static<T> T runFunAndCheckKey(Supplier<T> supplier, String lockKey, Integer seconds) {
|
||||
try{
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdcardUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.ApiAccessLimitUtil;
|
||||
import com.sqx.common.utils.DataLimitUtil;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.sqx.modules.app.service.AliService;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -36,6 +42,13 @@ public class AppController {
|
||||
private AppService appService;
|
||||
@Autowired
|
||||
private CommonInfoService commonRepository;
|
||||
private final UserInfoService userInfoService;
|
||||
private final AliService aliService;
|
||||
|
||||
public AppController(UserInfoService userInfoService, AliService aliService) {
|
||||
this.userInfoService = userInfoService;
|
||||
this.aliService = aliService;
|
||||
}
|
||||
|
||||
@PostMapping("/authenticationRegister")
|
||||
@ApiOperation("认证创建账号")
|
||||
@@ -79,43 +92,81 @@ public class AppController {
|
||||
@ApiOperation("用户修改个人信息")
|
||||
@ResponseBody
|
||||
@Debounce(interval = 3000, value = "#userId")
|
||||
public Result updateUserImageUrl(@RequestAttribute("userId") Long userId, String zhiFuBao, String zhiFuBaoName) {
|
||||
if (StrUtil.isEmpty(zhiFuBao) || StrUtil.isEmpty(zhiFuBaoName)) {
|
||||
return Result.error("支付宝账户及姓名不能为空!");
|
||||
}
|
||||
if (!DataLimitUtil.isAccessAllowed(zhiFuBao+zhiFuBaoName, Integer.parseInt(commonRepository.findOne(924).getValue()), "month")) {
|
||||
return Result.error("修改失败,相同支付宝账号每月可绑定次数已用完");
|
||||
public Result updateUserImageUrl(@RequestAttribute("userId") Long userId, @RequestParam(required = false) String zhiFuBao,
|
||||
@RequestParam String certName, @RequestParam(required = false) String certNum) {
|
||||
if (StrUtil.isAllBlank(zhiFuBao, certNum)) {
|
||||
return Result.error("支付宝账号或实名身份证号码必须传递一个");
|
||||
}
|
||||
|
||||
UserInfo userInfo = userInfoService.getByUserId(userId);
|
||||
UserEntity userEntity = userService.getById(userId);
|
||||
|
||||
int count = userService.count(new QueryWrapper<UserEntity>()
|
||||
.ne("user_id", userId)
|
||||
.eq("zhi_fu_bao_name", zhiFuBaoName)
|
||||
.eq("zhi_fu_bao_name", certName)
|
||||
.eq("zhi_fu_bao", zhiFuBao));
|
||||
|
||||
if (count > 0) {
|
||||
if (StrUtil.isNotBlank(zhiFuBao) && count > 0) {
|
||||
return Result.error("一个支付宝账号仅可绑定一个用户");
|
||||
}
|
||||
if (!ApiAccessLimitUtil.isAccessAllowed(userId.toString(), "updateZFB", Integer.parseInt(commonRepository.findOne(925).getValue()), "month")) {
|
||||
return Result.error("每月可修改次数已用完,请联系管理员");
|
||||
|
||||
if (StrUtil.isNotBlank(zhiFuBao)) {
|
||||
if (StrUtil.isNotBlank(userInfo.getCertName()) && !certName.equals(userInfo.getCertName())) {
|
||||
return Result.error("姓名与实名认证信息不相符");
|
||||
}
|
||||
|
||||
if (!DataLimitUtil.isAccessAllowed(zhiFuBao+certName, Integer.parseInt(commonRepository.findOne(924).getValue()), "month")) {
|
||||
return Result.error("修改失败,相同支付宝账号每月可绑定次数已用完");
|
||||
}
|
||||
|
||||
if (!ApiAccessLimitUtil.isAccessAllowed(userId.toString(), "updateZFB", Integer.parseInt(commonRepository.findOne(925).getValue()), "month")) {
|
||||
return Result.error("每月可修改次数已用完,请联系管理员");
|
||||
}
|
||||
}
|
||||
UserEntity old = userService.getById(userId);
|
||||
String accountNo = old.getZhiFuBao();
|
||||
String accountName = old.getZhiFuBaoName();
|
||||
boolean isFirstBind = false;
|
||||
if (StrUtil.isEmpty(accountNo) && StrUtil.isEmpty(accountName)) {
|
||||
isFirstBind = true;
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(certNum)) {
|
||||
if (StrUtil.isNotBlank(userEntity.getZhiFuBaoName()) && !certName.equals(userEntity.getZhiFuBaoName())) {
|
||||
return Result.error("姓名与绑定支付宝信息不相符");
|
||||
}
|
||||
if (!IdcardUtil.isValidCard(certNum)) {
|
||||
throw new SqxException("身份证号码有误");
|
||||
}
|
||||
|
||||
Integer idCount = userInfoService.countCertCount(certName, certNum);
|
||||
if (idCount > 1) {
|
||||
throw new SqxException("此实名信息已存在");
|
||||
}
|
||||
|
||||
if (!ApiAccessLimitUtil.isAccessAllowed(String.valueOf(userId), "updateAuthCertInfo", 1, "month")) {
|
||||
return Result.error("每月可修改次数已用完,请联系管理员");
|
||||
}
|
||||
}
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.setZhiFuBao(zhiFuBao);
|
||||
userEntity.setZhiFuBaoName(zhiFuBaoName);
|
||||
userEntity.setUserId(userId);
|
||||
old.setZhiFuBao(userEntity.getZhiFuBao());
|
||||
old.setZhiFuBaoName(userEntity.getZhiFuBaoName());
|
||||
boolean bool = userService.updateById(userEntity);
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(zhiFuBao)) {
|
||||
userEntity.setZhiFuBao(zhiFuBao);
|
||||
userEntity.setZhiFuBaoName(certName);
|
||||
userService.updateById(userEntity);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(certNum)) {
|
||||
try {
|
||||
aliService.authCertNo(certName, certNum);
|
||||
}catch (Exception e) {
|
||||
ApiAccessLimitUtil.removeKey(String.valueOf(userId), "updateAuthCertInfo");
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
userInfo.setCertName(certName);
|
||||
userInfo.setCertNo(certNum);
|
||||
userInfo.setUpdateTime(DateUtil.date());
|
||||
userInfoService.updateById(userInfo);
|
||||
}
|
||||
return Result.success();
|
||||
// 去除首绑支付宝奖励
|
||||
// if (bool && isFirstBind) {
|
||||
// userService.firstBindAwardsMoney(old);
|
||||
// }
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AliServiceImpl implements AliService {
|
||||
throw new SqxException("身份证信息不匹配,认证失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new SqxException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user