优化上上签个人用户注册 #34

Merged
bgy merged 3 commits from bgy into dev 2023-10-05 12:37:11 +00:00
5 changed files with 77 additions and 42 deletions
@@ -3,7 +3,6 @@ package com.ruoyi.web.controller.bestsign;
import com.ruoyi.bestsign.domain.PersonRegisterVO;
import com.ruoyi.bestsign.service.SignRegisterService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
@@ -106,7 +106,7 @@ spring:
ssq:
developerId: 1695872832013855470
privateKey: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCiDRuz+dxqkWqHdov0hK+KEWLw/e8MQSqkZZ4c01Yr6cSmQiWyV8Xin0u5S/EA02FWxpjLi1nLriVtOBhZGsoryFmcJrwzSnQ5PORP/HhfcAWFE/Y+3qSQS1OiU7e5wbReCgEUvx4GHZuhdu8cOvq5DG9l33YFZrIEMBTmnf8eKT54STx0tjcKl7U6B6nsiThy3zVtpWXVv6H1HGmxC0KT4EQ388s/PFjrwmk+GFb3EpKCns/GQHf7QrtNz1ZOgCXfgQiQ+91/tcngzUH+zMCIxn5lS+ENAxVI6Ev3W9Y0QHtKwmO4ORVuAskJYzBB2xKI/gw8+PUXNziMAKXuoUAjAgMBAAECggEAd7yHw6vTGUrpE76cGsgPjEzcdoSqpLth7qbG9TWSblAEZXRqtiP0q0ZYhUl/gcSuH5gOPhdw+fZq4RCZrP0GdONMkvxsAtn4lnJPoGpD5wC2k2X0hO+tWJDP8xk4n6BozTNHKTUt0gb+f4eJlapep2xwwy0h30vKLR3504zafEV9j/2D8l5TFSv6rd3UVxUvrDKQ9mhfATEUlrTpjs0SfWupMkr4j7TuJJ8qSUSiEADe4hyUB6+LouDZCt8jV4aLojQBJKrQ6VPVdDFkHGsePu4tHtvcKsaOZJ0pjpJ7MT6D5ElD/sJjo0g/3qK5/FToVFVbrxtykVreK6mE5oSTQQKBgQDpEFSgH1d4N7NsZhviaCIUkB97hO0jpRbD7UZirzZ9ok96Fk+SmfhdmypDMoiaRHCNhQuu5dI9mg5RbUhz9mCZnAhzJRL+DmE4bhNvQmbtJA7KT6n/AdH2zy0mYulrcG17dQspvTr/5421PTEE2+FRoCbG6hBsSSUit9HLvAU13QKBgQCx/7ql+hbx+t0Yb02XckBHiA+MWrFLO4dMX9cKf3LldC0nhn0K9HOSoZmM0KcmXRnMo+/4t89xOJRl7JRXwcLoy/64OaUBVv+8FFV1yY4THka3nEnQE40vVWy+vuNJtt+eKlEhJ35N1GIHXo7/4j0POtEuNU7KSqMnLUD+Oy/t/wKBgEiajcJUASuyLnLWXFlrlzJQs34HKtiv1Se0Avk7G/6HUbr2uFMzI+wFKmVEmMl2CJoNmFYjwhruowc6xBdb6TvxH7C/G+uJD0BFCkjeprG5SeI8bvjB2GbKo4YRyiVuIK0VCSU3jemqeLq9FUguN0L2YR4WTIdvQeJO4UxWhkkBAoGBAJk7TxDHZK1XirIYTzGK928c4FWxVWMwkd7buqGc6epBwwV9r3OY0U1vtGIW1W4fQ7B5iIISqpALZyT/Lw0FDqedxWAOr8+hd3IQBynpI1et/q7d6mUoD6ip332tkrjIp2TfhQwHlaGmreUuL+h0eJ/9wEoJNhTLf/yf5o11omM9AoGBAOLVlXR9FbU2Ubpp3HwTumSzKDWzq3T5eQcqC1zE3BPOo29uAf9BQTumPxe51U64egttW/nif5FH4v4Gentmxb2B2ckdOs/u9zIWz3JPfHU7RqMyMokuWrQ6lMoiSYpH3MSHoavLyAEhAnpceX3oktXgpYHO9d8MfON3XKJl23ip
serverHost: http://openapi.bestsign.info/openapi/v2/
serverHost: https://openapi.bestsign.info/openapi/v2/
# token配置
token:
@@ -11,4 +11,8 @@ public interface SignRegisterService {
* @return
*/
AjaxResult registerPerson(PersonRegisterVO personRegisterVO);
/**
* 查询用户认证状态/user/async/applyCert/status/
*/
AjaxResult queryRegisterStatus(PersonRegisterVO personRegisterVO);
}
@@ -1,6 +1,7 @@
package com.ruoyi.bestsign.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.bestsign.domain.PersonRegisterVO;
import com.ruoyi.bestsign.service.SignRegisterService;
import com.ruoyi.bestsign.utils.BestsignOpenApiClient;
@@ -22,14 +23,37 @@ public class RegisterServiceImpl implements SignRegisterService {
@Override
public AjaxResult registerPerson(PersonRegisterVO personRegisterVO) {
try {
String s = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
JSONObject jsonObject = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
personRegisterVO.getName(),
personRegisterVO.getMail(),
personRegisterVO.getMobile(),
personRegisterVO.getCredential().getIdentity(),
personRegisterVO.getCredential().getIdentityType(),
null, null, null, null, null);
AjaxResult.success(s);
null, null, null, null, null, "/user/reg/");
AjaxResult.success(jsonObject);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
}
return AjaxResult.success();
}
/**
* 查询用户认证状态/user/async/applyCert/status/
*
* @param personRegisterVO
*/
@Override
public AjaxResult queryRegisterStatus(PersonRegisterVO personRegisterVO) {
try {
JSONObject jsonObject = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
personRegisterVO.getName(),
personRegisterVO.getMail(),
personRegisterVO.getMobile(),
personRegisterVO.getCredential().getIdentity(),
personRegisterVO.getCredential().getIdentityType(),
null, null, null, null, null, "/user/async/applyCert/status/");
AjaxResult.success(jsonObject);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.validation.constraints.NotNull;
import java.io.IOException;
/**
@@ -31,6 +32,9 @@ public class BestsignOpenApiClient {
*/
@Value("${ssq.serverHost}")
private String serverHost;
/**
* 签名参数
*/
private static String urlSignParams = "?developerId=%s&rtick=%s&signType=rsa&sign=%s";
// public BestsignOpenApiClient(String developerId, String privateKey,
@@ -55,35 +59,37 @@ public class BestsignOpenApiClient {
* @param province 省份
* @param city 城市
* @param address 地址
* @param method 地址
* @return 异步申请任务单号
* @throws IOException
*/
public String userPersonalReg(String account, String name, String mail,
String mobile, String identity, String identityType,
String contactMail, String contactMobile, String province,
String city, String address) throws Exception {
String host = this.serverHost;
String method = "/user/reg/";
// 组装请求参数,作为requestbody
public JSONObject userPersonalReg(String account, String name, String mail,
String mobile, String identity, String identityType,
String contactMail, String contactMobile, String province,
String city, String address, @NotNull String method) throws Exception {
//body参数
JSONObject requestBody = new JSONObject();
requestBody.put("account", account);
requestBody.put("name", name);
requestBody.put("userType", "1");
requestBody.put("mail", mail);
requestBody.put("mobile", mobile);
//用户帐号
requestBody.put("account", account);
//用户名称
requestBody.put("name", name);
//用户类型
requestBody.put("userType", "1");
//用户邮箱
requestBody.put("mail", mail);
//用户手机号
requestBody.put("mobile", mobile);
//用户证件信息对象
JSONObject credential = new JSONObject();
//用户证件号
credential.put("identity", identity);
//用户证件类型
credential.put("identityType", identityType);
credential.put("contactMail", contactMail);
credential.put("contactMobile", contactMobile);
credential.put("province", province);
credential.put("city", city);
credential.put("address", address);
requestBody.put("credential", credential);
//是否申请证书
requestBody.put("applyCert", "2");
requestBody.put("applyCert", "1");
// 生成一个时间戳参数
String rtick = RSAUtils.getRtick();
// 计算参数签名
@@ -100,25 +106,27 @@ public class BestsignOpenApiClient {
System.out.println(responseBody);
// 返回结果解析
JSONObject userObj = JSON.parseObject(responseBody);
System.out.println(JSON.toJSONString(userObj));
return userObj;
// 返回errno为0,表示成功,其他表示失败
if (userObj.getIntValue("errno") == 0) {
JSONObject data = userObj.getJSONObject("data");
if (data != null) {
//对返回data进行处理
String taskId = data.getString("taskId");
return taskId;
}
} else {
//接口返回异常
System.out.println(userObj.getIntValue("errno"));
System.out.println(userObj.getString("errmsg"));
}
return userObj.toJSONString();
// if (userObj.getIntValue("errno") == 0) {
// JSONObject data = userObj.getJSONObject("data");
// if (data != null) {
// //对返回data进行处理
// String taskId = data.getString("taskId");
// return taskId;
// }
// return null;
// } else {
// //接口返回异常
// System.out.println(userObj.getIntValue("errno"));
// System.out.println(userObj.getString("errmsg"));
// throw new Exception(userObj.getIntValue("errno") + ":"
// + userObj.getString("errmsg"));
// }
}
/**
* GET方法示例
* 下载合同PDF文件
@@ -149,7 +157,7 @@ public class BestsignOpenApiClient {
return responseBody;
}
public String selectApplyStatus(String account, String taskId) throws Exception {
public String selectApplyStatus(String account, String taskId) throws Exception {
String methodInvoke = "/user/async/applyCert/status/";
JSONObject requestParam = new JSONObject();
@@ -163,7 +171,7 @@ public class BestsignOpenApiClient {
this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
requestParam.toJSONString());
// 签名参数追加为url参数
String fullUrlParams = String.format(this.urlSignParams, this.developerId,
String fullUrlParams = String.format(urlSignParams, this.developerId,
timestamsParam, paramsSign);
String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
@@ -181,7 +189,7 @@ public class BestsignOpenApiClient {
}
} else {
log.error("查询申请状态异常:"+responseObj.toJSONString());
log.error("查询申请状态异常:" + responseObj.toJSONString());
}
return responseObj.toJSONString();
}