types.go 5.8 KB

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