github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/account/event.go (about)

     1  package account
     2  
     3  import (
     4  	"github.com/chanxuehong/wechat/mp/core"
     5  )
     6  
     7  const (
     8  	EventTypeQualificationVerifySuccess core.EventType = "qualification_verify_success" // 资质认证成功(此时立即获得接口权限)
     9  	EventTypeQualificationVerifyFail    core.EventType = "qualification_verify_fail"    // 资质认证失败
    10  	EventTypeNamingVerifySuccess        core.EventType = "naming_verify_success"        // 名称认证成功(即命名成功)
    11  	EventTypeNamingVerifyFail           core.EventType = "naming_verify_fail"           // 名称认证失败(这时虽然客户端不打勾,但仍有接口权限)
    12  	EventTypeAnnualRenew                core.EventType = "annual_renew"                 // 年审通知
    13  	EventTypeVerifyExpired              core.EventType = "verify_expired"               // 认证过期失效通知
    14  )
    15  
    16  // 资质认证成功(此时立即获得接口权限)事件
    17  type QualificationVerifySuccessEvent struct {
    18  	XMLName struct{} `xml:"xml" json:"-"`
    19  	core.MsgHeader
    20  	EventType   core.EventType `xml:"Event"       json:"Event"`
    21  	ExpiredTime int64          `xml:"ExpiredTime" json:"ExpiredTime"` // 有效期 (整形),指的是时间戳,将于该时间戳认证过期
    22  }
    23  
    24  func GetQualificationVerifySuccessEvent(msg *core.MixedMsg) *QualificationVerifySuccessEvent {
    25  	return &QualificationVerifySuccessEvent{
    26  		MsgHeader:   msg.MsgHeader,
    27  		EventType:   msg.EventType,
    28  		ExpiredTime: msg.ExpiredTime,
    29  	}
    30  }
    31  
    32  // 资质认证失败事件
    33  type QualificationVerifyFailEvent struct {
    34  	XMLName struct{} `xml:"xml" json:"-"`
    35  	core.MsgHeader
    36  	EventType  core.EventType `xml:"Event"      json:"Event"`
    37  	FailTime   int64          `xml:"FailTime"   json:"FailTime"`   // 失败发生时间 (整形),时间戳
    38  	FailReason string         `xml:"FailReason" json:"FailReason"` // 认证失败的原因
    39  }
    40  
    41  func GetQualificationVerifyFailEvent(msg *core.MixedMsg) *QualificationVerifyFailEvent {
    42  	return &QualificationVerifyFailEvent{
    43  		MsgHeader:  msg.MsgHeader,
    44  		EventType:  msg.EventType,
    45  		FailTime:   msg.FailTime,
    46  		FailReason: msg.FailReason,
    47  	}
    48  }
    49  
    50  // 名称认证成功(即命名成功)事件
    51  type NamingVerifySuccessEvent struct {
    52  	XMLName struct{} `xml:"xml" json:"-"`
    53  	core.MsgHeader
    54  	EventType   core.EventType `xml:"Event"       json:"Event"`
    55  	ExpiredTime int64          `xml:"ExpiredTime" json:"ExpiredTime"` // 有效期 (整形),指的是时间戳,将于该时间戳认证过期
    56  }
    57  
    58  func GetNamingVerifySuccessEvent(msg *core.MixedMsg) *NamingVerifySuccessEvent {
    59  	return &NamingVerifySuccessEvent{
    60  		MsgHeader:   msg.MsgHeader,
    61  		EventType:   msg.EventType,
    62  		ExpiredTime: msg.ExpiredTime,
    63  	}
    64  }
    65  
    66  // 名称认证失败(这时虽然客户端不打勾,但仍有接口权限)事件
    67  type NamingVerifyFailEvent struct {
    68  	XMLName struct{} `xml:"xml" json:"-"`
    69  	core.MsgHeader
    70  	EventType  core.EventType `xml:"Event"      json:"Event"`
    71  	FailTime   int64          `xml:"FailTime"   json:"FailTime"`   // 失败发生时间 (整形),时间戳
    72  	FailReason string         `xml:"FailReason" json:"FailReason"` // 认证失败的原因
    73  }
    74  
    75  func GetNamingVerifyFailEvent(msg *core.MixedMsg) *NamingVerifyFailEvent {
    76  	return &NamingVerifyFailEvent{
    77  		MsgHeader:  msg.MsgHeader,
    78  		EventType:  msg.EventType,
    79  		FailTime:   msg.FailTime,
    80  		FailReason: msg.FailReason,
    81  	}
    82  }
    83  
    84  // 年审通知事件
    85  type AnnualRenewEvent struct {
    86  	XMLName struct{} `xml:"xml" json:"-"`
    87  	core.MsgHeader
    88  	EventType   core.EventType `xml:"Event"       json:"Event"`
    89  	ExpiredTime int64          `xml:"ExpiredTime" json:"ExpiredTime"` // 有效期 (整形),指的是时间戳,将于该时间戳认证过期,需尽快年审
    90  }
    91  
    92  func GetAnnualRenewEvent(msg *core.MixedMsg) *AnnualRenewEvent {
    93  	return &AnnualRenewEvent{
    94  		MsgHeader:   msg.MsgHeader,
    95  		EventType:   msg.EventType,
    96  		ExpiredTime: msg.ExpiredTime,
    97  	}
    98  }
    99  
   100  // 认证过期失效通知事件
   101  type VerifyExpiredEvent struct {
   102  	XMLName struct{} `xml:"xml" json:"-"`
   103  	core.MsgHeader
   104  	EventType   core.EventType `xml:"Event"       json:"Event"`
   105  	ExpiredTime int64          `xml:"ExpiredTime" json:"ExpiredTime"` // 有效期 (整形),指的是时间戳,表示已于该时间戳认证过期,需要重新发起微信认证
   106  }
   107  
   108  func GetVerifyExpiredEvent(msg *core.MixedMsg) *VerifyExpiredEvent {
   109  	return &VerifyExpiredEvent{
   110  		MsgHeader:   msg.MsgHeader,
   111  		EventType:   msg.EventType,
   112  		ExpiredTime: msg.ExpiredTime,
   113  	}
   114  }