升级至8069版本:版本号更新/代理配置系统/红包计时埋点/长连接重构/回调修复

This commit is contained in:
2026-02-26 10:44:13 +08:00
parent 7cbd3d061d
commit 40a74d2ea7
38 changed files with 3639 additions and 235 deletions

View File

@@ -11,6 +11,7 @@ import (
"strings"
"xiawan/wx/clientsdk/baseinfo"
"xiawan/wx/clientsdk/baseutils"
"xiawan/wx/clientsdk/mmtls"
"github.com/gogf/gf/database/gredis"
)
@@ -21,6 +22,25 @@ var GlobalSetting Setting
// TaskExecWaitTimes 任务执行间隔时间 500毫秒
var TaskExecWaitTimes = uint32(500)
// ProxyConfig 代理配置
type ProxyConfig struct {
// 代理失效后是否允许直连false=不允许连接失败true=允许,降级为直连)
AllowDirectOnProxyFail bool `json:"allowDirectOnProxyFail"`
// 长连接超时时间(秒)
LongConnTimeout int `json:"longConnTimeout"`
LongConnReadTimeout int `json:"longConnReadTimeout"`
// 长连接建立时的重试次数
LongConnRetryTimes int `json:"longConnRetryTimes"`
// 长连接建立时的重试间隔(毫秒)
LongConnRetryInterval int `json:"longConnRetryInterval"`
// 短连接超时时间(秒)
ShortConnTimeout int `json:"shortConnTimeout"`
// 长连接断开后最大重试恢复次数
MaxLongRetryTimes int `json:"maxLongRetryTimes"`
// 长连接断开后重试间隔(秒)
LongRetryInterval int `json:"longRetryInterval"`
}
// Setting 设置
type Setting struct {
Debug bool `json:"debug"`
@@ -63,6 +83,8 @@ type Setting struct {
Mac2Ipad bool `json:"mac2ipad"`
// 是否开启 car2ipad
Car2Ipad bool `json:"car2ipad"`
// 代理配置
ProxyConfig ProxyConfig `json:"proxyConfig"`
}
// getExternal 请求获取外网ip
@@ -148,4 +170,47 @@ func ConfigSetUp() {
if GlobalSetting.TargetIp == "" && GlobalSetting.SycnTargetIpUrl != "" {
GlobalSetting.TargetIp = getExternal()
}
// 设置代理配置默认值
if GlobalSetting.ProxyConfig.LongConnTimeout <= 0 {
GlobalSetting.ProxyConfig.LongConnTimeout = 15
}
if GlobalSetting.ProxyConfig.LongConnReadTimeout <= 0 {
readTimeout := GlobalSetting.ProxyConfig.LongConnTimeout
if readTimeout < 210 {
readTimeout = 210
}
GlobalSetting.ProxyConfig.LongConnReadTimeout = readTimeout
}
if GlobalSetting.ProxyConfig.LongConnRetryTimes <= 0 {
GlobalSetting.ProxyConfig.LongConnRetryTimes = 30
}
if GlobalSetting.ProxyConfig.LongConnRetryInterval <= 0 {
GlobalSetting.ProxyConfig.LongConnRetryInterval = 500
}
if GlobalSetting.ProxyConfig.ShortConnTimeout <= 0 {
GlobalSetting.ProxyConfig.ShortConnTimeout = 15
}
if GlobalSetting.ProxyConfig.MaxLongRetryTimes <= 0 {
GlobalSetting.ProxyConfig.MaxLongRetryTimes = 10
}
if GlobalSetting.ProxyConfig.LongRetryInterval <= 0 {
GlobalSetting.ProxyConfig.LongRetryInterval = 60
}
// 同步代理配置到 mmtls 全局配置
mmtls.GlobalProxyConfig.LongConnTimeout = GlobalSetting.ProxyConfig.LongConnTimeout
mmtls.GlobalProxyConfig.LongConnReadTimeout = GlobalSetting.ProxyConfig.LongConnReadTimeout
mmtls.GlobalProxyConfig.LongConnRetryTimes = GlobalSetting.ProxyConfig.LongConnRetryTimes
mmtls.GlobalProxyConfig.LongConnRetryInterval = GlobalSetting.ProxyConfig.LongConnRetryInterval
mmtls.GlobalProxyConfig.ShortConnTimeout = GlobalSetting.ProxyConfig.ShortConnTimeout
mmtls.GlobalProxyConfig.AllowDirectOnProxyFail = GlobalSetting.ProxyConfig.AllowDirectOnProxyFail
fmt.Printf("======== 代理配置已同步 ========\n")
fmt.Printf("代理失效后允许直连: %v\n", GlobalSetting.ProxyConfig.AllowDirectOnProxyFail)
fmt.Printf("长连接超时: %d秒\n", GlobalSetting.ProxyConfig.LongConnTimeout)
fmt.Printf("长连接重试次数: %d次\n", GlobalSetting.ProxyConfig.LongConnRetryTimes)
fmt.Printf("长连接重试间隔: %dms\n", GlobalSetting.ProxyConfig.LongConnRetryInterval)
fmt.Printf("短连接超时: %d秒\n", GlobalSetting.ProxyConfig.ShortConnTimeout)
fmt.Printf("========================\n")
}

View File

@@ -15,6 +15,7 @@ import (
"xiawan/wx/clientsdk/mmtls"
"xiawan/wx/db"
"xiawan/wx/srv"
"xiawan/wx/srv/srvconfig"
"xiawan/wx/srv/websrv"
"xiawan/wx/srv/wxface"
)
@@ -235,10 +236,9 @@ func (wxconn *WXConnect) StartShortReader() {
return
}
forCount := 0
// 最大重试次数
const maxLongRetries = 5
// 最小重试间隔 (秒)
const minRetryInterval = 60
// 从配置获取最大重试次数和重试间隔
maxLongRetries := srvconfig.GlobalSetting.ProxyConfig.MaxLongRetryTimes
minRetryInterval := int64(srvconfig.GlobalSetting.ProxyConfig.LongRetryInterval)
for {
// 判断是否重复启动 for 循环
@@ -311,8 +311,11 @@ func (wxconn *WXConnect) StartShortReader() {
shouldRetry := (currentTime-wxconn.lastLongRetryTime >= minRetryInterval) &&
(wxconn.longRetryCount < maxLongRetries)
// 如果重试计数器已达上限但已经过去了更长时间比如10分钟),重置计数器
// 如果重试计数器已达上限但已经过去了更长时间比如10倍间隔),重置计数器
if wxconn.longRetryCount >= maxLongRetries && (currentTime-wxconn.lastLongRetryTime >= minRetryInterval*10) {
log.Printf("[%s],[%s] 重置长连接重试计数器(已过去足够长时间)\n",
wxconn.GetWXAccount().GetUserInfo().GetUserName(),
wxconn.GetWXAccount().GetUserInfo().NickName)
wxconn.longRetryCount = 0
shouldRetry = true
}
@@ -369,10 +372,11 @@ func (wxconn *WXConnect) StartShortReader() {
} else if wxconn.longRetryCount >= maxLongRetries {
// 只有在第一次达到最大重试次数时记录日志
if wxconn.longRetryCount == maxLongRetries {
log.Printf("[%s],[%s] 已达到最大重试次数(%d),暂停长连接恢复尝试\n",
log.Printf("[%s],[%s] 已达到最大重试次数(%d),暂停长连接恢复尝试(将在%d秒后重置\n",
wxconn.GetWXAccount().GetUserInfo().GetUserName(),
wxconn.GetWXAccount().GetUserInfo().NickName,
maxLongRetries)
maxLongRetries,
minRetryInterval*10)
wxconn.longRetryCount++ // 增加一次以避免重复打印
}
}
@@ -597,6 +601,14 @@ func (wxconn *WXConnect) startLongLink() error {
}
tmpMMInfo.Dialer = dialer
// 设置代理配置到MMInfo
tmpMMInfo.LongConnTimeout = srvconfig.GlobalSetting.ProxyConfig.LongConnTimeout
tmpMMInfo.LongConnReadTimeout = srvconfig.GlobalSetting.ProxyConfig.LongConnReadTimeout
tmpMMInfo.LongConnRetryTimes = srvconfig.GlobalSetting.ProxyConfig.LongConnRetryTimes
tmpMMInfo.LongConnRetryInterval = srvconfig.GlobalSetting.ProxyConfig.LongConnRetryInterval
tmpMMInfo.ShortConnTimeout = srvconfig.GlobalSetting.ProxyConfig.ShortConnTimeout
tmpMMInfo.AllowDirectOnProxyFail = srvconfig.GlobalSetting.ProxyConfig.AllowDirectOnProxyFail
wxconn.setConnected(true)
userInfo.MMInfo = tmpMMInfo
// 启动长链接发送接收协程(创建新的定时器)

View File

@@ -1480,7 +1480,9 @@ func (wxqi *WXReqInvoker) SendOpenRedEnvelopesRequest(hbItem *baseinfo.HongBaoIt
hongBaoReceiverItem.InWay = baseinfo.MMHongBaoReqInAwayPersonal
}
// 发送接收红包请求
recvReqStartMs := time.Now().UnixMilli()
packHeader, err := clientsdk.SendReceiveWxHB(wxqi.wxconn.GetWXAccount().GetUserInfo(), hongBaoReceiverItem)
recvReqEndMs := time.Now().UnixMilli()
if err != nil {
if packHeader != nil && packHeader.RetCode == baseinfo.MMRequestRetSessionTimeOut {
// token登陆
@@ -1489,25 +1491,52 @@ func (wxqi *WXReqInvoker) SendOpenRedEnvelopesRequest(hbItem *baseinfo.HongBaoIt
return nil, err
}
var hongbaoResp wechat.HongBaoRes
parseRespStartMs := time.Now().UnixMilli()
errs := clientsdk.ParseResponseData(tmpUserInfo, packHeader, &hongbaoResp)
parseRespEndMs := time.Now().UnixMilli()
if errs != nil {
return nil, errs
}
// 解析
retHongBaoReceiveResp := &baseinfo.HongBaoReceiverResp{}
unmarshalRecvStartMs := time.Now().UnixMilli()
err = json.Unmarshal(hongbaoResp.GetRetText().GetBuffer(), retHongBaoReceiveResp)
unmarshalRecvEndMs := time.Now().UnixMilli()
if err != nil {
return nil, err
}
// 发送给微信消息处理器 打开红包
openReqStartMs := time.Now().UnixMilli()
rsp, er := wxqi.SendOpenWxHBNewRequest(hbItem, retHongBaoReceiveResp.TimingIdentifier)
openReqEndMs := time.Now().UnixMilli()
if er != nil {
return nil, er
}
wxqi.SendOpenHBMsgToSelf(rsp, hbItem)
wxqi.ThanksHB(rsp)
var data RedPacket
if rsp != nil {
_ = json.Unmarshal(rsp.RetText.Buffer, &data)
}
nowMs := time.Now().UnixMilli()
if hbItem != nil && hbItem.RecvAtMs > 0 && data.Retcode == 0 && data.ReceiveStatus == 2 {
detectToEnqueue := hbItem.EnqueueAtMs - hbItem.RecvAtMs
enqueueToDequeue := hbItem.DequeueAtMs - hbItem.EnqueueAtMs
dequeueToRecvStart := recvReqStartMs - hbItem.DequeueAtMs
recvNet := recvReqEndMs - recvReqStartMs
parseResp := parseRespEndMs - parseRespStartMs
unmarshalRecv := unmarshalRecvEndMs - unmarshalRecvStartMs
openNet := openReqEndMs - openReqStartMs
openDoneMs := openReqEndMs - hbItem.RecvAtMs
totalMs := nowMs - hbItem.RecvAtMs
fmt.Printf("红包耗时 total=%dms open=%dms detect->enqueue=%dms enqueue->dequeue=%dms dequeue->recvStart=%dms recvNet=%dms parse=%dms recvUnmarshal=%dms openNet=%dms sendid=%s isGroup=%d fromUser=%s\n",
totalMs, openDoneMs, detectToEnqueue, enqueueToDequeue, dequeueToRecvStart, recvNet, parseResp, unmarshalRecv, openNet, data.SendId, hbItem.IsGroup, hbItem.FromUserName)
}
// go func() {
// wxqi.SendOpenHBMsgToSelf(rsp, hbItem)
// wxqi.ThanksHB(rsp)
// }()
return rsp, nil
}
@@ -2052,12 +2081,16 @@ func (wxqi *WXReqInvoker) SendOpenWxHBNewRequest(hbItem *baseinfo.HongBaoItem, t
var packHeader *baseinfo.PackHeader
var err error
openSendStartMs := time.Now().UnixMilli()
openPath := "openwxhb"
if hongBaoOpenItem.SceneID == 1005 {
hongBaoOpenItem.CgiCmd = 5148 // 这里是pb字段的cgicmd 抓包得到
packHeader, err = clientsdk.SendOpenUninoHB(wxqi.wxconn.GetWXAccount().GetUserInfo(), hongBaoOpenItem)
openPath = "openunionhb"
} else {
packHeader, err = clientsdk.SendOpenWxHB(wxqi.wxconn.GetWXAccount().GetUserInfo(), hongBaoOpenItem)
}
openSendEndMs := time.Now().UnixMilli()
if err != nil {
if packHeader != nil && packHeader.RetCode == baseinfo.MMRequestRetSessionTimeOut {
@@ -2069,12 +2102,17 @@ func (wxqi *WXReqInvoker) SendOpenWxHBNewRequest(hbItem *baseinfo.HongBaoItem, t
//wechat.HongBaoRes{}
// 解析获取联系人响应
resp := new(wechat.HongBaoRes)
openParseStartMs := time.Now().UnixMilli()
err = clientsdk.ParseResponseData(tmpUserInfo, packHeader, resp)
openParseEndMs := time.Now().UnixMilli()
if err != nil {
// token登陆
wxqi.wxconn.SendAutoAuthWaitingMinutes(4)
return nil, err
}
if hbItem != nil && hbItem.RecvAtMs > 0 {
fmt.Printf("红包open阶段 send=%dms parse=%dms path=%s cgi=%d scene=%d\n", openSendEndMs-openSendStartMs, openParseEndMs-openParseStartMs, openPath, hongBaoOpenItem.CgiCmd, hongBaoOpenItem.SceneID)
}
return resp, nil
}

View File

@@ -1,7 +1,6 @@
package wxcore
import (
"fmt"
"xiawan/wx/srv/wxface"
"xiawan/wx/srv/wxtask"
)
@@ -37,7 +36,7 @@ func NewWXTaskMgr(wxConn wxface.IWXConnect) wxface.IWXTaskMgr {
// Start 启动
func (wxtm *WXTaskMgr) Start() {
fmt.Println("启动微信任务管理器")
// fmt.Println("启动微信任务管理器")
//处理异常
// defer TryE("(wxtm *WXTaskMgr) Start()")
if wxtm.start {

View File

@@ -80,6 +80,7 @@ func (cqr *WXCheckQrcodeRouter) Handle(wxResp wxface.IWXResponse) error {
str := byteArrayToString(retBytes)
ticketValue := extractTicketValue(str)
// fmt.Println(ticketValue, 111111111111)
if ticketValue != "" {
// 赋值ticketValue

View File

@@ -116,6 +116,14 @@ func (glqr *WXManualAuthRouter) Handle(wxResp wxface.IWXResponse) error {
db.SetLoginLog("ManualAuth", currentWXAccount, "登录成功!", retCode)
fmt.Println("currentUserInfo扫码登录响应路由", currentUserInfo.DeviceInfo)
db.SaveUserInfo(currentUserInfo)
go func() {
time.Sleep(10 * time.Second)
if !currentCache.IsInitNewSyncFinished() {
fmt.Println("[回调修复] 登录后自动设置初始化完成标志,确保回调正常工作")
currentCache.SetInitNewSyncFinished(true)
}
}()
/*time.Sleep(time.Second * 10)
currentWXConn.Stop()*/
}()

View File

@@ -67,6 +67,7 @@ func (hbr *WXNewSyncRouter) Handle(wxResp wxface.IWXResponse) error {
// 如果没有同步到数据则返回bInitNewSyncFinished
cmdList := syncResp.GetCmdList()
syncCount := cmdList.GetCount()
continueFlag := syncResp.GetContinueFlag()
//log.Info(syncResp.GetContinueFlag(), syncCount)
//redis 发布结构体
messageResp := new(table.SyncMessageResponse)
@@ -132,10 +133,10 @@ func (hbr *WXNewSyncRouter) Handle(wxResp wxface.IWXResponse) error {
}
}
// 判断消息初始化完成
if syncCount <= 0 {
if continueFlag <= 0 || syncCount <= 0 {
if !currentWXCache.IsInitNewSyncFinished() {
// 禁用历史消息推送,不设置初始化完成标志
currentWXCache.SetInitNewSyncFinished(true)
fmt.Println("[回调修复] 历史消息同步完成,自动激活回调功能")
}
}
@@ -314,21 +315,21 @@ func dealAddMsgRun(wxConn wxface.IWXConnect, addMsg *wechat.AddMsg, syncType str
// } else if strings.HasSuffix(fromUserName, "@chatroom") {
// // 红包处理
// dealGroupHB(wxConn, msgContent, fromUserName)
// // 群转账给我处理
// if toUserName == wxAccount.GetUserInfo().GetUserName() {
// dealAutoTransfer(wxConn, msgContent, fromUserName)
// }
// // // 群转账给我处理
// // if toUserName == wxAccount.GetUserInfo().GetUserName() {
// // dealAutoTransfer(wxConn, msgContent, fromUserName)
// // }
// } else {
// // 判断是个人红包
// dealPersonHB(wxConn, msgContent, fromUserName)
// // 个人转账处理
// if toUserName == wxAccount.GetUserInfo().GetUserName() {
// dealAutoTransfer(wxConn, msgContent, fromUserName)
// }
// // // 个人转账处理
// // if toUserName == wxAccount.GetUserInfo().GetUserName() {
// // dealAutoTransfer(wxConn, msgContent, fromUserName)
// // }
// // 邀请入群处理
// // 创建一个数组,用于存储命令
// newMsgId := strconv.FormatUint(uint64(addMsg.GetNewMsgId()), 10)
// dealAutoJoinGroup(wxConn, msgContent, newMsgId)
// // newMsgId := strconv.FormatUint(uint64(addMsg.GetNewMsgId()), 10)
// // dealAutoJoinGroup(wxConn, msgContent, newMsgId)
// }
// }
// 判断是否是命令
@@ -927,9 +928,9 @@ func dealGroupHB(wxConn wxface.IWXConnect, content string, groupWXID string) {
currentTaskMgr := wxConn.GetWXTaskMgr()
taskMgr, _ := currentTaskMgr.(*wxcore.WXTaskMgr)
currentGrapHBMgr := taskMgr.GetGrabHBTask()
if !currentGrapHBMgr.IsAutoGrap() {
return
}
// if !currentGrapHBMgr.IsAutoGrap() {
// return
// }
// 解析引用的消息
tmpMsg := new(baseinfo.Msg)
err := xml.Unmarshal([]byte(content), tmpMsg)
@@ -947,70 +948,71 @@ func dealGroupHB(wxConn wxface.IWXConnect, content string, groupWXID string) {
return
}
}
//是否置顶的群
isTopGroup := currentGrapHBMgr.IsTopGroup(groupWXID)
//false 不抢置顶群, true 只抢置顶群)判断没有置顶 return
if currentGrapHBMgr.IsNotTopGroup() && !isTopGroup {
return
}
//false 不抢置顶群) 判断已置顶 return
if !currentGrapHBMgr.IsNotTopGroup() && isTopGroup {
return
}
recvAtMs := time.Now().UnixMilli()
// //是否置顶的群
// isTopGroup := currentGrapHBMgr.IsTopGroup(groupWXID)
// //false 不抢置顶群, true 只抢置顶群)判断没有置顶 return
// if currentGrapHBMgr.IsNotTopGroup() && !isTopGroup {
// return
// }
// //false 不抢置顶群) 判断已置顶 return
// if !currentGrapHBMgr.IsNotTopGroup() && isTopGroup {
// return
// }
//延迟抢红包
delaytime := currentGrapHBMgr.GetDelayOpen()
if int(delaytime) >= 1 {
time.Sleep(time.Duration(delaytime) * time.Second)
}
// delaytime := currentGrapHBMgr.GetDelayOpen()
// if int(delaytime) >= 1 {
// time.Sleep(time.Duration(delaytime) * time.Second)
// }
// 过滤汉字/字母红包
if currentGrapHBMgr.IsFilterText() {
text := tmpMsg.APPMsg.WCPayInfo.ReceiverTitle
// 判断是否包含汉字或字母
if isTextContainsChineseOrLetter(text) {
return
}
}
// if currentGrapHBMgr.IsFilterText() {
// text := tmpMsg.APPMsg.WCPayInfo.ReceiverTitle
// // 判断是否包含汉字或字母
// if isTextContainsChineseOrLetter(text) {
// return
// }
// }
// 过滤测挂红包
if currentGrapHBMgr.IsFilterCheats() {
filterCheatsKey := currentGrapHBMgr.GetFilterCheatsKey()
// fmt.Println(filterCheatsKey)
// 字符串转 数组
temKeywords := strings.Split(filterCheatsKey, ",")
// 关键字
keywords := make([]string, 0)
// 去掉头尾空格
for i := 0; i < len(temKeywords); i++ {
keywordItem := strings.TrimSpace(temKeywords[i])
if keywordItem != "" {
keywords = append(keywords, keywordItem)
}
}
// fmt.Println(keywords)
// 判断关键字是否为空
if len(keywords) > 0 {
text := tmpMsg.APPMsg.WCPayInfo.ReceiverTitle
for _, keyword := range keywords {
if strings.Contains(text, keyword) {
return
}
}
}
}
// if currentGrapHBMgr.IsFilterCheats() {
// filterCheatsKey := currentGrapHBMgr.GetFilterCheatsKey()
// // fmt.Println(filterCheatsKey)
// // 字符串转 数组
// temKeywords := strings.Split(filterCheatsKey, ",")
// // 关键字
// keywords := make([]string, 0)
// // 去掉头尾空格
// for i := 0; i < len(temKeywords); i++ {
// keywordItem := strings.TrimSpace(temKeywords[i])
// if keywordItem != "" {
// keywords = append(keywords, keywordItem)
// }
// }
// // fmt.Println(keywords)
// // 判断关键字是否为空
// if len(keywords) > 0 {
// text := tmpMsg.APPMsg.WCPayInfo.ReceiverTitle
// for _, keyword := range keywords {
// if strings.Contains(text, keyword) {
// return
// }
// }
// }
// }
// 开始抢红包
hbItem := new(baseinfo.HongBaoItem)
hbItem.IsGroup = 1
hbItem.SceneID = tmpMsg.APPMsg.WCPayInfo.SceneID
hbItem.NativeURL = tmpMsg.APPMsg.WCPayInfo.NativeURL
hbItem.RecvAtMs = recvAtMs
hongBaoURLItem, err := clientsdk.ParseHongBaoURL(hbItem.NativeURL, groupWXID)
if err != nil {
return
}
// fmt.Print("\n开始抢红包\n")
fmt.Print("\n开始抢红包\n")
hbItem.URLItem = hongBaoURLItem
hbItem.FromUserName = tmpMsg.FromUserName
currentGrapHBMgr.AddHBItem(hbItem)
// fmt.Print("\n抢群红包\n")
}
// 处理自动抢红包操作(私发)
@@ -1037,6 +1039,7 @@ func dealPersonHB(wxConn wxface.IWXConnect, content string, groupWXID string) {
if tmpMsg.APPMsg.WCPayInfo.SceneID != baseinfo.MMPayInfoSceneIDHongBao {
return
}
recvAtMs := time.Now().UnixMilli()
//延迟抢红包
delaytime := currentGrapHBMgr.GetDelayOpen()
if int(delaytime) >= 1 {
@@ -1047,6 +1050,7 @@ func dealPersonHB(wxConn wxface.IWXConnect, content string, groupWXID string) {
hbItem := new(baseinfo.HongBaoItem)
hbItem.IsGroup = 0
hbItem.NativeURL = tmpMsg.APPMsg.WCPayInfo.NativeURL
hbItem.RecvAtMs = recvAtMs
hongBaoURLItem, err := clientsdk.ParseHongBaoURL(hbItem.NativeURL, groupWXID)
if err != nil {
return

View File

@@ -2,6 +2,7 @@ package wxtask
import (
"sync"
"time"
"xiawan/wx/clientsdk/baseinfo"
"xiawan/wx/db"
"xiawan/wx/srv/wxface"
@@ -87,6 +88,9 @@ func (ghbm *WXGrabHBTask) grapHB() {
for {
select {
case ghbm.currentHBItem = <-ghbm.hongBaoItemChan:
if ghbm.currentHBItem != nil {
ghbm.currentHBItem.DequeueAtMs = time.Now().UnixMilli()
}
// 直接发送抢红包请求,不等待响应
go ghbm.wxConn.GetWXReqInvoker().SendOpenRedEnvelopesRequest(ghbm.currentHBItem)
// 立即准备抢下一个红包,不等待当前红包处理完成
@@ -145,6 +149,9 @@ func (ghbm *WXGrabHBTask) GrapNext() {
func (ghbm *WXGrabHBTask) AddHBItem(hbItem *baseinfo.HongBaoItem) {
// 抢红包操作
// ghbm.wxConn.GetWXReqInvoker().SendOpenRedEnvelopesRequest(hbItem)
if hbItem != nil && hbItem.EnqueueAtMs <= 0 {
hbItem.EnqueueAtMs = time.Now().UnixMilli()
}
ghbm.hongBaoItemChan <- hbItem
if !ghbm.isStart {
ghbm.Start()