CreateFlowByTemplateDirectly.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package essapi
  2. import (
  3. "mtp2_if/logger"
  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, formFields []*essbasic.FormField,
  11. appId, proxyOrganizationOpenId, proxyOperatorOpenId *string) (resp map[string][]*string, err error) {
  12. agent := utils.SetAgent(appId, proxyOrganizationOpenId, proxyOperatorOpenId)
  13. resp = make(map[string][]*string)
  14. // 创建签署流程
  15. var flowInfos []*essbasic.FlowInfo
  16. flowInfos = append(flowInfos, utils.FillFlowInfo(templateId, flowName, flowApproverInfos, formFields))
  17. // 构建内容控件填充结构(根据自己需求使用)
  18. // flowInfos[i].FormFields = []*v20210526.FormField{utils.BuildFormField("姓名", "张三")
  19. // 注意:这里是签署方需要填写的内容,发起方填写内容在 FillFlowInfo 方法中设置
  20. // 发起签署
  21. flowResponse, err := CreateFlowsByTemplates(agent, flowInfos)
  22. if err != nil {
  23. return
  24. }
  25. flowIds := flowResponse.Response.FlowIds
  26. resp["flowIds"] = flowIds
  27. // 获取签署链接
  28. createSignUrlsResp, err := CreateSignUrls(flowIds, agent)
  29. if err != nil {
  30. return
  31. }
  32. // 目标只需要乙方签署地址
  33. var urls []*string
  34. for _, signUrlInfo := range createSignUrlsResp.Response.SignUrlInfos {
  35. logger.GetLogger().Debugf("signUrlInfo OpenId:%v ApproverType:%v OrganizationName:%v Name:%v Mobile:%v", *signUrlInfo.OpenId, *signUrlInfo.ApproverType, *signUrlInfo.OrganizationName, *signUrlInfo.Name, *signUrlInfo.Mobile)
  36. if *signUrlInfo.OpenId != *proxyOperatorOpenId { // 不是甲方经办人
  37. urls = append(urls, signUrlInfo.SignUrl)
  38. }
  39. }
  40. resp["urls"] = urls
  41. return
  42. }