契约锁 创建合同

导入依赖

       <dependency>
			<groupId>com.qiyuesuo.sdk</groupId>
			<artifactId>sdk-java</artifactId>
			<version>3.1.0</version>
			<!--<version>3.0.8</version>-->
		</dependency>

注册成功得到的 key和secret

String url = "https://openapi.qiyuesuo.cn";
        String accessKey = "key";
        String accessSecret = "secret";

注意 url .cn 结尾是测试环境 .com结尾是生产环境
使用模板创建合同并 自动签章(后台需要配置签章)
契约锁 创建合同_第1张图片

@Test
    public void dd() {
        // 初始化sdkClient
        String serverUrl = "https://openapi.qiyuesuo.cn";
        String accessKey = "";
        String accessSecret = "";

        SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret);
// 合同基本参数
        Contract contract = new Contract();
        contract.setSubject("测试合同自动签章");
        contract.setCategory(new Category(2652369013224509655L));
        contract.setBizId("");
        contract.setSend(true);
// 个人
        Signatory signatory1 = new Signatory();
        signatory1.setTenantName("范礼威");
        signatory1.setTenantType("PERSONAL");
        signatory1.setReceiver(new User( "13125196976", "MOBILE"));
        signatory1.setSerialNo(2);
// 对接方
		Signatory signatory2 = new Signatory();
		signatory2.setTenantName("杭州则灵企业管理有限公司");
		signatory2.setTenantType("COMPANY");
		signatory2.setReceiver(new User( "[email protected]", "EMAIL"));
		signatory2.setSerialNo(1);
		Action action = new Action("COMPANY", 1);
		signatory2.addAction(action);
// 设置签署方
		contract.addSignatory(signatory2);
        contract.addSignatory(signatory1);
//		contract.addTemplateParam(new TemplateParam("mm", "杭州123"));
//		contract.addTemplateParam(new TemplateParam("mm", "2020年1月9日"));
// 创建合同
        ContractDraftRequest request = new ContractDraftRequest(contract);
        String response = sdkClient.service(request);
        SdkResponse<Contract> responseObj = JSONUtils.toQysResponse(response, Contract.class);
// 返回结果
        if (responseObj.getCode() == 0) {
            Contract result = responseObj.getResult();
            logger.info("创建合同成功,合同ID:{}", result.getId());
        } else {
            logger.info("请求失败,错误码:{},错误信息:{}", responseObj.getCode(), responseObj.getMessage());
        }
    }

注意contract.addSignatory()的顺序!!(发起方在前)

你可能感兴趣的:(契约锁 创建合同)