关于fdd 法大大 接入问题

首先要在配置文件中配置好第三方参数

关于fdd 法大大 接入问题_第1张图片

然后上传合同模板到fdd

@Value("${fdd.fddclientcode}")
    private String fdd_client_code;
    @Value("${fdd.fddappId}")
    private String fdd_appId;
    @Value("${fdd.fddsecret}")
    private String fdd_secret;
    @Value("${fdd.fddversion}")
    private String fdd_version;
    @Value("${fdd.fddurl}")
    private String fdd_url;
    @Autowired
    Th3rdFddMapper th3rdFddMapper;


    @Override
    public IBaseDAO getBaseDao() {
        return th3rdFddMapper;
    }

    
    public  Map createContract(String docUrl){
        File file = null;
        String appId = fdd_appId;
        String secret = fdd_secret;
        String version = fdd_version;
        String url = fdd_url;
//        String appId = "";
//        String secret = "";
//        String version = "2.0";
//        String url = "https://extapi.fadada.com/api2/";

        String template_id = StringUtils.generateRandomString(32);
        System.out.println(template_id);
        //個人ca申请
        FddClientBase clientBase = new FddClientBase(appId,secret,version,url);
        String customerResponse = clientBase.invokeSyncPersonAuto("张叔叔","[email protected]","3834748459","0","134567890");
        System.out.println(customerResponse);
        customerResponse = clientBase.invokeUploadTemplate(template_id, file, docUrl);
        System.out.println(customerResponse);

        JSONObject customerEntity = JSON.parseObject(customerResponse);
        String result = customerEntity.getString("code");
        System.out.println(result);
        Map resultMap = new HashMap<>();
        resultMap.put("code",result);
        return resultMap;
    }

最后根据不同的需求生成电子合同

/**
* @Package com.duojia.eagle.manager.contract
* @param  * @param name
 * @param email
 * @param idCard
 * @param mobile
 * @param userType
 * @param userId
* @Description: 生成电子合同
* @author changjiang
* @date 2018/1/24 14:48
*/
public Map generateFadada(String name, String email, String idCard, String mobile, String userType, Long userId){

    String appId = Configuration.getInstance().getValue("fdd_appId");
    String secret = Configuration.getInstance().getValue("fdd_secret");
    String version = Configuration.getInstance().getValue("fdd_version");
    String url = Configuration.getInstance().getValue("fdd_url");
    String notify_url = Configuration.getInstance().getValue("fdd_notify_url");

    //個人ca申请
    FddClientBase clientBase = new FddClientBase(appId,secret,version,url);
    String customerResponse = clientBase.invokeSyncPersonAuto(name,email,idCard,"0",mobile);
    System.out.println(customerResponse);

    JSONObject customerEntity = JSON.parseObject(customerResponse);
    String result = customerEntity.getString("code");
    boolean flag = false;
    String downUrl = "";
    String customerId = "";
    String viewUrl = "";

    Map resultMap = new HashMap<>();
    resultMap.put("flag", ResultStatusEnum.ERROR.getStatus());
    resultMap.put("customerId",customerId);
    resultMap.put("downUrl",downUrl);
    resultMap.put("viewUrl",viewUrl);


    //个人ca申请正确
    if(result.equals("1000")){
        flag = true;
    }
    //个人模板参数传参
    String contractId = IdUtils.getContractNo(userType, userId) + "";
    resultMap.put("contactId",contractId);

    if(flag) {
        //个人模板传输参数替换
        JSONObject paramter = new JSONObject();
        paramter.put("name1", name);
        String templateResponse = clientBase.invokeGenerateContract("22", contractId, null, null, null, paramter.toJSONString(), null);
        System.out.println(templateResponse);
        JSONObject templateEntity = JSON.parseObject(templateResponse);
        result = templateEntity.getString("code");
        if (!result.equals("1000")) {
            flag = false;
        }
    }

    if(flag){
        customerId =customerEntity.getString("customer_id");
        //乙方自动签署,个人签章
        String transaction1Response = clientBase.invokeExtSignAuto(IdUtils.getContractNo(userType,userId)+"",customerId,"1",contractId,"叁生众康平台入驻合作协议20171222",
                "自动签名的乙方名称",notify_url);
        System.out.println(transaction1Response);

        JSONObject transaction1Entity = JSON.parseObject(transaction1Response);
        result = transaction1Entity.getString("code");
        if (!result.equals("1000")) {
            flag = false;
        }
    }

    if(flag){
        //甲方自动签署,公司签章
        String transaction2Response = clientBase.invokeExtSignAuto(IdUtils.getContractNo(userType,userId)+"","sssssssds","1",contractId,name+"叁生众康平台入驻合作协议",
                "盖章位置在这里",notify_url);
        System.out.println(transaction2Response);
        JSONObject transaction2Entity = JSON.parseObject(transaction2Response);
        result = transaction2Entity.getString("code");
        if (!result.equals("1000")) {
            flag = false;
        }
        downUrl = transaction2Entity.getString("download_url");
        System.out.println(downUrl);
        viewUrl = transaction2Entity.getString("viewpdf_url");
        System.out.println(viewUrl);
    }

    if(flag){//如果签署成功,返回状态
        resultMap.put("flag", ResultStatusEnum.SUCCESS.getStatus());
        resultMap.put("customerId",customerId);
        resultMap.put("downUrl",downUrl);
        resultMap.put("viewUrl",viewUrl);
        resultMap.put("contactId",contractId);
    }

    return resultMap;
}

在回调地址中归档合同

public String generateNotifyFadada(HttpServletRequest request, HttpServletResponse response){
    Map map = new HashMap<>();
    log.info("transaction_id-------"+request.getParameter("transaction_id"));
    log.info("contract_id-------"+request.getParameter("contract_id"));
    log.info("result_code-------"+request.getParameter("result_code"));
    log.info("result_desc-------"+request.getParameter("result_desc"));
    log.info("download_url-------"+request.getParameter("download_url"));
    log.info("viewpdf_url-------"+request.getParameter("viewpdf_url"));
    log.info("timestamp-------"+request.getParameter("timestamp"));
    log.info("msg_digest-------"+request.getParameter("msg_digest"));
    String transaction_id = request.getParameter("transaction_id");
    String orgid = transaction_id.substring(11,transaction_id.length());
    String customerId = request.getParameter("customerId");
    String contract_id = request.getParameter("contract_id");
    String result_code = request.getParameter("result_code");
    String result_desc = request.getParameter("result_desc");
    String download_url = request.getParameter("download_url");
    String viewpdf_url = request.getParameter("viewpdf_url");
    String timestamp = request.getParameter("timestamp");
    String msg_digest = request.getParameter("msg_digest");

    if(result_code.equalsIgnoreCase("3000")) {
        OrgDo updateOrgDo = new OrgDo();
        updateOrgDo.setOrgId(Long.parseLong(orgid));
        updateOrgDo.setContactId(contract_id);
        updateOrgDo.setDownUrl(download_url);
        updateOrgDo.setViewUrl(viewpdf_url);
        int flag1 = orgFacade.updateOrgDo(updateOrgDo);
        contractFilling(contract_id);
        System.out.println("用户合同签订=======================================================");
    }
    return "200";
}

你可能感兴趣的:(法大大)