package essapi import ( "mtp2_if/logger" "mtp2_if/utils" SysConfig "mtp2_if/config" essbasic "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/essbasic/v20210526" ) // CreateFlowByTemplateDirectly 通过合同名和模板Id直接发起签署流程 // 本接口是对于发起合同几个接口的封装,详细参数需要根据自身业务进行调整 // CreateFlowsByTemplates--CreateSignUrls func CreateFlowByTemplateDirectly(flowName, templateId string, flowApproverInfos []*essbasic.FlowApproverInfo, formFields []*essbasic.FormField, appId, proxyOrganizationOpenId, proxyOperatorOpenId *string) (resp map[string][]*string, err error) { agent := utils.SetAgent(appId, proxyOrganizationOpenId, proxyOperatorOpenId) resp = make(map[string][]*string) // 创建签署流程 var flowInfos []*essbasic.FlowInfo flowInfos = append(flowInfos, utils.FillFlowInfo(templateId, flowName, flowApproverInfos, formFields)) // 构建内容控件填充结构(根据自己需求使用) // flowInfos[i].FormFields = []*v20210526.FormField{utils.BuildFormField("姓名", "张三") // 注意:这里是签署方需要填写的内容,发起方填写内容在 FillFlowInfo 方法中设置 // 增加 nil 判断是解决非深金模式(一个交易所多个电子签子客模式)情况下,直接取配置文件信息 if proxyOperatorOpenId == nil { proxyOperatorOpenId = &SysConfig.SerCfg.TencentCfg.ProxyOperatorOpenId } // 发起签署 flowResponse, err := CreateFlowsByTemplates(agent, flowInfos) if err != nil { return } flowIds := flowResponse.Response.FlowIds resp["flowIds"] = flowIds // 获取签署链接 createSignUrlsResp, err := CreateSignUrls(flowIds, agent) if err != nil { return } // 目标只需要乙方签署地址(应是非本企业签署地址,因为本企业一般是静默签署) var urls []*string for _, signUrlInfo := range createSignUrlsResp.Response.SignUrlInfos { logger.GetLogger().Debugf("signUrlInfo OpenId:%v ApproverType:%v OrganizationName:%v Name:%v Mobile:%v", *signUrlInfo.OpenId, *signUrlInfo.ApproverType, *signUrlInfo.OrganizationName, *signUrlInfo.Name, *signUrlInfo.Mobile) if *signUrlInfo.OpenId != *proxyOperatorOpenId { // 不是甲方经办人 urls = append(urls, signUrlInfo.SignUrl) } } resp["urls"] = urls return }