feat:短信认证
This commit is contained in:
1 parent
fc83656496
commit
f56d578fbb
7 files changed
+45
-28
No files matched your search
+1
-1
@@ -64,7 +64,7 @@ public interface MemberErrorCode {
|
||||
ErrorCode VIEW_RECORD_NOT_EXISTS = new ErrorCode(2_001_000_004, "用户查看记录不存在");
|
||||
ErrorCode COM_AUTH_NOT_EXISTS = new ErrorCode(2_001_000_005, "通用认证不存在");
|
||||
ErrorCode COM_AUTH_EXISTS = new ErrorCode(2_001_000_005, "正在认证中,请勿重复发起");
|
||||
ErrorCode THIRD_AUTH_START_ERROR = new ErrorCode(2_001_000_006, "第三方认证发起失败");
|
||||
ErrorCode THIRD_AUTH_START_ERROR = new ErrorCode(2_001_000_006, "第三方认证发起失败,{}");
|
||||
|
||||
//========== 用户图片、视频资源管理 1-004-013-000 ==========
|
||||
ErrorCode PHOTO_NOT_EXISTS = new ErrorCode(1_004_013_000, "用户资源不存在");
|
||||
|
||||
+4
-1
@@ -61,6 +61,9 @@ public class ThirdFaceVerifyServiceImpl implements ThirdFaceVerifyService {
|
||||
InitFaceVerifyResponseBody.InitFaceVerifyResponseBodyResultObject resultObject = body.getResultObject();
|
||||
|
||||
ThirdFaceVerifyResVO result = new ThirdFaceVerifyResVO();
|
||||
if (ObjectUtil.notEqual(body.getCode(), "200")) {
|
||||
result.setErrorMessage(body.getMessage());
|
||||
}
|
||||
result.setCertifyId(resultObject.getCertifyId());
|
||||
result.setCertifyUrl(resultObject.getCertifyUrl());
|
||||
return result;
|
||||
@@ -121,7 +124,7 @@ public class ThirdFaceVerifyServiceImpl implements ThirdFaceVerifyService {
|
||||
result.setErrorMessage(body.getMessage());
|
||||
}
|
||||
DescribeFaceVerifyResponseBody.DescribeFaceVerifyResponseBodyResultObject resultObject = body.getResultObject();
|
||||
BeanUtil.toBean(resultObject, ThirdFindFaceVerifyResVo.class);
|
||||
result = BeanUtil.toBean(resultObject, ThirdFindFaceVerifyResVo.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -13,8 +13,10 @@ public class ThirdFaceVerifyResVO {
|
||||
|
||||
private String certifyUrl;
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
public boolean isPass() {
|
||||
return ObjectUtil.isAllNotEmpty(certifyId);
|
||||
return ObjectUtil.isAllNotEmpty(certifyId) && ObjectUtil.isEmpty(errorMessage);
|
||||
}
|
||||
|
||||
public boolean isFail() {
|
||||
|
||||
+7
-7
@@ -14,28 +14,28 @@ public class ThirdFindFaceVerifyResVo {
|
||||
* T:通过
|
||||
* F:不通过
|
||||
*/
|
||||
private String Passed;
|
||||
private String passed;
|
||||
|
||||
/**
|
||||
* 认证结果描述
|
||||
* 200:成功
|
||||
*/
|
||||
private String SubCode;
|
||||
private String subCode;
|
||||
|
||||
/**
|
||||
* 认证的主体信息,一般的认证场景返回为空
|
||||
*/
|
||||
private String IdentityInfo;
|
||||
private String identityInfo;
|
||||
|
||||
/**
|
||||
* 设备Token
|
||||
*/
|
||||
private String DeviceToken;
|
||||
private String deviceToken;
|
||||
|
||||
/**
|
||||
* 人脸认证主体附件信息
|
||||
*/
|
||||
private String MaterialInfo;
|
||||
private String materialInfo;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
@@ -46,14 +46,14 @@ public class ThirdFindFaceVerifyResVo {
|
||||
* 验证通过
|
||||
*/
|
||||
public boolean isPassed() {
|
||||
return ObjectUtil.equals("T", Passed);
|
||||
return ObjectUtil.equals("T", passed);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证未通过
|
||||
*/
|
||||
public boolean isNotPassed() {
|
||||
return ObjectUtil.equals("F", Passed);
|
||||
return ObjectUtil.equals("F", passed);
|
||||
}
|
||||
|
||||
}
|
||||
+19
-7
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.controller.admin.thirdcallback;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.module.member.client.service.ThirdFaceVerifyService;
|
||||
import cn.iocoder.yudao.module.member.client.vo.thirdfaceverify.ThirdFindFaceVerifyReqVo;
|
||||
@@ -10,6 +11,7 @@ import cn.iocoder.yudao.module.member.controller.admin.thirdcallback.vo.FaceVeri
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.comauth.ComAuthDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.comauth.ComAuthMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.auth.MemberComAuthStatusEnum;
|
||||
import cn.iocoder.yudao.module.member.framework.web.config.ThirdAlConfig;
|
||||
import cn.iocoder.yudao.module.member.service.comauth.ComAuthService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -29,13 +31,16 @@ import java.time.LocalDateTime;
|
||||
public class ThirdCallbackController {
|
||||
|
||||
@Resource
|
||||
private ComAuthService comAuthService;
|
||||
@Resource
|
||||
private ThirdFaceVerifyService thirdFaceVerifyService;
|
||||
private ThirdAlConfig thirdAlConfig;
|
||||
|
||||
@Resource
|
||||
private ComAuthMapper comAuthMapper;
|
||||
@Resource
|
||||
private ComAuthMapper authMapper;
|
||||
|
||||
@Resource
|
||||
private ThirdFaceVerifyService thirdFaceVerifyService;
|
||||
|
||||
@GetMapping("/face-verify")
|
||||
@Operation(summary = "人脸认证回调")
|
||||
@PermitAll
|
||||
@@ -46,14 +51,21 @@ public class ThirdCallbackController {
|
||||
log.error("人脸认证回调,参数错误");
|
||||
return;
|
||||
}
|
||||
Long authId = Long.valueOf(query.getCertifyId());
|
||||
// 检查token
|
||||
if (ObjectUtil.notEqual(query.getCallbackToken(), thirdAlConfig.getFaceVerifyCallbackToken())) {
|
||||
log.error("人脸认证回调,token校验错误,传入的token={}", query.getCallbackToken());
|
||||
return;
|
||||
}
|
||||
String certifyId = query.getCertifyId();
|
||||
// 查询认证订单
|
||||
ComAuthDO auth = comAuthService.getAuth(authId);
|
||||
ComAuthDO auth = comAuthMapper.selectOne(new LambdaQueryWrapperX<ComAuthDO>()
|
||||
.eq(ComAuthDO::getBizId, certifyId)
|
||||
.last("limit 1")
|
||||
);
|
||||
if (ObjectUtil.isEmpty(auth)) {
|
||||
log.error("人脸认证回调,认证订单不存在,authId={}", query.getCertifyId());
|
||||
return;
|
||||
}
|
||||
|
||||
// 手动查询
|
||||
ThirdFindFaceVerifyReqVo dto = new ThirdFindFaceVerifyReqVo();
|
||||
dto.setCertifyId(query.getCertifyId());
|
||||
@@ -70,7 +82,7 @@ public class ThirdCallbackController {
|
||||
if (faceVerifyRes.isNotPassed()) {
|
||||
updateObj.setAuthStatus(MemberComAuthStatusEnum.CHECK_FAIL.getType());
|
||||
}
|
||||
updateObj.setId(authId);
|
||||
updateObj.setId(auth.getId());
|
||||
updateObj.setAuthTime(LocalDateTime.now());
|
||||
updateObj.setFailReason("验证失败");
|
||||
authMapper.updateById(updateObj);
|
||||
|
||||
+10
-10
@@ -72,7 +72,8 @@ public class ComAuthServiceImpl implements ComAuthService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ComAuthDO createManAuth(CreateManAuthReqVo dto) {
|
||||
isStartAuth(dto.getMemberId());
|
||||
ComAuthDO startAuth = isStartAuth(dto.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(startAuth)) return startAuth;
|
||||
// 新增
|
||||
ComAuthDO saveObj = new ComAuthDO();
|
||||
saveObj.setAuthMemberId(dto.getMemberId());
|
||||
@@ -101,7 +102,8 @@ public class ComAuthServiceImpl implements ComAuthService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ComAuthDO createWomanAuth(CreateWomanAuthReqVo dto) {
|
||||
isStartAuth(dto.getMemberId());
|
||||
ComAuthDO startAuth = isStartAuth(dto.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(startAuth)) return startAuth;
|
||||
// 新增auth
|
||||
ComAuthDO saveObj = new ComAuthDO();
|
||||
saveObj.setAuthMemberId(dto.getMemberId());
|
||||
@@ -128,15 +130,12 @@ public class ComAuthServiceImpl implements ComAuthService {
|
||||
return authMapper.selectById(saveObj.getId());
|
||||
}
|
||||
|
||||
public void isStartAuth(Long userId) {
|
||||
public ComAuthDO isStartAuth(Long userId) {
|
||||
ComAuthDO userAuth = getSelf().getUserAuth(userId);
|
||||
if (ObjectUtil.isEmpty(userAuth)) return;
|
||||
if (ObjectUtil.isEmpty(userAuth)) {
|
||||
throw exception(MemberErrorCode.COM_AUTH_NOT_EXISTS);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(userAuth)) return null;
|
||||
List<String> isStartEnumList = Arrays.asList(MemberComAuthStatusEnum.WAIT_AUTH.getType(), MemberComAuthStatusEnum.CHECK.getType());
|
||||
if (ObjectUtil.isNotEmpty(userAuth.getBizId()) && !isStartEnumList.contains(userAuth.getAuthStatus())) {
|
||||
return;
|
||||
if (ObjectUtil.isNotEmpty(userAuth.getBizId()) && isStartEnumList.contains(userAuth.getAuthStatus())) {
|
||||
return userAuth;
|
||||
}
|
||||
throw exception(MemberErrorCode.COM_AUTH_EXISTS);
|
||||
}
|
||||
@@ -153,7 +152,7 @@ public class ComAuthServiceImpl implements ComAuthService {
|
||||
dto.setFaceVerifyUserId(auth.getAuthMemberId());
|
||||
ThirdFaceVerifyResVO thirdRes = thirdFaceVerifyService.faceVerify(dto);
|
||||
if (ObjectUtil.isEmpty(thirdRes) || thirdRes.isFail()) {
|
||||
throw exception(MemberErrorCode.THIRD_AUTH_START_ERROR);
|
||||
throw exception(MemberErrorCode.THIRD_AUTH_START_ERROR, thirdRes.getErrorMessage());
|
||||
}
|
||||
if (thirdRes.isPass()) {
|
||||
// 更新auth
|
||||
@@ -253,6 +252,7 @@ public class ComAuthServiceImpl implements ComAuthService {
|
||||
totalSync++;
|
||||
updateList.add(entity);
|
||||
}
|
||||
authMapper.updateBatch(updateList);
|
||||
return totalSync;
|
||||
}
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ yudao:
|
||||
expire-times: 10m
|
||||
send-frequency: 1m
|
||||
send-maximum-quantity-per-day: 10
|
||||
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||
begin-code: 0000 # 这里配置 9999 的原因是,测试方便。
|
||||
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
|
||||
trade:
|
||||
order:
|
||||
|
||||
Reference in new issue
Block a user