From 50fb58286ed3b718c39a97e0987ee7561a295651 Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期五, 04 七月 2025 17:56:41 +0800 Subject: [PATCH] git ch --- server/service/src/main/java/com/doumee/service/business/third/SignService.java | 296 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 277 insertions(+), 19 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/third/SignService.java b/server/service/src/main/java/com/doumee/service/business/third/SignService.java index 675bc7d..81e40c6 100644 --- a/server/service/src/main/java/com/doumee/service/business/third/SignService.java +++ b/server/service/src/main/java/com/doumee/service/business/third/SignService.java @@ -15,13 +15,20 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.URL; import java.util.Date; import java.util.IdentityHashMap; import java.util.Map; +import java.util.UUID; /** * <ul> @@ -47,6 +54,8 @@ private static String SERVICE_URL="https://api.sandbox.junziqian.com"; private static String APP_KEY="dcb4bd535a09df3c"; private static String APP_SECRET="b87c346edcb4bd535a09df3ca8c45d9a"; + @Value("${debug_model}") + private Boolean debugModel; @Autowired private SystemDictDataBiz systemDictDataBiz; @@ -77,11 +86,11 @@ } public void initParams(){ - long ts=System.currentTimeMillis(); + long ts=System.currentTimeMillis()/1000; String nonce=DigestUtils.md5Hex(System.currentTimeMillis()+""); String sign=DigestUtils.sha256Hex("nonce"+nonce+"ts"+ts+"app_key"+APP_KEY+"app_secret"+APP_SECRET); bodyParams=new IdentityHashMap<>(); - bodyParams.put("ts",ts); + bodyParams.put("ts",System.currentTimeMillis()/1000); bodyParams.put("app_key",APP_KEY); bodyParams.put("sign",sign); bodyParams.put("nonce",nonce);//杩欏彧鍙槸涓轰簡鐢熸垚涓�涓殢鏈哄�� @@ -91,7 +100,6 @@ * 1.ping鏈嶅姟 */ public boolean ping(){ - initParams(); try { Map<String, Object> params=bodyParams; String url=SERVICE_URL+"/v2/ping"; @@ -114,13 +122,17 @@ * @param creditCode * @param legalName * @param email - * @param businessimg + * @param businessimgPath * @param notifyUrl * @return */ - public boolean organizationCreate (String fullname,String creditCode,String legalName,String email,File businessimg,String notifyUrl){ + public boolean organizationCreate (String fullname,String creditCode,String legalName,String email,String businessimgPath, String notifyUrl){ try { initParams(); + File businessimg =netFileToLoclFile(businessimgPath); + if(businessimg == null || !businessimg.isFile() || !businessimg.exists()){ + return false; + } Map<String, Object> params=bodyParams; String url=SERVICE_URL+"/v2/user/organizationCreate"; params.put("name",fullname); @@ -133,6 +145,7 @@ params.put("legalName",legalName); params.put("emailOrMobile",email); String str= HttpClientUtils.init().getPost(url,null,params,true); + businessimg.delete(); saveInterfaceLog(url,"銆愮數瀛愮銆戝彂璧蜂紒涓氳璇佺敵璇�",JSONObject.toJSONString(params),str); JSONObject json = JSONObject.parseObject(str); if(json!=null && json.getBoolean("success")){ @@ -151,12 +164,17 @@ * @param creditCode * @param legalName * @param email - * @param businessimg + * @param businessimgPath * @param notifyUrl * @return */ - public boolean organizationReApply(String fullname,String creditCode,String legalName,String email,File businessimg,String notifyUrl){ + public boolean organizationReApply(String fullname,String creditCode,String legalName,String email,String businessimgPath,String notifyUrl){ try { + + File businessimg = new File(new URI(businessimgPath)); + if(businessimg == null|| !businessimg.isFile() || !businessimg.exists()){ + return false ; + } initParams(); Map<String, Object> params=bodyParams; String url=SERVICE_URL+"/v2/user/organizationReapply"; @@ -170,6 +188,7 @@ params.put("legalName",legalName); params.put("emailOrMobile",email); String str= HttpClientUtils.init().getPost(url,null,params,true); + businessimg.delete(); saveInterfaceLog(url,"銆愮數瀛愮銆戦噸鏂板彂璧蜂紒涓氳璇佺敵璇�",JSONObject.toJSONString(params),str); JSONObject json = JSONObject.parseObject(str); if(json!=null && json.getBoolean("success")){ @@ -184,7 +203,34 @@ } /** - * 鏌ヨ浼佷笟绛剧害鐘舵�� 瀹℃壒鐘舵��,0姝e湪鐢宠1閫氳繃2椹冲洖 + * 缃戠粶鏂囦欢杞湰鍦颁复鏃舵枃浠� + * @param fileUrl + * @return + */ + public static File netFileToLoclFile(String fileUrl) { + + try { + URL url = new URL(fileUrl); + InputStream inputStream = url.openConnection().getInputStream(); + + File file = File.createTempFile( "temp",""+UUID.randomUUID().toString()+fileUrl.substring(fileUrl.lastIndexOf("."))); // 鎸囧畾淇濆瓨鍒版湰鍦扮殑鏂囦欢鍚嶅強璺緞 + OutputStream outputStream = new FileOutputStream(file); + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + + outputStream.close(); + inputStream.close(); + return file; + }catch (Exception e){ + + } + return null; + } + /** + * 鏌ヨ浼佷笟绛剧害鐘舵�� 瀹℃牳鐘舵��,0姝e湪鐢宠1閫氳繃2椹冲洖 * @param email * @return */ @@ -210,24 +256,51 @@ /** * 鍙戣捣绛剧害 * @param name - * @param file + * @param fileUrl * @param fullname * @param creditCoe * @param email * @param postionJson */ - public String applySign(String name,File file,String fullname,String creditCoe,String email,String postionJson){ + public String applySignWidthQifengSet(String name,String fileUrl,String fullname,String creditCoe,String email,String postionJson,String singId,String notifyUrl,Float qifengSet){ + return applySignDoByParam(name,fileUrl,fullname,creditCoe,email,postionJson,singId,notifyUrl,qifengSet); + } + /** + * 鍙戣捣绛剧害 + * @param name + * @param fileUrl + * @param fullname + * @param creditCoe + * @param email + * @param postionJson + */ + public String applySign(String name,String fileUrl,String fullname,String creditCoe,String email,String postionJson,String singId,String notifyUrl){ + return applySignDoByParam(name,fileUrl,fullname,creditCoe,email,postionJson,singId,notifyUrl,null); + } + /** + * 鍙戣捣绛剧害 + * @param name + * @param fileUrl + * @param fullname + * @param creditCoe + * @param email + * @param postionJson + */ + public String applySignDoByParam(String name,String fileUrl,String fullname,String creditCoe,String email,String postionJson,String singId,String notifyUrl,Float qifengSet){ try { - String url=SERVICE_URL+"/v2/sign/applySign"; initParams(); + String url=SERVICE_URL+"/v2/sign/applySign"; Map<String, Object> params=bodyParams; params.put("contractName",name); //鍚堝悓鍚嶇О params.put("serverCa",1); //浣跨敤浜戣瘉涔� - params.put("file",file); +// params.put("file",file); + params.put("url",fileUrl); params.put("dealType",5); //鎸囧畾鍚堝悓鏂囦欢绛剧讲鏂瑰紡 5 涓洪儴鍒嗚嚜鍔ㄧ - params.put("positionType",0); //鎸囧畾閫氳繃琛ㄥ崟鍩熸柟寮忚缃瀛椾綅缃� - params.put("fileType",0); +// params.put("positionType",2); //鎸囧畾閫氳繃琛ㄥ崟鍩熸柟寮忚缃瀛椾綅缃� + params.put("positionType",0); //鎸囧畾鍏珷浣嶇疆绫诲瀷:0鎴杗ull浣跨敤绛惧瓧搴ф爣浣嶇疆鎴栦笉鎸囧畾绛惧瓧浣嶇疆;1琛ㄥ崟鍩熷畾浣�(琛ㄥ崟鍩熷鏋滀笂浼犱负pdf鏃�,闇�pdf鑷瀹氫箟濂借〃鍗曞煙,html鍙妘rl鍙妕mpl绛夐渶瀹氫箟濂絠nput鏍囩);2鍏抽敭瀛楀畾涔� + params.put("fileType",1); params.put("needQifengSign",1); + params.put("notifyUrl",notifyUrl); JSONArray signatories=new JSONArray(); SignatoryReq sReq=new SignatoryReq(); sReq.setFullName(fullname); //浼佷笟濮撳悕 @@ -235,7 +308,58 @@ sReq.setIdentityCard(creditCoe);//钀ヤ笟鎵х収鍙� sReq.setEmail(email); //鍦ㄥ悰瀛愮娉ㄥ唽璁よ瘉鐨勯偖绠� // sReq.setChapteJson("[{\"page\":0,\"chaptes\":[{\"offsetX\":0.12,\"offsetY\":0.23}]},{\"page\":1,\"chaptes\":[{\"offsetX\":0.45,\"offsetY\":0.67}]}]"); - sReq.setChapteJson(postionJson); +// sReq.setChapteJson(postionJson);//琛ㄥ崟鍩熷畾浣� 瀵瑰簲positionType=1 +// sReq.setSearchKey(postionJson);//鍏抽敭瀛� 瀵瑰簲positionType=2 + sReq.setSignId(singId); + sReq.setNoNeedVerify(1); + sReq.setQiFengOffset(qifengSet); + signatories.add(sReq); + params.put("signatories",signatories.toJSONString()); + System.out.println("================"+JSONObject.toJSONString(params)); + String str= HttpClientUtils.init().getPost(url,null,params,true); + System.out.println(str); + saveInterfaceLog(url,"銆愮數瀛愮銆戝彂璧风绾�",JSONObject.toJSONString(params),str); + JSONObject json = JSONObject.parseObject(str); + if(json!=null && json.getBoolean("success")){ + return json.getString("data"); + } + }catch (Exception e){ + e.printStackTrace(); + } + return null; + + } + /** + * 鍙戣捣绛剧害 + * @param name + * @param file + * @param creditCoe + * @param email + * @param postionJson + */ + public String applySignLocalFile(String name,String fullname,String file,String creditCoe,String email,String postionJson,String singId,String notifyUrl){ + try { initParams(); + String url=SERVICE_URL+"/v2/sign/applySign"; + Map<String, Object> params=bodyParams; + params.put("contractName",name); //鍚堝悓鍚嶇О + params.put("serverCa",1); //浣跨敤浜戣瘉涔� + params.put("file",new File(file)); + params.put("dealType",5); //鎸囧畾鍚堝悓鏂囦欢绛剧讲鏂瑰紡 5 涓洪儴鍒嗚嚜鍔ㄧ + params.put("positionType",0); //鎸囧畾閫氳繃琛ㄥ崟鍩熸柟寮忚缃瀛椾綅缃� + params.put("fileType",0); + params.put("needQifengSign",1); + params.put("notifyUrl",notifyUrl); + JSONArray signatories=new JSONArray(); + SignatoryReq sReq=new SignatoryReq(); + sReq.setFullName(fullname); //浼佷笟濮撳悕 + sReq.setIdentityType(11); //璇佷欢绫诲瀷 + sReq.setIdentityCard(creditCoe);//钀ヤ笟鎵х収鍙� + sReq.setEmail(email); //鍦ㄥ悰瀛愮娉ㄥ唽璁よ瘉鐨勯偖绠� +// sReq.setChapteJson("[{\"page\":0,\"chaptes\":[{\"offsetX\":0.12,\"offsetY\":0.23}]},{\"page\":1,\"chaptes\":[{\"offsetX\":0.45,\"offsetY\":0.67}]}]"); +// sReq.setChapteJson(postionJson); +// sReq.setSearchKey(postionJson); + sReq.setSignId(singId); + sReq.setSearchConvertExtend("{\"fixX\":-80,\"fixY\":-80}"); sReq.setNoNeedVerify(1); signatories.add(sReq); params.put("signatories",signatories.toJSONString()); @@ -248,21 +372,75 @@ return json.getString("data"); } }catch (Exception e){ + e.printStackTrace(); } return null; } + /** + * 鍙戣捣绛剧害 + * @param name + * @param file + * @param creditCoe + * @param email + * @param postionJson + */ + public String applySignLocalFileByParam(String name,String fullname,String file,String creditCoe,String email,String postionJson,String singId,String notifyUrl,Float qifengSet){ + try { initParams(); + String url=SERVICE_URL+"/v2/sign/applySign"; + Map<String, Object> params=bodyParams; + params.put("contractName",name); //鍚堝悓鍚嶇О + params.put("serverCa",1); //浣跨敤浜戣瘉涔� + params.put("file",new File(file)); + params.put("dealType",5); //鎸囧畾鍚堝悓鏂囦欢绛剧讲鏂瑰紡 5 涓洪儴鍒嗚嚜鍔ㄧ + params.put("positionType",0); //鎸囧畾閫氳繃琛ㄥ崟鍩熸柟寮忚缃瀛椾綅缃� + params.put("fileType",0); + params.put("needQifengSign",1); + params.put("notifyUrl",notifyUrl); + JSONArray signatories=new JSONArray(); + SignatoryReq sReq=new SignatoryReq(); + sReq.setFullName(fullname); //浼佷笟濮撳悕 + sReq.setIdentityType(11); //璇佷欢绫诲瀷 + sReq.setIdentityCard(creditCoe);//钀ヤ笟鎵х収鍙� + sReq.setEmail(email); //鍦ㄥ悰瀛愮娉ㄥ唽璁よ瘉鐨勯偖绠� +// sReq.setChapteJson("[{\"page\":0,\"chaptes\":[{\"offsetX\":0.12,\"offsetY\":0.23}]},{\"page\":1,\"chaptes\":[{\"offsetX\":0.45,\"offsetY\":0.67}]}]"); +// sReq.setChapteJson(postionJson); +// sReq.setSearchKey(postionJson); + sReq.setSignId(singId); + sReq.setQiFengOffset(qifengSet); + sReq.setSearchConvertExtend("{\"fixX\":-80,\"fixY\":-80}"); + sReq.setNoNeedVerify(1); + signatories.add(sReq); + params.put("signatories",signatories.toJSONString()); + System.out.println(signatories.toJSONString()); + String str= HttpClientUtils.init().getPost(url,null,params,true); + System.out.println(str); + saveInterfaceLog(url,"銆愮數瀛愮銆戝彂璧风绾�",JSONObject.toJSONString(params),str); + JSONObject json = JSONObject.parseObject(str); + if(json!=null && json.getBoolean("success")){ + return json.getString("data"); + } + }catch (Exception e){ + e.printStackTrace(); + + } + return null; + + } + /** - * 鑾峰彇绛剧讲閾炬帴鍦板潃 + * 鑾峰彇绛剧讲閾炬帴鍦板潃锛堢缃查〉闈㈠湴鍧�锛� * @param applyNo * @param name * @param creditCode */ public String signLink(String applyNo,String name,String creditCode) { try { + //寤惰繜2绉� +// Thread.sleep(2*1000); initParams(); Map<String, Object> params = bodyParams; String url = SERVICE_URL + "/v2/sign/link"; @@ -275,6 +453,37 @@ saveInterfaceLog(url,"銆愮數瀛愮銆戣幏鍙栫缃查摼鎺ュ湴鍧�",JSONObject.toJSONString(params),str); JSONObject json = JSONObject.parseObject(str); if(json!=null && json.getBoolean("success")){ + String link =json.getString("data"); + if(!debugModel){ + link = link.replace("https://h5","https://h7"); + } + return link; + } + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + /** + * 鑾峰彇绛剧讲閾炬帴鍦板潃(杩斿洖鏂囦欢鍦板潃锛岀缃插悗鎵嶆槸鏂囦欢鍦板潃锛屽惁鍒欒烦杞埌绛剧讲椤甸潰) + * @param applyNo + */ + public String linkFileStatus(String applyNo) { + + try { initParams(); + Map<String, Object> params = bodyParams; + String url = SERVICE_URL + "/v2/sign/status"; + //鏋勫缓璇锋眰鍙傛暟 + params.put("applyNo",applyNo); //鍙戣捣鍚堝悓绛剧讲鎺ュ彛杩斿洖鐨凙PL缂栧彿 +// params.put("fullName",fullName); //绛剧害浜哄悕绉� +// params.put("identityCard",identityCard); //绛剧害浜鸿瘉浠跺彿 +// params.put("identityType",12); //璇佷欢绫诲瀷 1韬唤璇�, 2鎶ょ収, 3鍙拌優璇�, 4娓境灞呮皯鏉ュ線鍐呭湴閫氳璇�, 11钀ヤ笟鎵х収, 12缁熶竴绀句細淇$敤浠g爜, 20瀛愯处鍙�, 99鍏朵粬 + String str= HttpClientUtils.init().getPost(url,null,params,true); + System.out.println(str); + saveInterfaceLog(url,"銆愮數瀛愮銆戠绾︾姸鎬佹煡璇�",JSONObject.toJSONString(params),str); + JSONObject json = JSONObject.parseObject(str); + if(json!=null && json.getBoolean("success")){ + //0 锛氭湭绛� 1 锛氬凡绛� 2锛氭嫆绛� 3锛氬凡淇濆叏 return json.getString("data"); } }catch (Exception e){ @@ -283,13 +492,12 @@ return null; } /** - * 鑾峰彇绛剧讲閾炬帴鍦板潃 + * 鑾峰彇绛剧讲閾炬帴鍦板潃(杩斿洖鏂囦欢鍦板潃锛岀缃插悗鎵嶆槸鏂囦欢鍦板潃锛屽惁鍒欒烦杞埌绛剧讲椤甸潰) * @param applyNo */ public String linkFile(String applyNo) { - try { - initParams(); + try { initParams(); Map<String, Object> params = bodyParams; String url = SERVICE_URL + "/v2/sign/linkFile"; //鏋勫缓璇锋眰鍙傛暟 @@ -306,5 +514,55 @@ } return null; } + /** + * 涓婁紶浼佷笟鑷畾涔夊嵃绔�(杩斿洖鍗扮珷ID) + * @param signName + * @param path + */ + public String uploadEntSign(String signName,String path,String email ) { + + try { initParams(); + File signImgFile =netFileToLoclFile(path); + Map<String, Object> params = bodyParams; + String url = SERVICE_URL + "/v2/user/uploadEntSign"; + //鏋勫缓璇锋眰鍙傛暟 + params.put("signName",signName); + params.put("signImgFile",signImgFile); + params.put("email",email); + String str= HttpClientUtils.init().getPost(url,null,params,true); + System.out.println(str); + saveInterfaceLog(url,"銆愮數瀛愮銆戜笂浼犱紒涓氳嚜瀹氫箟鍗扮珷",JSONObject.toJSONString(params),str); + JSONObject json = JSONObject.parseObject(str); + if(json!=null && json.getBoolean("success")){ + return json.getString("data"); + } + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + /** + * 鍒犻櫎浼佷笟鑷畾涔夊嵃绔� + * @param signId + */ + public boolean deleteEntSign(String signId ) { + + try { initParams(); + Map<String, Object> params = bodyParams; + String url = SERVICE_URL + "/v2/user/deleteEntSign"; + //鏋勫缓璇锋眰鍙傛暟 + params.put("signId",signId); + String str= HttpClientUtils.init().getPost(url,null,params,true); + System.out.println(str); + saveInterfaceLog(url,"銆愮數瀛愮銆戝垹闄や紒涓氳嚜瀹氫箟鍗扮珷",JSONObject.toJSONString(params),str); + JSONObject json = JSONObject.parseObject(str); + if(json!=null && json.getBoolean("success")){ + return json.getBoolean("success"); + } + }catch (Exception e){ + e.printStackTrace(); + } + return false; + } } -- Gitblit v1.9.3