scrm-go

open_wechat_model.go 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. package wechat_service
  2. import (
  3. "encoding/xml"
  4. "time"
  5. "github.com/silenceper/wechat/menu"
  6. )
  7. //MsgEncrypt 微信平台向第三方平台授权事件接收URL推送的xml数据结构
  8. type MsgEncrypt struct {
  9. AppID string `xml:"AppId"`
  10. Encrypt string `xml:"Encrypt"`
  11. }
  12. //ComponentRequestBody 第三方平台授权事件接收URL接收数据后解密后的基本结构,
  13. //有各种不同的结构:Ticket,AuthorizedStruct,UnauthorizedStruct,UpdateauthorizedStruct,由InfoType.InfoType判断
  14. type ComponentRequestBody struct {
  15. AppID string `xml:"AppId"`
  16. CreateTime string `xml:"CreateTime"`
  17. InfoType string `xml:"InfoType"`
  18. // 接收微信平台向第三方平台授权事件接收URL推送,InfoType为component_verify_ticket时,返回
  19. ComponentVerifyTicket string `xml:"ComponentVerifyTicket,omitempty"`
  20. // 微信平台向第三方平台授权事件接收URL推送的数据,InfoType为authorized,unauthorized,updateauthorized时间有返回
  21. AuthorizerAppid string `xml:"AuthorizerAppid,omitempty"`
  22. // 微信平台向第三方平台授权事件接收URL推送的数据,InfoType为authorized,updateauthorized时间有返回
  23. AuthorizationCode string `xml:"AuthorizationCode,omitempty"`
  24. AuthorizationCodeExpiredTime string `xml:"AuthorizationCodeExpiredTime,omitempty"`
  25. PreAuthCode string `xml:"PreAuthCode,omitempty"`
  26. }
  27. type EncryptRequestBody struct {
  28. XMLName xml.Name `xml:"xml"`
  29. ToUserName string
  30. Encrypt string
  31. }
  32. type TextRequestBody struct {
  33. XMLName xml.Name `xml:"xml"`
  34. ToUserName string
  35. FromUserName string
  36. CreateTime time.Duration
  37. MsgType string
  38. Event string
  39. EventKey string
  40. Url string
  41. PicUrl string
  42. MediaId string
  43. ThumbMediaId string
  44. Content string
  45. MsgId int
  46. Location_X string
  47. Location_Y string
  48. Label string
  49. }
  50. type CDATAText struct {
  51. Text string `xml:",innerxml"`
  52. }
  53. type EncryptResponseBody struct {
  54. XMLName xml.Name `xml:"xml"`
  55. Encrypt CDATAText
  56. MsgSignature CDATAText
  57. TimeStamp string
  58. Nonce CDATAText
  59. }
  60. type TextResponseBody struct {
  61. XMLName xml.Name `xml:"xml"`
  62. ToUserName CDATAText
  63. FromUserName CDATAText
  64. CreateTime string
  65. MsgType CDATAText
  66. Content CDATAText
  67. }
  68. type MPResult struct {
  69. ErrCode int64 `json:"errcode"`
  70. ErrMsg string `json:"errmsg"`
  71. }
  72. //ComponentAccessToken 第三方平台主动向微信服务器请求第三方平台自己的component_access_token返回的数据结构
  73. type ComponentAccessToken struct {
  74. ComponentAccessToken string `json:"component_access_token"`
  75. ExpiresIn int `json:"expires_in"`
  76. }
  77. //PreAuthCode 第三方平台主动向微信服务器请求第三方平台预授权码pre_auth_code返回的数据结构
  78. type PreAuthCode struct {
  79. PreAuthCode string `json:"pre_auth_code"`
  80. ExpiresIn int `json:"expires_in"`
  81. }
  82. //AuthorizationInfo 公众号向第三方平台授权成功后,在redirect_uri利用auth_code(公众号确定授权后,微信拼接在redirect_uri上,用来交换AuthorizationInfo)主动请求授权信息
  83. type AuthorizationInfo struct {
  84. AuthorizationInfo struct {
  85. AuthorizerAppid string `json:"authorizer_appid"`
  86. AuthorizerAccessToken string `json:"authorizer_access_token"`
  87. ExpiresIn int64 `json:"expires_in"`
  88. AuthorizerRefreshToken string `json:"authorizer_refresh_token"`
  89. FuncInfo []FuncInfoItems `json:"func_info"`
  90. } `json:"authorization_info"`
  91. }
  92. type FuncInfoItems struct {
  93. FuncscopeCategory struct {
  94. ID int64 `json:"id"`
  95. } `json:"funcscope_category"`
  96. }
  97. //AuthorizerInfo 第三方平利用authorizer_appid(公众号的appid,授权确定后获得,AuthorizationInfo.authorizer_appid)和component_appid(第三方平台appid,在微信开发平台新建一个第三方应用时生成)
  98. type AuthorizerInfo struct {
  99. AuthorizerInfo struct {
  100. NickName string `json:"nick_name"`
  101. HeadImg string `json:"head_img"`
  102. ServiceTypeInfo AuthorizerInfoTypeInfo `json:"service_type_info"`
  103. VerifyTypeInfo AuthorizerInfoTypeInfo `json:"verify_type_info"`
  104. UserName string `json:"user_name"`
  105. QrcodeURL string `json:"qrcode_url"`
  106. PrincipalName string `json:"principal_name"`
  107. BusinessInfo BusinessInfo `json:"business_info"`
  108. } `json:"authorizer_info"`
  109. }
  110. type AuthorizerInfoTypeInfo struct {
  111. ID int64 `json:"id"`
  112. }
  113. type BusinessInfo struct {
  114. OpenPay int64 `json:"open_pay"`
  115. OpenShake int64 `json:"open_shake"`
  116. OpenScan int64 `json:"open_scan"`
  117. OpenCard int64 `json:"open_card"`
  118. OpenStore int64 `json:"open_store"`
  119. }
  120. //微信菜单形式
  121. type SelfMenuInfo struct {
  122. Button []SelfMenuButton `json:"button"`
  123. }
  124. //reqMenu 设置菜单请求数据
  125. type RRreqMenu struct {
  126. Button []*menu.Button `json:"button,omitempty"`
  127. MatchRule *menu.MatchRule `json:"matchrule,omitempty"`
  128. }
  129. //SelfMenuButton 自定义菜单配置详情
  130. type SelfMenuButton struct {
  131. Type string `json:"type"`
  132. Name string `json:"name"`
  133. Key string `json:"key"`
  134. URL string `json:"url,omitempty"`
  135. Value string `json:"value,omitempty"`
  136. Act string `json:"act,omitempty"`
  137. MediaId string `json:"media_id,omitempty"`
  138. SubButton []SelfMenuButton `json:"sub_button"`
  139. }