springboot对接上上签(四)

291 阅读1分钟

发送合同

在我们创建好合同之后,我们需要把合同发给相关的人员进行签署,这里就需要调用上上签的发送合同的接口了,这里可以设置合同的接收人、合同签署的有效时间等

/** 发送合同 */
public static void sendContract(String contractId, String cusId, String cusMobile, String title)
    throws IOException {
  String host = serverHost;
  String method = "/contract/send/";
  String rtick = RSAUtils.getRtick();
  JSONObject requestBody = new JSONObject();
  requestBody.put("contractId", contractId); // 合同编号
  requestBody.put("signer", "xxxxx"); // 发送给谁
  requestBody.put("isAllowChangeSignaturePosition", "1");
  List<String> verifyType = new ArrayList<>();
  verifyType.add("sms");
  requestBody.put("verifyType", verifyType);
  requestBody.put("vcodeMobile", "xxxxxx");
  requestBody.put("isDrawSignatureImage", "0");

  //      requestBody.put("expireTime",systime+604800);
  requestBody.put("title", title);
  List<JSONObject> signaturePositions = new ArrayList<>();
  JSONObject credential = new JSONObject();
  credential.put("pageNum", 1);
  credential.put("x", 0.31);
  credential.put("y", 0.22);
  signaturePositions.add(credential);
  requestBody.put("signaturePositions", signaturePositions);
  // 计算参数签名
  String paramsSign =
      RSAUtils.calcRsaSign(
          developerId, privateKey, host, method, rtick, null, requestBody.toJSONString());
  // 签名参数追加为url参数
  String urlParams = String.format(urlSignParams, developerId, rtick, paramsSign);
  String responseBody =
      HttpClientSender.sendHttpPost(host, method, urlParams, requestBody.toJSONString());
  System.out.println(responseBody);
}