第三方合同接口示例记录

Posted codechange

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第三方合同接口示例记录相关的知识,希望对你有一定的参考价值。

public static String contractSign(Contract contract,Userbasicsinfo loanUser,Userbasicsinfo tenderUser,HttpServletRequest request){
        
        String osName = System.getProperties().getProperty("os.name").toLowerCase();
        String outputPath = null;
        String downloadPath = null;
        if(osName.startsWith("win")){
            outputPath = "D:\contract_" + contract.getContractNo() + ".doc";
            downloadPath = "D:\contract_" + contract.getContractNo() + ".pdf";
        }else{
            File dir = new File("/home/p2ptemp/");
            if(!dir.exists()){
                dir.mkdirs();
            }
            outputPath = "/home/p2ptemp/contract_" + contract.getContractNo() + ".doc";
            downloadPath = "/home/p2ptemp/contract_" + contract.getContractNo() + ".pdf";
        }
        
        try {
            boolean bool = htmlToDoc.writeWordFileString(getContractEmptyHtml(contract.getContent()), outputPath);
            if(bool){
                //2. 发起人签章
                Userrelationinfo loanRela = loanUser.getUserrelationinfo();
                String response = FddClient.invokeSyncPersonAuto(loanUser.getName(),loanRela.getEmail() , loanRela.getCardId(), loanRela.getPhone());
                
                Map<String,String> map = JSON.parseObject(response, Map.class);
                String customer_id = map.get("customer_id");
                String cnum = "ZC"+System.currentTimeMillis();
                response = FddClient.invokeUploadDocs(cnum, new File(outputPath), "", ".doc");
                
                response = FddClient.invokeExtSignAuto("ZCSIGN"+cnum, customer_id, "", "", "1", "3", cnum,  "xxx合同", loanUser.getName(), "", "");
               
                map = JSON.parseObject(response, Map.class);
                String downloadUrl = map.get("download_url");
                //2.5 下载
                FddDownload.download(downloadUrl, downloadPath);
                response = FddClient.invokeContractFilling(cnum);
                //3. 投资人签章
                Userrelationinfo tenderRela = tenderUser.getUserrelationinfo();
                response = FddClient.invokeSyncPersonAuto(tenderUser.getName(),tenderRela.getEmail() , tenderRela.getCardId(), tenderRela.getPhone());
                
                map = JSON.parseObject(response, Map.class);
                customer_id = map.get("customer_id");
                cnum = "ZC"+System.currentTimeMillis();
                response = FddClient.invokeUploadDocs(cnum, new File(downloadPath), "", ".pdf");
                
                response = FddClient.invokeExtSignAuto("ZCSIGN"+cnum, customer_id, "", "", "1", "3", cnum,  "xxx合同", tenderUser.getName(), "", "");
                
                map = JSON.parseObject(response, Map.class);
                downloadUrl = map.get("download_url");
                //4. 合同归档
                response = FddClient.invokeContractFilling(cnum);
                return downloadUrl;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    
    
    public static String getContractEmptyHtml(String content) {
        String path = ProjectPathUtils.getClassesPath();
        path = path.replaceAll("/classes", "")+"views/contract/detail.jsp";
        if(path.indexOf("/")!=0&&path.indexOf(":")!=1){
            path = "/"+path;
        }
        File file = new File(path);
        FileInputStream fis = null;
        InputStreamReader read = null;
        BufferedReader bufferedReader = null;
        try{
            fis = new FileInputStream(file);
            read = new InputStreamReader(fis,"UTF-8");
            bufferedReader = new BufferedReader(read);
            StringBuilder lineTxt = new StringBuilder("");
            String tempLine = null;
            while((tempLine = bufferedReader.readLine()) != null){
                lineTxt.append(tempLine);
            } 
            String returnValue = lineTxt.toString();
            int index = returnValue.indexOf("<!DOCTYPE ");
            returnValue = returnValue.substring(index, returnValue.length()).replace("${content}", content);
            return returnValue;
        }catch(Exception ex){
            
        }
        return null;
    }

以上代码在工作上使用到了,记录一下下

以上是关于第三方合同接口示例记录的主要内容,如果未能解决你的问题,请参考以下文章

Android:片段在活动结果合同中未收到 RESULT_OK

如何调用第三方电子签章接口

支付宝接口php 如何调用

java 怎么接收第三方传过来的xml

标准服务接口示例代码

Sphinx - 在代码块片段中使用省略号 (...)