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

     1  package mass
     2  
     3  import (
     4  	"github.com/chanxuehong/wechat/mp/core"
     5  )
     6  
     7  const (
     8  	EventTypeMassSendJobFinish core.EventType = "MASSSENDJOBFINISH"
     9  )
    10  
    11  // 事件推送群发结果
    12  type MassSendJobFinishEvent struct {
    13  	XMLName struct{} `xml:"xml" json:"-"`
    14  	core.MsgHeader
    15  	EventType core.EventType `xml:"Event" json:"Event"` // 事件信息, 此处为 MASSSENDJOBFINISH
    16  	MsgId     int64          `xml:"MsgId" json:"MsgId"` // 群发的消息ID, 64位整型
    17  
    18  	// 群发的结构, 为 "send success" 或 "send fail" 或 "err(num)".
    19  	// 但 send success 时, 也有可能因用户拒收公众号的消息, 系统错误等原因造成少量用户接收失败.
    20  	// err(num) 是审核失败的具体原因, 可能的情况如下:
    21  	// err(10001), //涉嫌广告
    22  	// err(20001), //涉嫌政治
    23  	// err(20004), //涉嫌社会
    24  	// err(20002), //涉嫌色情
    25  	// err(20006), //涉嫌违法犯罪
    26  	// err(20008), //涉嫌欺诈
    27  	// err(20013), //涉嫌版权
    28  	// err(22000), //涉嫌互推(互相宣传)
    29  	// err(21000), //涉嫌其他
    30  	Status     string `xml:"Status"     json:"Status"`
    31  	TotalCount int    `xml:"TotalCount" json:"TotalCount"` // group_id 下粉丝数, 或者 openid_list 中的粉丝数
    32  	// 过滤(过滤是指特定地区, 性别的过滤, 用户设置拒收的过滤; 用户接收已超4条的过滤)后,
    33  	// 准备发送的粉丝数, 原则上, FilterCount = SentCount + ErrorCount
    34  	FilterCount int `xml:"FilterCount" json:"FilterCount"`
    35  	SentCount   int `xml:"SentCount"   json:"SentCount"`  // 发送成功的粉丝数
    36  	ErrorCount  int `xml:"ErrorCount"  json:"ErrorCount"` // 发送失败的粉丝数
    37  }
    38  
    39  func GetMassSendJobFinishEvent(msg *core.MixedMsg) *MassSendJobFinishEvent {
    40  	return &MassSendJobFinishEvent{
    41  		MsgHeader:   msg.MsgHeader,
    42  		EventType:   msg.EventType,
    43  		MsgId:       msg.MsgID, // NOTE
    44  		Status:      msg.Status,
    45  		TotalCount:  msg.TotalCount,
    46  		FilterCount: msg.FilterCount,
    47  		SentCount:   msg.SentCount,
    48  		ErrorCount:  msg.ErrorCount,
    49  	}
    50  }