types.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. Result CompanyAuthResult `json:"result"`
  16. }
  17. // CompanyAuthResult 认证审核结果。
  18. type CompanyAuthResult struct {
  19. Status string `json:"status"`
  20. Reason string `json:"reason"`
  21. }
  22. // AuthPassed 是否认证成功。
  23. func (s *CompanyAuthStatus) AuthPassed() bool {
  24. return s.Result.Status == "AUTH_PASSED"
  25. }
  26. // CreateUserParams 在契约锁创建内部用户(医生等需个人签名的成员)。
  27. type CreateUserParams struct {
  28. Name string
  29. OpenUserID string
  30. AccountNo string
  31. Password string
  32. Mobile string
  33. }
  34. // UserInfo 契约锁用户基本信息。
  35. type UserInfo struct {
  36. Name string
  37. }
  38. // CompanySealSpec 企业公章关键字签署位置。
  39. type CompanySealSpec struct {
  40. CompanyName string
  41. Keyword string
  42. OffsetX string
  43. OffsetY string
  44. RotateDegree int64
  45. Page string // 空则不限页;双章场景可设 "1"
  46. }
  47. // PersonalSealSpec 个人签名关键字签署位置。
  48. type PersonalSealSpec struct {
  49. OpenUserID string
  50. Keyword string
  51. }
  52. // SignDocumentRequest PDF 静默签章请求(机构章 + 可选个人签)。
  53. type SignDocumentRequest struct {
  54. PDF []byte
  55. Subject string
  56. ProcessID string // 空则使用 Client 初始化时的 SignDefaults
  57. Launcher string
  58. CompanySeal CompanySealSpec
  59. PersonalSeals []PersonalSealSpec
  60. }
  61. // SignDualCompanyRequest 双企业公章签署(如账单合同甲乙双方)。
  62. type SignDualCompanyRequest struct {
  63. PDF []byte
  64. Subject string
  65. ProcessID string
  66. Launcher string
  67. CompanySeals []CompanySealSpec
  68. }
  69. // Callback request / event types — 与契约锁开放平台事件名一致。
  70. const (
  71. EventCompanyAuthSuccess = "COMPANY_AUTH_SUCCESS"
  72. EventCompanySealAuthSuccess = "COMPANY_SIGN_SILENT_AUTH"
  73. EventUserAuthSuccess = "USER_AUTH_SUCCESS"
  74. EventPersonalSealAuthSuccess = "PERSONAL_SIGN_SILENT_AUTH"
  75. EventCallbackCheck = "CALLBACK_CHECK"
  76. )
  77. // CallbackRequest 契约锁 HTTP 回调原始载荷。
  78. type CallbackRequest struct {
  79. Signature string `json:"signature"`
  80. Timestamp string `json:"timestamp"`
  81. Nonce string `json:"nonce"`
  82. Encrypted string `json:"encrypted"`
  83. }
  84. // CallbackEvent 解密验签后的回调事件。
  85. type CallbackEvent struct {
  86. Type EventType
  87. Data any
  88. }
  89. // EventType 回调事件类型。
  90. type EventType string
  91. // CompanyCertificationData 机构认证成功回调。
  92. type CompanyCertificationData struct {
  93. CompanyID string `json:"companyId"`
  94. CompanyName string `json:"companyName"`
  95. OpenCompanyID string `json:"openCompanyId"`
  96. RegisterNo string `json:"registerNo"`
  97. ApplicantName string `json:"applicantName"`
  98. ApplicantPhone string `json:"applicantPhone"`
  99. AuthEndTime string `json:"authEndTime"`
  100. CallbackTime string `json:"callbackTime"`
  101. }
  102. // CompanySealAuthData 机构印章静默授权回调。
  103. type CompanySealAuthData struct {
  104. UserName string `json:"userName"`
  105. UserMobile string `json:"userMobile"`
  106. AuthTime string `json:"authTime"`
  107. Status string `json:"status"`
  108. AuthCompanyID string `json:"authCompanyId"`
  109. AuthCompanyName string `json:"authCompanyName"`
  110. CallbackTime string `json:"callbackTime"`
  111. }
  112. // PersonalSealAuthData 个人签名静默授权回调。
  113. type PersonalSealAuthData struct {
  114. UserName string `json:"userName"`
  115. UserMobile string `json:"userMobile"`
  116. UserEmail string `json:"userEmail"`
  117. UserID string `json:"userId"`
  118. OpenUserID string `json:"openUserId"`
  119. AuthTime string `json:"authTime"`
  120. Status string `json:"status"`
  121. CallbackTime string `json:"callbackTime"`
  122. }
  123. // AuthRecord 静默授权记录摘要。
  124. type AuthRecord struct {
  125. Status string
  126. StartTime string
  127. EndTime string
  128. AuthScope string
  129. }
  130. // DefaultPersonalAuthDuration 个人静默授权默认时长(旧系统 10 个月,避免跨年重叠)。
  131. const DefaultPersonalAuthDuration = 10 * 30 * 24 * time.Hour
  132. // DefaultCompanySealAuthDuration 机构印章静默授权默认时长(旧系统 1 年)。
  133. const DefaultCompanySealAuthDuration = 365 * 24 * time.Hour