types.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. package qiyuesuosdk
  2. import "time"
  3. // OrgCertParams 机构法人认证页参数;OpenCompanyID 通常等于平台 tenant_id。
  4. type OrgCertParams struct {
  5. CompanyName string
  6. Charger string
  7. Mobile string
  8. OpenCompanyID string
  9. }
  10. // CompanyAuthStatus 法人单位认证状态查询结果。
  11. type CompanyAuthStatus struct {
  12. CompanyName string `json:"companyName"`
  13. Mobile string `json:"mobile"`
  14. RegisterNo string `json:"registerNo"`
  15. BizID flexStringID `json:"bizId"`
  16. AuthEndTime string `json:"authEndTime"`
  17. Result CompanyAuthResult `json:"result"`
  18. }
  19. func (s *CompanyAuthStatus) CompanyID() string {
  20. if s == nil {
  21. return ""
  22. }
  23. return s.BizID.String()
  24. }
  25. // CompanyAuthResult 认证审核结果。
  26. type CompanyAuthResult struct {
  27. Status string `json:"status"`
  28. Reason string `json:"reason"`
  29. }
  30. // AuthPassed 是否认证成功。
  31. func (s *CompanyAuthStatus) AuthPassed() bool {
  32. return s.Result.Status == "AUTH_PASSED"
  33. }
  34. // CreateUserParams 在契约锁创建内部用户(医生等需个人签名的成员)。
  35. type CreateUserParams struct {
  36. Name string
  37. OpenUserID string
  38. AccountNo string
  39. Password string
  40. Mobile string
  41. }
  42. // UserLocateParams 定位契约锁个人用户;查询优先级与开放平台一致:用户 id > 手机号 > 证件号 > 三方用户 id > 登录账号。
  43. type UserLocateParams struct {
  44. UserID string
  45. Mobile string
  46. CardNo string
  47. OpenUserID string
  48. AccountNo string
  49. }
  50. // UserInfo 契约锁用户基本信息。
  51. type UserInfo struct {
  52. ID string
  53. BizID string
  54. Name string
  55. Mobile string
  56. Status string
  57. }
  58. func (u *UserInfo) OpenUserID() string {
  59. if u == nil {
  60. return ""
  61. }
  62. if u.BizID != "" {
  63. return u.BizID
  64. }
  65. return u.ID
  66. }
  67. // CompanySealSpec 企业公章关键字签署位置。
  68. type CompanySealSpec struct {
  69. CompanyName string
  70. Keyword string
  71. OffsetX string
  72. OffsetY string
  73. RotateDegree int64
  74. Page string // 空则不限页;双章场景可设 "1"
  75. }
  76. // PersonalSealSpec 个人签名关键字签署位置。
  77. type PersonalSealSpec struct {
  78. OpenUserID string
  79. Keyword string
  80. }
  81. // SignDocumentRequest PDF 静默签章请求(机构章 + 可选个人签)。
  82. type SignDocumentRequest struct {
  83. PDF []byte
  84. Subject string
  85. ProcessID string // 空则使用 Client 初始化时的 SignDefaults
  86. Launcher string
  87. CompanySeal CompanySealSpec
  88. PersonalSeals []PersonalSealSpec
  89. }
  90. // SignDualCompanyRequest 双企业公章签署(如账单合同甲乙双方)。
  91. type SignDualCompanyRequest struct {
  92. PDF []byte
  93. Subject string
  94. ProcessID string
  95. Launcher string
  96. CompanySeals []CompanySealSpec
  97. }
  98. // Callback request / event types — 与契约锁开放平台事件名一致。
  99. const (
  100. EventCompanyAuthSuccess = "COMPANY_AUTH_SUCCESS"
  101. EventCompanySealAuthSuccess = "COMPANY_SIGN_SILENT_AUTH"
  102. EventUserAuthSuccess = "USER_AUTH_SUCCESS"
  103. EventPersonalSealAuthSuccess = "PERSONAL_SIGN_SILENT_AUTH"
  104. EventCallbackCheck = "CALLBACK_CHECK"
  105. )
  106. // CallbackRequest 契约锁 HTTP 回调原始载荷。
  107. type CallbackRequest struct {
  108. Signature string `json:"signature"`
  109. Timestamp string `json:"timestamp"`
  110. Nonce string `json:"nonce"`
  111. Encrypted string `json:"encrypted"`
  112. }
  113. // CallbackEvent 解密验签后的回调事件。
  114. type CallbackEvent struct {
  115. Type EventType
  116. Data any
  117. }
  118. // EventType 回调事件类型。
  119. type EventType string
  120. // CompanyCertificationData 机构认证成功回调。
  121. type CompanyCertificationData struct {
  122. CompanyID string `json:"companyId"`
  123. CompanyName string `json:"companyName"`
  124. OpenCompanyID string `json:"openCompanyId"`
  125. RegisterNo string `json:"registerNo"`
  126. ApplicantName string `json:"applicantName"`
  127. ApplicantPhone string `json:"applicantPhone"`
  128. AuthEndTime string `json:"authEndTime"`
  129. CallbackTime string `json:"callbackTime"`
  130. }
  131. // CompanySealAuthData 机构印章静默授权回调。
  132. type CompanySealAuthData struct {
  133. UserName string `json:"userName"`
  134. UserMobile string `json:"userMobile"`
  135. AuthTime string `json:"authTime"`
  136. Status string `json:"status"`
  137. AuthCompanyID string `json:"authCompanyId"`
  138. AuthCompanyName string `json:"authCompanyName"`
  139. CallbackTime string `json:"callbackTime"`
  140. }
  141. // PersonalSealAuthData 个人签名静默授权回调。
  142. type PersonalSealAuthData struct {
  143. UserName string `json:"userName"`
  144. UserMobile string `json:"userMobile"`
  145. UserEmail string `json:"userEmail"`
  146. UserID string `json:"userId"`
  147. OpenUserID string `json:"openUserId"`
  148. AuthTime string `json:"authTime"`
  149. Status string `json:"status"`
  150. CallbackTime string `json:"callbackTime"`
  151. }
  152. // ApplyCompanyParams 个人静默签授权目标法人单位(applyCompany)。
  153. // 定位优先级与机构章一致:契约锁公司 id > openCompanyId > 名称/信用代码。
  154. type ApplyCompanyParams struct {
  155. CompanyID string // 契约锁法人单位 id(tenant_esigns.qys_company_id)
  156. OpenCompanyID string // 三方 openCompanyId(新系统多为 tenant_id;旧系统可能为 org_id)
  157. Name string
  158. RegisterNo string
  159. }
  160. // AuthRecord 静默授权记录摘要。
  161. type AuthRecord struct {
  162. Status string
  163. StartTime string
  164. EndTime string
  165. AuthScope string
  166. ApplyCompanyID string
  167. ApplyCompanyOpenCompanyID string
  168. ApplyCompanyName string
  169. ApplyCompanyRegisterNo string
  170. }
  171. // DefaultPersonalAuthDuration 个人静默授权默认时长(旧系统 10 个月,避免跨年重叠)。
  172. const DefaultPersonalAuthDuration = 10 * 30 * 24 * time.Hour
  173. // DefaultCompanySealAuthDuration 机构印章静默授权默认时长(旧系统 1 年)。
  174. const DefaultCompanySealAuthDuration = 365 * 24 * time.Hour