|
|
@@ -4,6 +4,8 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.PhoneUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -11,14 +13,18 @@ import org.spring.base.common.enums.ErrorCodeEnum;
|
|
|
import org.spring.base.common.exception.BusinessException;
|
|
|
import org.spring.base.common.req.BaseReq;
|
|
|
import org.spring.base.common.rsp.Result;
|
|
|
+import org.spring.finance.biz.common.SysDictConstants;
|
|
|
import org.spring.finance.biz.crud.entity.AccountFinance;
|
|
|
import org.spring.finance.biz.crud.entity.bo.AccountRegisterBo;
|
|
|
import org.spring.finance.biz.crud.entity.req.StrReq;
|
|
|
import org.spring.finance.biz.crud.service.AccountFinanceService;
|
|
|
import org.spring.finance.biz.crud.service.PromotionService;
|
|
|
+import org.spring.finance.biz.crud.service.SysDictDataService;
|
|
|
import org.spring.finance.biz.crud.service.app.AccountAppService;
|
|
|
import org.spring.finance.biz.crud.service.cache.UserSessionRedisCache;
|
|
|
import org.spring.finance.biz.enums.sms.SmsOptTypeEnum;
|
|
|
+import org.spring.finance.biz.idverify.IdVerifyClientApi;
|
|
|
+import org.spring.finance.biz.idverify.req.IdVerifyReq;
|
|
|
import org.spring.finance.biz.sms.SmsClientApi;
|
|
|
import org.spring.finance.biz.utils.AesUtils;
|
|
|
import org.spring.finance.server.common.annotation.LoginRequired;
|
|
|
@@ -46,6 +52,10 @@ public class AccountAuthController {
|
|
|
@Resource
|
|
|
private UserSessionRedisCache userSessionRedisCache;
|
|
|
@Resource
|
|
|
+ private IdVerifyClientApi idVerifyClientApi;
|
|
|
+ @Resource
|
|
|
+ private SysDictDataService sysDictDataService;
|
|
|
+ @Resource
|
|
|
private PromotionService promotionService;
|
|
|
//转账额度每日
|
|
|
private final static BigDecimal TRANSFER_AMOUNT = BigDecimal.valueOf(50000);
|
|
|
@@ -94,6 +104,16 @@ public class AccountAuthController {
|
|
|
accountRegisterBo.setSalt(salt);
|
|
|
accountRegisterBo.setPassword(AesUtils.encrypt(password, salt));
|
|
|
accountRegisterBo.setRealName(realName);
|
|
|
+ //字典查询转账限额额度
|
|
|
+ String transferLimit = sysDictDataService.findValueByKey(SysDictConstants.DATA_TRANSFER_LIMIT, SysDictConstants.TYPE_SYSTEM_CONFIG);
|
|
|
+ BigDecimal transferLimitAmount = new BigDecimal(transferLimit);
|
|
|
+ //设置用户每日限额
|
|
|
+ accountRegisterBo.setTransferLimit(transferLimitAmount);
|
|
|
+ //字典查询提现限额额度
|
|
|
+ String withdrawalLimit = sysDictDataService.findValueByKey(SysDictConstants.DATA_WITHDRAWAL_LIMIT, SysDictConstants.TYPE_SYSTEM_CONFIG);
|
|
|
+ BigDecimal withdrawalLimitAmount = new BigDecimal(withdrawalLimit);
|
|
|
+ //设置每日提现额度
|
|
|
+ accountRegisterBo.setWithdrawalLimit(withdrawalLimitAmount);
|
|
|
//生成推荐码
|
|
|
accountRegisterBo.setPromotionCode(accountAppService.getPromotionCode());
|
|
|
accountFinance = accountFinanceService.register(accountRegisterBo);
|
|
|
@@ -187,23 +207,43 @@ public class AccountAuthController {
|
|
|
// LoginVo loginVo = new LoginVo();
|
|
|
// loginVo.setAccessToken(accessToken);
|
|
|
// return Result.success(loginVo);
|
|
|
+// }
|
|
|
+
|
|
|
+// @ResponseBody
|
|
|
+// @ApiOperation(value = "修改登录密码")
|
|
|
+// @LoginRequired
|
|
|
+// @PostMapping(value = "update_pwd")
|
|
|
+// public Result<?> updatePwd(@RequestBody @Valid BaseReq<UpdatePwdReq> req) {
|
|
|
+// Integer userId = userSessionRedisCache.getLoginUserId(req.getAccessToken());
|
|
|
+// AccountFinance accountFinance = accountFinanceService.getById(userId);
|
|
|
+// if (accountFinance == null) {
|
|
|
+// throw new BusinessException(ErrorCodeEnum.MISSING_KEY_INFORMATION.getCode(), ErrorCodeEnum.MISSING_KEY_INFORMATION.getDesc());
|
|
|
+// }
|
|
|
+// //校验旧密码
|
|
|
+// String pwdEncryption = AesUtils.encrypt(req.getData().getOldPwd(), accountFinance.getSalt());
|
|
|
+// if (ObjectUtil.notEqual(pwdEncryption, accountFinance.getPassword())) {
|
|
|
+// throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "旧密码错误");
|
|
|
+// }
|
|
|
+// String salt = RandomUtil.randomString(16);
|
|
|
+// AccountFinance update = new AccountFinance();
|
|
|
+// update.setId(userId);
|
|
|
+// update.setSalt(salt);
|
|
|
+// update.setPassword(AesUtils.encrypt(req.getData().getPassword(), salt));
|
|
|
+// boolean result = accountFinanceService.updateById(update);
|
|
|
+// return result ? Result.success() : Result.error("修改密码失败");
|
|
|
// }
|
|
|
|
|
|
@ResponseBody
|
|
|
- @ApiOperation(value = "修改密码")
|
|
|
+ @ApiOperation(value = "修改登录密码")
|
|
|
@LoginRequired
|
|
|
- @PostMapping(value = "update_pwd")
|
|
|
- public Result<?> updatePwd(@RequestBody @Valid BaseReq<UpdatePwdReq> req) {
|
|
|
+ @PostMapping(value = "update_login_pwd")
|
|
|
+ public Result<?> UpdateLoginPwd (@RequestBody @Valid BaseReq<UpdatePwdReq> req) {
|
|
|
Integer userId = userSessionRedisCache.getLoginUserId(req.getAccessToken());
|
|
|
AccountFinance accountFinance = accountFinanceService.getById(userId);
|
|
|
if (accountFinance == null) {
|
|
|
throw new BusinessException(ErrorCodeEnum.MISSING_KEY_INFORMATION.getCode(), ErrorCodeEnum.MISSING_KEY_INFORMATION.getDesc());
|
|
|
}
|
|
|
- //校验旧密码
|
|
|
- String pwdEncryption = AesUtils.encrypt(req.getData().getOldPwd(), accountFinance.getSalt());
|
|
|
- if (ObjectUtil.notEqual(pwdEncryption, accountFinance.getPassword())) {
|
|
|
- throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "旧密码错误");
|
|
|
- }
|
|
|
+ //生成登陆密码盐值
|
|
|
String salt = RandomUtil.randomString(16);
|
|
|
AccountFinance update = new AccountFinance();
|
|
|
update.setId(userId);
|
|
|
@@ -235,29 +275,32 @@ public class AccountAuthController {
|
|
|
if (!verification) {
|
|
|
throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "验证码不正确");
|
|
|
}
|
|
|
- } else {
|
|
|
- //注册
|
|
|
- if (!verification) {
|
|
|
- throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "验证码不正确");
|
|
|
- }
|
|
|
- AccountRegisterBo accountRegisterBo = new AccountRegisterBo();
|
|
|
- accountRegisterBo.setAccount(account);
|
|
|
- if (req.getData().getPromotionCode() != null && !req.getData().getPromotionCode().isEmpty()) {
|
|
|
- if (accountAppService.checkPromotion(req.getData().getPromotionId(), req.getData().getPromotionCode())) {
|
|
|
- throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "请输入有效的邀请码");
|
|
|
- }else {
|
|
|
- AccountFinance promotionAccount = accountFinanceService.getByCode(req.getData().getPromotionCode());
|
|
|
- accountRegisterBo.setPromotionId(promotionAccount.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- //设置用户每日限额
|
|
|
- accountRegisterBo.setTransferLimit(TRANSFER_AMOUNT);
|
|
|
- //设置每日提现额度
|
|
|
- accountRegisterBo.setWithdrawalLimit(WITHDRAWAL_AMOUNT);
|
|
|
- //生成推荐码
|
|
|
- accountRegisterBo.setPromotionCode(accountAppService.getPromotionCode());
|
|
|
- accountFinance = accountFinanceService.register(accountRegisterBo);
|
|
|
+ }else {
|
|
|
+ throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "手机号未注册");
|
|
|
}
|
|
|
+// } else {
|
|
|
+// //注册
|
|
|
+// if (!verification) {
|
|
|
+// throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "验证码不正确");
|
|
|
+// }
|
|
|
+// AccountRegisterBo accountRegisterBo = new AccountRegisterBo();
|
|
|
+// accountRegisterBo.setAccount(account);
|
|
|
+// if (req.getData().getPromotionCode() != null && !req.getData().getPromotionCode().isEmpty()) {
|
|
|
+// if (accountAppService.checkPromotion(req.getData().getPromotionId(), req.getData().getPromotionCode())) {
|
|
|
+// throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "请输入有效的邀请码");
|
|
|
+// }else {
|
|
|
+// AccountFinance promotionAccount = accountFinanceService.getByCode(req.getData().getPromotionCode());
|
|
|
+// accountRegisterBo.setPromotionId(promotionAccount.getId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //设置用户每日限额
|
|
|
+// accountRegisterBo.setTransferLimit(TRANSFER_AMOUNT);
|
|
|
+// //设置每日提现额度
|
|
|
+// accountRegisterBo.setWithdrawalLimit(WITHDRAWAL_AMOUNT);
|
|
|
+// //生成推荐码
|
|
|
+// accountRegisterBo.setPromotionCode(accountAppService.getPromotionCode());
|
|
|
+// accountFinance = accountFinanceService.register(accountRegisterBo);
|
|
|
+// }
|
|
|
//生成token
|
|
|
String accessToken = IdUtil.simpleUUID();
|
|
|
//登录
|
|
|
@@ -325,4 +368,41 @@ public class AccountAuthController {
|
|
|
boolean result = accountFinanceService.updatePayPwd(userId, payPwd, salt);
|
|
|
return result ? Result.success() : Result.error("设置支付密码失败");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "实名认证")
|
|
|
+ @PostMapping(value = "real_name_auth")
|
|
|
+ public Result<?> realNameAuth(@RequestBody @Valid BaseReq<IdVerifyReq> req) {
|
|
|
+ if (req.getData() == null) {
|
|
|
+ throw new BusinessException(ErrorCodeEnum.INPUT_PARAMETER_ERROR.getCode(), ErrorCodeEnum.INPUT_PARAMETER_ERROR.getDesc());
|
|
|
+ }
|
|
|
+ IdVerifyReq idVerifyReq = req.getData();
|
|
|
+ String result = idVerifyClientApi.verifyId(idVerifyReq.getIdNumber(),idVerifyReq.getName());
|
|
|
+ //处理逻辑业务
|
|
|
+ AccountFinance accountFinance = new AccountFinance();
|
|
|
+ accountFinance.setIdNumber(idVerifyReq.getIdNumber());
|
|
|
+ accountFinance.setRealName(idVerifyReq.getName());
|
|
|
+ Integer userId = userSessionRedisCache.getLoginUserId(req.getAccessToken());
|
|
|
+ accountFinance.setId(userId);
|
|
|
+ try {
|
|
|
+ String resultBody = result.split("ResultBody:")[1].trim();
|
|
|
+ JSONObject jsonObject = JSON.parseObject(resultBody);
|
|
|
+ int checkresult = jsonObject.getJSONObject("result").getIntValue("checkresult");
|
|
|
+ String message = jsonObject.getJSONObject("result").getString("message");
|
|
|
+ if (checkresult == 1) {
|
|
|
+ accountFinanceService.updateById(accountFinance);
|
|
|
+ return Result.success(message);
|
|
|
+ } else if(checkresult == 2) {
|
|
|
+ return Result.error(message);
|
|
|
+ } else if(checkresult == 3) {
|
|
|
+ return Result.error(message);
|
|
|
+ } else {
|
|
|
+ return Result.error("实名认证失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException(ErrorCodeEnum.FAIL.getCode(), "实名认证失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|