|
@@ -0,0 +1,396 @@
|
|
1
|
+package com.huiju.estateagents;
|
|
2
|
+
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
4
|
+import com.alibaba.fastjson.JSONArray;
|
|
5
|
+import com.alibaba.fastjson.JSONObject;
|
|
6
|
+import com.fadada.sdk.client.FddClientBase;
|
|
7
|
+import com.fadada.sdk.client.FddClientExtra;
|
|
8
|
+import com.fadada.sdk.client.authForfadada.*;
|
|
9
|
+import com.fadada.sdk.client.authForfadada.model.AgentInfoINO;
|
|
10
|
+import com.fadada.sdk.client.authForfadada.model.BankInfoINO;
|
|
11
|
+import com.fadada.sdk.client.authForfadada.model.CompanyInfoINO;
|
|
12
|
+import com.fadada.sdk.client.authForfadada.model.LegalInfoINO;
|
|
13
|
+import com.fadada.sdk.client.request.ExtsignReq;
|
|
14
|
+import com.fadada.sdk.test.util.ConfigUtil;
|
|
15
|
+import com.fadada.sdk.util.http.HttpsUtil;
|
|
16
|
+import jodd.util.URLDecoder;
|
|
17
|
+import org.apache.commons.codec.binary.Base64;
|
|
18
|
+import org.junit.After;
|
|
19
|
+import org.junit.Before;
|
|
20
|
+import org.junit.Test;
|
|
21
|
+import org.junit.runner.RunWith;
|
|
22
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
23
|
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
24
|
+import org.springframework.transaction.annotation.Transactional;
|
|
25
|
+
|
|
26
|
+import java.io.File;
|
|
27
|
+import java.io.IOException;
|
|
28
|
+import java.io.UnsupportedEncodingException;
|
|
29
|
+
|
|
30
|
+@RunWith(SpringJUnit4ClassRunner.class)
|
|
31
|
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
32
|
+@Transactional
|
|
33
|
+public class FdadaTest {
|
|
34
|
+ private static String APP_ID = "";
|
|
35
|
+ private static String APP_SECRET = "";
|
|
36
|
+ private static String V = "2.0";
|
|
37
|
+ private static String HOST = "https://testapi.fadada.com:8443/api/";
|
|
38
|
+
|
|
39
|
+ private String customer_name;
|
|
40
|
+ private String id_card = "";// 身份证号码;
|
|
41
|
+ private String ident_type = "";// 身份证类型 ;
|
|
42
|
+ private String mobile;
|
|
43
|
+ private String contract_id;
|
|
44
|
+ private String template_id;
|
|
45
|
+ private String transaction_id;
|
|
46
|
+ private String email;
|
|
47
|
+ private File file;
|
|
48
|
+ private StringBuffer response = new StringBuffer("==================Welcome ^_^ ==================");
|
|
49
|
+ @Before
|
|
50
|
+ public void before() {
|
|
51
|
+ String timeStamp = HttpsUtil.getTimeStamp();
|
|
52
|
+
|
|
53
|
+ customer_name = ConfigUtil.getPersonName();
|
|
54
|
+ contract_id = "CONT" + timeStamp;// 直接上传接口合同编号
|
|
55
|
+ template_id = "TEMP" + timeStamp;// 模板编号
|
|
56
|
+ transaction_id = "TRAN_" + timeStamp;// 手动签交易号
|
|
57
|
+ email = "ep" + timeStamp + "@fadada.com";// 个人邮箱
|
|
58
|
+ id_card = "";// 身份证号码;
|
|
59
|
+ mobile = "";// 手机号;
|
|
60
|
+ file = new File(ConfigUtil.getFilePath());
|
|
61
|
+
|
|
62
|
+ response.append("\n").append("名字:").append(customer_name);
|
|
63
|
+ response.append("\n").append("身份证号码:").append(id_card);
|
|
64
|
+ response.append("\n").append("证件类型:").append(ident_type);
|
|
65
|
+ response.append("\n").append("手机号:").append(mobile);
|
|
66
|
+ response.append("\n").append("邮箱:").append(email);
|
|
67
|
+ response.append("\n").append("上传合同编号:").append(contract_id);
|
|
68
|
+ response.append("\n").append("上传模板编号:").append(template_id);
|
|
69
|
+ response.append("\n").append("手动签交易号:").append(transaction_id);
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+ /*=============法大大实名测试=============*/
|
|
74
|
+ @Test
|
|
75
|
+ public void Test1(){
|
|
76
|
+ regAccount();//1注册账号
|
|
77
|
+ getAuthCompanyurl();//2获取企业实名认证地址
|
|
78
|
+ getAuthPersonurl();//3获取个人实名认证地址
|
|
79
|
+ findPersonCertInfo();//17 查询个人实名认证信息
|
|
80
|
+ findCompanyCertInfo();//18 查询企业实名认证信息
|
|
81
|
+ GetFileForUUID();//19 通过uuid下载文件
|
|
82
|
+ ApplyCert();//4实名证书申请
|
|
83
|
+ ApplyNumCert();//5编号证书申请
|
|
84
|
+ addSignature1();//6印章上传
|
|
85
|
+ addSignature2();//6印章上传
|
|
86
|
+ customSignature();//7自定义印章
|
|
87
|
+
|
|
88
|
+ }
|
|
89
|
+ @Test
|
|
90
|
+ public void Test2(){
|
|
91
|
+ uploadContract();//8合同上传
|
|
92
|
+ uploadTemplate();//9模板上传
|
|
93
|
+ GenerateContract();//10模板填充
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ @Test
|
|
97
|
+ public void Test3(){
|
|
98
|
+ uploadContract();//8合同上传
|
|
99
|
+ extsign();//12手动签署接口
|
|
100
|
+ extsignAuto();//11自动签署
|
|
101
|
+ viewContract();//13合同查看
|
|
102
|
+ downloadContract();//14合同下载
|
|
103
|
+ contractFiling();//15合同归档
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ /*=============注册账号=============*/
|
|
107
|
+ public void regAccount(){
|
|
108
|
+ response.append("\n").append("注册账号:");
|
|
109
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
110
|
+ String open_id = transaction_id;
|
|
111
|
+ String account_type = "";
|
|
112
|
+ String result =base.invokeregisterAccount(open_id,account_type);
|
|
113
|
+ response.append("\n").append(result);
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ /*=============获取企业实名认证地址=============*/
|
|
117
|
+ public void getAuthCompanyurl(){
|
|
118
|
+ response.append("\n").append("获取企业实名认证地址:");
|
|
119
|
+ GetCompanyVerifyUrl comverify = new GetCompanyVerifyUrl(APP_ID,APP_SECRET,V,HOST);
|
|
120
|
+ CompanyInfoINO companyInfo = new CompanyInfoINO();
|
|
121
|
+ companyInfo.setCompany_name("");
|
|
122
|
+ companyInfo.setCredit_no("");
|
|
123
|
+ companyInfo.setCredit_image_path("");
|
|
124
|
+
|
|
125
|
+ BankInfoINO bankInfo = new BankInfoINO();
|
|
126
|
+ bankInfo.setBank_name("");
|
|
127
|
+ bankInfo.setBank_id("");
|
|
128
|
+ bankInfo.setSubbranch_name("");
|
|
129
|
+
|
|
130
|
+ LegalInfoINO legalInfo = new LegalInfoINO();
|
|
131
|
+ legalInfo.setLegal_name("");
|
|
132
|
+ legalInfo.setLegal_id("");
|
|
133
|
+ legalInfo.setLegal_mobile("");
|
|
134
|
+ legalInfo.setLegal_id_front_path("");
|
|
135
|
+
|
|
136
|
+ AgentInfoINO agentInfo = new AgentInfoINO();
|
|
137
|
+ agentInfo.setAgent_name("");
|
|
138
|
+ agentInfo.setAgent_id("");
|
|
139
|
+ agentInfo.setAgent_mobile("");
|
|
140
|
+ agentInfo.setAgent_id_front_path("");
|
|
141
|
+ String customer_id = "";//必填
|
|
142
|
+ /**
|
|
143
|
+ * 实名认证套餐类型
|
|
144
|
+ * 0:标准方案(对公打款+纸质审核)默认0;
|
|
145
|
+ * 1:对公打款;
|
|
146
|
+ * 2:纸质审核',
|
|
147
|
+ */
|
|
148
|
+ String verifyed_way = "";
|
|
149
|
+ String page_modify = "1";//必填
|
|
150
|
+ String m_verified_way = "0";//实名认证套餐类型
|
|
151
|
+
|
|
152
|
+ String company_principal_type = "1";//1.法人,2代理人
|
|
153
|
+ String notify_url = "http://www.baidu.com";//必填
|
|
154
|
+ String return_url = "http://www.baidu.com";//可填
|
|
155
|
+ String result = comverify.invokeCompanyVerifyUrl(companyInfo,bankInfo,legalInfo
|
|
156
|
+ ,agentInfo, customer_id,verifyed_way,m_verified_way,page_modify,
|
|
157
|
+ company_principal_type,return_url,notify_url,"","");
|
|
158
|
+ response.append("\n").append(result);
|
|
159
|
+ String data = JSON.parseObject(result).getString("data");
|
|
160
|
+ if (null !=data){
|
|
161
|
+ String url = JSON.parseObject(data).getString("url");
|
|
162
|
+ url = decode(url);
|
|
163
|
+ System.out.println(url);
|
|
164
|
+ }
|
|
165
|
+ }
|
|
166
|
+ /*=============获取个人实名认证地址=============*/
|
|
167
|
+ public void getAuthPersonurl(){
|
|
168
|
+ response.append("\n").append("获取个人实名认证地址:");
|
|
169
|
+ GetPersonVerifyUrl personverify = new GetPersonVerifyUrl(APP_ID,APP_SECRET,V,HOST);
|
|
170
|
+ String customer_id = "";
|
|
171
|
+ String verifyed_way = "0";
|
|
172
|
+ String page_modify = "1";
|
|
173
|
+ String notify_url = "https://www.baidu.com";
|
|
174
|
+ String return_url= "https://www.baidu.com";
|
|
175
|
+ String customer_name = "";
|
|
176
|
+ String customer_ident_type = "0";
|
|
177
|
+ String customer_ident_no ="";
|
|
178
|
+ String mobile ="";
|
|
179
|
+ String ident_front_path ="";
|
|
180
|
+ String result = personverify.invokePersonVerifyUrl(customer_id,verifyed_way,
|
|
181
|
+ page_modify,notify_url,return_url,customer_name,customer_ident_type,
|
|
182
|
+ customer_ident_no,mobile,ident_front_path,"","");
|
|
183
|
+ response.append("\n").append(result);
|
|
184
|
+ String data = JSON.parseObject(result).getString("data");
|
|
185
|
+ if (null !=data){
|
|
186
|
+ String url = JSON.parseObject(data).getString("url");
|
|
187
|
+ url = decode(url);
|
|
188
|
+ System.out.println(url);
|
|
189
|
+ }
|
|
190
|
+ }
|
|
191
|
+
|
|
192
|
+ /*=============查询个人实名认证信息=============*/
|
|
193
|
+ public void findPersonCertInfo(){
|
|
194
|
+ response.append("\n").append("查询个人实名认证信息:");
|
|
195
|
+ FindCertInfo personCertInfo = new FindCertInfo(APP_ID,APP_SECRET,V,HOST);
|
|
196
|
+ String verified_serialno = "";
|
|
197
|
+ String result = personCertInfo.invokeFindPersonCert(verified_serialno,
|
|
198
|
+ "1");
|
|
199
|
+ response.append("\n").append(result);
|
|
200
|
+ }
|
|
201
|
+ /*=============查询企业实名认证信息=============*/
|
|
202
|
+ public void findCompanyCertInfo(){
|
|
203
|
+ response.append("\n").append("查询企业实名认证信息:");
|
|
204
|
+ FindCertInfo personCertInfo = new FindCertInfo(APP_ID,APP_SECRET,V,HOST);
|
|
205
|
+ String verified_serialno = "";
|
|
206
|
+ String result = personCertInfo.invokeFindPersonCert(verified_serialno,
|
|
207
|
+ "2");
|
|
208
|
+ response.append("\n").append(result);
|
|
209
|
+ }
|
|
210
|
+
|
|
211
|
+ public void ApplyCert(){
|
|
212
|
+ response.append("\n").append("申请实名证书:");
|
|
213
|
+ ApplyCert applyCert = new ApplyCert(APP_ID,APP_SECRET,V,HOST);
|
|
214
|
+ String customer_id = "";
|
|
215
|
+ String verified_serialno= "";
|
|
216
|
+ String result = applyCert.invokeApplyCert(customer_id,verified_serialno);
|
|
217
|
+ response.append("\n").append(result);
|
|
218
|
+ }
|
|
219
|
+
|
|
220
|
+ public void ApplyNumCert(){
|
|
221
|
+ response.append("\n").append("编号证书申请:");
|
|
222
|
+ ApplyNumCert applyNumCert = new ApplyNumCert(APP_ID,APP_SECRET,V,HOST);
|
|
223
|
+ String customer_id = "";
|
|
224
|
+ String verified_serialno= "";
|
|
225
|
+ String result = applyNumCert.invokeapplyNumcert(customer_id,verified_serialno);
|
|
226
|
+ response.append("\n").append(result);
|
|
227
|
+ }
|
|
228
|
+
|
|
229
|
+ public void GetFileForUUID(){
|
|
230
|
+ response.append("\n").append("通过uuid下载文件地址:");
|
|
231
|
+ GetFileForUUID getFileForUUID = new GetFileForUUID(APP_ID,APP_SECRET,V,HOST);
|
|
232
|
+ String uuid = "";
|
|
233
|
+ String result = getFileForUUID.invokeFileForUUID(uuid);
|
|
234
|
+ response.append("\n").append(result);
|
|
235
|
+ }
|
|
236
|
+
|
|
237
|
+ public void addSignature1(){
|
|
238
|
+ response.append("\n").append("印章上传:");
|
|
239
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
240
|
+ File imgfile = new File("");
|
|
241
|
+ String result = base.invokeaddSignature("",imgfile,"");
|
|
242
|
+ response.append("\n").append(result);
|
|
243
|
+ }
|
|
244
|
+ public void addSignature2(){
|
|
245
|
+ response.append("\n").append("印章上传:");
|
|
246
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
247
|
+ String signature_img_base64 = "";
|
|
248
|
+ String result = base.invokeaddSignature("",signature_img_base64);
|
|
249
|
+ response.append("\n").append(result);
|
|
250
|
+ }
|
|
251
|
+ public void customSignature(){
|
|
252
|
+ response.append("\n").append("自定义印章:");
|
|
253
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
254
|
+ String customer_id ="";
|
|
255
|
+ String content ="content";
|
|
256
|
+ String result = base.invokecustomSignature(customer_id,content);
|
|
257
|
+ response.append("\n").append(result);
|
|
258
|
+ }
|
|
259
|
+
|
|
260
|
+ public void uploadContract() {
|
|
261
|
+ response.append("\n").append("上传合同接口");
|
|
262
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
263
|
+ String result = base.invokeUploadDocs(contract_id, "合同标题", null, "", ".pdf");
|
|
264
|
+ response.append("\n").append(result);
|
|
265
|
+ }
|
|
266
|
+ public void uploadTemplate() {
|
|
267
|
+ response.append("\n").append("上传模板");
|
|
268
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
269
|
+ String doc_url ="";
|
|
270
|
+ String result = base.invokeUploadTemplate(template_id, file, doc_url);
|
|
271
|
+ response.append("\n").append(result);
|
|
272
|
+ }
|
|
273
|
+ public void GenerateContract() {
|
|
274
|
+ try {
|
|
275
|
+ response.append("\n").append("合同生成");
|
|
276
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
277
|
+ String font_size = "";
|
|
278
|
+ String font_type = "";
|
|
279
|
+ String paramter = "";
|
|
280
|
+ paramter = getparamter();
|
|
281
|
+ String dynamic_tables = "";
|
|
282
|
+ dynamic_tables = getdynamic_tables();
|
|
283
|
+ String result = base.invokeGenerateContract(template_id, contract_id, "", font_size, font_type, paramter, dynamic_tables);
|
|
284
|
+ response.append("\n").append(result);
|
|
285
|
+ String viewpdf_url = JSON.parseObject(result).getString("viewpdf_url");
|
|
286
|
+ Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + viewpdf_url);
|
|
287
|
+ } catch (Exception e) {
|
|
288
|
+ e.printStackTrace();
|
|
289
|
+ }
|
|
290
|
+ }
|
|
291
|
+
|
|
292
|
+ public void extsign(){
|
|
293
|
+ response.append("\n").append("手动签署接口:");
|
|
294
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
295
|
+ ExtsignReq req = new ExtsignReq();
|
|
296
|
+ req.setCustomer_id("");
|
|
297
|
+ req.setTransaction_id(transaction_id);
|
|
298
|
+ req.setContract_id("");
|
|
299
|
+ req.setDoc_title("1");
|
|
300
|
+ req.setReturn_url("");
|
|
301
|
+ String result = base.invokeExtSign(req);
|
|
302
|
+ response.append("\n").append(result);
|
|
303
|
+ }
|
|
304
|
+
|
|
305
|
+ public void extsignAuto() {
|
|
306
|
+ try {
|
|
307
|
+ response.append("\n").append("自动签");
|
|
308
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
309
|
+ ExtsignReq req = new ExtsignReq();
|
|
310
|
+ req.setCustomer_id("");
|
|
311
|
+ req.setTransaction_id(transaction_id);
|
|
312
|
+ req.setContract_id("");
|
|
313
|
+ req.setClient_role("1");
|
|
314
|
+ req.setSign_keyword("");
|
|
315
|
+ req.setDoc_title("1");
|
|
316
|
+ String result = base.invokeExtSignAuto(req);
|
|
317
|
+ response.append("\n").append(result);
|
|
318
|
+ String viewpdf_url = JSON.parseObject(result).getString("viewpdf_url");
|
|
319
|
+ Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + viewpdf_url);
|
|
320
|
+ } catch (Exception e) {
|
|
321
|
+ e.printStackTrace();
|
|
322
|
+ }
|
|
323
|
+ }
|
|
324
|
+
|
|
325
|
+ public void viewContract() {
|
|
326
|
+ try {
|
|
327
|
+ response.append("\n").append("合同查看");
|
|
328
|
+ FddClientExtra extra = new FddClientExtra(APP_ID,APP_SECRET,V,HOST);
|
|
329
|
+ String contract_id = "";
|
|
330
|
+ String result = extra.invokeViewPdfURL(contract_id);
|
|
331
|
+ response.append("\n").append(result);
|
|
332
|
+ Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + result);
|
|
333
|
+ } catch (IOException e) {
|
|
334
|
+ e.printStackTrace();
|
|
335
|
+ }
|
|
336
|
+
|
|
337
|
+ }
|
|
338
|
+
|
|
339
|
+ public void downloadContract() {
|
|
340
|
+ response.append("\n").append("合同下载");
|
|
341
|
+ String contract_id = "";
|
|
342
|
+ FddClientExtra extra = new FddClientExtra(APP_ID,APP_SECRET,V,HOST);
|
|
343
|
+ String result = extra.invokeDownloadPdf(contract_id);
|
|
344
|
+ response.append("\n").append(result);
|
|
345
|
+ }
|
|
346
|
+ public void contractFiling() {
|
|
347
|
+ response.append("\n").append("合同归档");
|
|
348
|
+ FddClientBase base = new FddClientBase(APP_ID,APP_SECRET,V,HOST);
|
|
349
|
+ String contract_id = "";
|
|
350
|
+ String result = base.invokeContractFilling(contract_id);
|
|
351
|
+ response.append("\n").append(result);
|
|
352
|
+ }
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+ @After
|
|
356
|
+ public void after() {
|
|
357
|
+ System.out.println(response);
|
|
358
|
+ }
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+ private String decode(String bizContent) {
|
|
362
|
+ bizContent = URLDecoder.decode(bizContent, "utf-8");
|
|
363
|
+ bizContent = new String(Base64.decodeBase64(bizContent.getBytes()));
|
|
364
|
+ return bizContent;
|
|
365
|
+ }
|
|
366
|
+
|
|
367
|
+ private String getparamter() {
|
|
368
|
+ JSONObject paramter = new JSONObject();
|
|
369
|
+// paramter.put("homeUrl","√");
|
|
370
|
+ paramter.put("borrower","深圳法大大");
|
|
371
|
+ return paramter.toString();
|
|
372
|
+ }
|
|
373
|
+ private String getdynamic_tables() {
|
|
374
|
+ JSONArray dynamic_tables = new JSONArray();
|
|
375
|
+ JSONObject dynamic2 = new JSONObject();
|
|
376
|
+ dynamic2.put("insertWay", 1);
|
|
377
|
+// dynamic2.put("keyword", "");
|
|
378
|
+ dynamic2.put("pageBegin", "1");
|
|
379
|
+ dynamic2.put("cellHeight", "16.0");
|
|
380
|
+
|
|
381
|
+ dynamic2.put("colWidthPercent", new int[] { 3, 4, 4, 4});
|
|
382
|
+ dynamic2.put("theFirstHeader", "附二");
|
|
383
|
+ dynamic2.put("cellHorizontalAlignment", "1");
|
|
384
|
+ dynamic2.put("cellVerticalAlignment", "5");
|
|
385
|
+ dynamic2.put("headers", new String[] { "序号", "借款人", "贷款人", "金额" });
|
|
386
|
+ String row1[] = new String[] { "1", "小网", "小易", "1000" };
|
|
387
|
+ String row2[] = new String[] { "2", "小云", "小音", "2000" };
|
|
388
|
+ String row3[] = new String[] { "3", "小乐", "天马", "3000" };
|
|
389
|
+ dynamic2.put("datas", new String[][] { row1, row2, row3 });
|
|
390
|
+ dynamic2.put("headersAlignment", "1");
|
|
391
|
+ dynamic2.put("tableWidthPercentage", 80);
|
|
392
|
+ dynamic_tables.add(dynamic2);
|
|
393
|
+ System.out.println(dynamic_tables.toString());
|
|
394
|
+ return dynamic_tables.toString();
|
|
395
|
+ }
|
|
396
|
+}
|