CreateFlowByTemplateDirectly.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package essapi
  2. import (
  3. "mtp2_if/config"
  4. "mtp2_if/utils"
  5. essbasic "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/essbasic/v20210526"
  6. )
  7. // CreateFlowByTemplateDirectly 通过合同名和模板Id直接发起签署流程
  8. // 本接口是对于发起合同几个接口的封装,详细参数需要根据自身业务进行调整
  9. // CreateFlowsByTemplates--CreateSignUrls
  10. func CreateFlowByTemplateDirectly(flowName, templateId string, flowApproverInfos []*essbasic.FlowApproverInfo) (resp map[string][]*string, err error) {
  11. agent := utils.SetAgent()
  12. resp = make(map[string][]*string)
  13. // 创建签署流程
  14. var flowInfos []*essbasic.FlowInfo
  15. flowInfos = append(flowInfos, utils.FillFlowInfo(templateId, flowName, flowApproverInfos))
  16. // 构建内容控件填充结构(根据自己需求使用)
  17. // flowInfos[i].FormFields = []*v20210526.FormField{utils.BuildFormField("姓名", "张三")}
  18. // 发起签署
  19. flowResponse, err := CreateFlowsByTemplates(agent, flowInfos)
  20. if err != nil {
  21. return
  22. }
  23. flowIds := flowResponse.Response.FlowIds
  24. resp["flowIds"] = flowIds
  25. // 获取签署链接
  26. createSignUrlsResp, err := CreateSignUrls(flowIds, agent)
  27. if err != nil {
  28. return
  29. }
  30. // 目标只需要乙方签署地址
  31. var urls []*string
  32. for _, signUrlInfo := range createSignUrlsResp.Response.SignUrlInfos {
  33. if signUrlInfo.OpenId != &config.SerCfg.TencentCfg.ProxyOperatorOpenId { // 不是甲方经办人
  34. urls = append(urls, signUrlInfo.SignUrl)
  35. }
  36. }
  37. resp["urls"] = urls
  38. return
  39. }