CreateFlowByTemplateDirectly.go 2.3 KB

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