|
|
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
7
|
7
|
import org.springframework.beans.factory.annotation.Value;
|
|
8
|
8
|
import org.springframework.stereotype.Component;
|
|
9
|
9
|
|
|
|
10
|
+import javax.validation.constraints.NotNull;
|
|
10
|
11
|
import java.io.IOException;
|
|
11
|
12
|
|
|
12
|
13
|
/**
|
|
|
@@ -31,6 +32,9 @@ public class BestsignOpenApiClient {
|
|
31
|
32
|
*/
|
|
32
|
33
|
@Value("${ssq.serverHost}")
|
|
33
|
34
|
private String serverHost;
|
|
|
35
|
+ /**
|
|
|
36
|
+ * 签名参数
|
|
|
37
|
+ */
|
|
34
|
38
|
private static String urlSignParams = "?developerId=%s&rtick=%s&signType=rsa&sign=%s";
|
|
35
|
39
|
|
|
36
|
40
|
// public BestsignOpenApiClient(String developerId, String privateKey,
|
|
|
@@ -55,35 +59,37 @@ public class BestsignOpenApiClient {
|
|
55
|
59
|
* @param province 省份
|
|
56
|
60
|
* @param city 城市
|
|
57
|
61
|
* @param address 地址
|
|
|
62
|
+ * @param method 地址
|
|
58
|
63
|
* @return 异步申请任务单号
|
|
59
|
64
|
* @throws IOException
|
|
60
|
65
|
*/
|
|
61
|
|
- public String userPersonalReg(String account, String name, String mail,
|
|
62
|
|
- String mobile, String identity, String identityType,
|
|
63
|
|
- String contactMail, String contactMobile, String province,
|
|
64
|
|
- String city, String address) throws Exception {
|
|
65
|
|
- String host = this.serverHost;
|
|
66
|
|
- String method = "/user/reg/";
|
|
67
|
|
-
|
|
68
|
|
- // 组装请求参数,作为requestbody
|
|
|
66
|
+ public JSONObject userPersonalReg(String account, String name, String mail,
|
|
|
67
|
+ String mobile, String identity, String identityType,
|
|
|
68
|
+ String contactMail, String contactMobile, String province,
|
|
|
69
|
+ String city, String address, @NotNull String method) throws Exception {
|
|
|
70
|
+ //body参数
|
|
69
|
71
|
JSONObject requestBody = new JSONObject();
|
|
|
72
|
+
|
|
|
73
|
+ //用户帐号
|
|
70
|
74
|
requestBody.put("account", account);
|
|
|
75
|
+ //用户名称
|
|
71
|
76
|
requestBody.put("name", name);
|
|
|
77
|
+ //用户类型
|
|
72
|
78
|
requestBody.put("userType", "1");
|
|
|
79
|
+ //用户邮箱
|
|
73
|
80
|
requestBody.put("mail", mail);
|
|
|
81
|
+ //用户手机号
|
|
74
|
82
|
requestBody.put("mobile", mobile);
|
|
75
|
|
-
|
|
|
83
|
+ //用户证件信息对象
|
|
76
|
84
|
JSONObject credential = new JSONObject();
|
|
|
85
|
+ //用户证件号
|
|
77
|
86
|
credential.put("identity", identity);
|
|
|
87
|
+ //用户证件类型
|
|
78
|
88
|
credential.put("identityType", identityType);
|
|
79
|
|
- credential.put("contactMail", contactMail);
|
|
80
|
|
- credential.put("contactMobile", contactMobile);
|
|
81
|
|
- credential.put("province", province);
|
|
82
|
|
- credential.put("city", city);
|
|
83
|
|
- credential.put("address", address);
|
|
84
|
89
|
requestBody.put("credential", credential);
|
|
|
90
|
+
|
|
85
|
91
|
//是否申请证书
|
|
86
|
|
- requestBody.put("applyCert", "2");
|
|
|
92
|
+ requestBody.put("applyCert", "1");
|
|
87
|
93
|
// 生成一个时间戳参数
|
|
88
|
94
|
String rtick = RSAUtils.getRtick();
|
|
89
|
95
|
// 计算参数签名
|
|
|
@@ -100,25 +106,27 @@ public class BestsignOpenApiClient {
|
|
100
|
106
|
System.out.println(responseBody);
|
|
101
|
107
|
// 返回结果解析
|
|
102
|
108
|
JSONObject userObj = JSON.parseObject(responseBody);
|
|
|
109
|
+ System.out.println(JSON.toJSONString(userObj));
|
|
|
110
|
+ return userObj;
|
|
103
|
111
|
// 返回errno为0,表示成功,其他表示失败
|
|
104
|
|
- if (userObj.getIntValue("errno") == 0) {
|
|
105
|
|
- JSONObject data = userObj.getJSONObject("data");
|
|
106
|
|
- if (data != null) {
|
|
107
|
|
- //对返回data进行处理
|
|
108
|
|
- String taskId = data.getString("taskId");
|
|
109
|
|
- return taskId;
|
|
110
|
|
- }
|
|
111
|
|
- } else {
|
|
112
|
|
- //接口返回异常
|
|
113
|
|
- System.out.println(userObj.getIntValue("errno"));
|
|
114
|
|
- System.out.println(userObj.getString("errmsg"));
|
|
115
|
|
- }
|
|
116
|
|
- return userObj.toJSONString();
|
|
|
112
|
+// if (userObj.getIntValue("errno") == 0) {
|
|
|
113
|
+// JSONObject data = userObj.getJSONObject("data");
|
|
|
114
|
+// if (data != null) {
|
|
|
115
|
+// //对返回data进行处理
|
|
|
116
|
+// String taskId = data.getString("taskId");
|
|
|
117
|
+// return taskId;
|
|
|
118
|
+// }
|
|
|
119
|
+// return null;
|
|
|
120
|
+// } else {
|
|
|
121
|
+// //接口返回异常
|
|
|
122
|
+// System.out.println(userObj.getIntValue("errno"));
|
|
|
123
|
+// System.out.println(userObj.getString("errmsg"));
|
|
|
124
|
+// throw new Exception(userObj.getIntValue("errno") + ":"
|
|
|
125
|
+// + userObj.getString("errmsg"));
|
|
|
126
|
+// }
|
|
117
|
127
|
}
|
|
118
|
128
|
|
|
119
|
129
|
|
|
120
|
|
-
|
|
121
|
|
-
|
|
122
|
130
|
/**
|
|
123
|
131
|
* GET方法示例
|
|
124
|
132
|
* 下载合同PDF文件
|
|
|
@@ -149,7 +157,7 @@ public class BestsignOpenApiClient {
|
|
149
|
157
|
return responseBody;
|
|
150
|
158
|
}
|
|
151
|
159
|
|
|
152
|
|
- public String selectApplyStatus(String account, String taskId) throws Exception {
|
|
|
160
|
+ public String selectApplyStatus(String account, String taskId) throws Exception {
|
|
153
|
161
|
String methodInvoke = "/user/async/applyCert/status/";
|
|
154
|
162
|
JSONObject requestParam = new JSONObject();
|
|
155
|
163
|
|
|
|
@@ -163,7 +171,7 @@ public class BestsignOpenApiClient {
|
|
163
|
171
|
this.privateKey, this.serverHost, methodInvoke, timestamsParam, null,
|
|
164
|
172
|
requestParam.toJSONString());
|
|
165
|
173
|
// 签名参数追加为url参数
|
|
166
|
|
- String fullUrlParams = String.format(this.urlSignParams, this.developerId,
|
|
|
174
|
+ String fullUrlParams = String.format(urlSignParams, this.developerId,
|
|
167
|
175
|
timestamsParam, paramsSign);
|
|
168
|
176
|
|
|
169
|
177
|
String responseResult = HttpClientSender.sendHttpPost(this.serverHost, methodInvoke,
|
|
|
@@ -181,7 +189,7 @@ public class BestsignOpenApiClient {
|
|
181
|
189
|
}
|
|
182
|
190
|
} else {
|
|
183
|
191
|
|
|
184
|
|
- log.error("查询申请状态异常:"+responseObj.toJSONString());
|
|
|
192
|
+ log.error("查询申请状态异常:" + responseObj.toJSONString());
|
|
185
|
193
|
}
|
|
186
|
194
|
return responseObj.toJSONString();
|
|
187
|
195
|
}
|