发送邮件添加渠道筛选

This commit is contained in:
sk 2024-06-03 10:51:51 +08:00
parent e1812b5ecf
commit 35c0e07004
7 changed files with 558 additions and 532 deletions

View File

@ -74,10 +74,11 @@ type Message struct {
Params []int32 //额外参数
Platform string //平台信息
ShowId int64 //区分主子游戏大厅
Channel []string //渠道
}
func NewMessage(pid string, srcId int32, srcName string, snid, mType int32, title, content string, coin, diamond int64,
state int32, addTime int64, attachState int32, giftId string, params []int32, platform string, showId int64) *Message {
state int32, addTime int64, attachState int32, giftId string, params []int32, platform string, showId int64, channel []string) *Message {
if srcName == "" {
srcName = "{\"zh\":\"系统\",\"vi\":\"GM\",\"en\":\"GM\",\"kh\":\"GM\"}"
}
@ -99,6 +100,7 @@ func NewMessage(pid string, srcId int32, srcName string, snid, mType int32, titl
Platform: platform,
Diamond: diamond,
ShowId: showId,
Channel: channel,
}
if msg.Pid == "" {
msg.Pid = msg.Id.Hex()

File diff suppressed because it is too large Load Diff

View File

@ -468,6 +468,7 @@ message ASCreateShortMessage{
int64 Diamond = 8;
int64 ShowId = 9;
repeated int32 Params = 10;
repeated string OnChannelName = 11;
}
message SACreateShortMessage{
TagCode Tag = 1; //

View File

@ -86,7 +86,7 @@ func (this *CSInviteCodePlayerHandler) Process(s *netlib.Session, packetid int,
//发送邮件
var otherParams []int32
newMsg := model.NewMessage("", p.SnId, "", p.SnId, model.MSGTYPE_INVITECODE, p.Name, inviteCode, coin, 0,
model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, p.Platform, model.HallAll)
model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, p.Platform, model.HallAll, nil)
err = model.InsertMessage(p.Platform, newMsg)
if err == nil {

View File

@ -561,22 +561,21 @@ func (this *Player) SendGameConfig(gameId int32, plf, chl string) {
}
func (this *Player) LoadMessage(lastLogoutTime int64, isFirstLogin, isSkipWeek bool) {
task.New(nil,
task.CallableWrapper(func(o *basic.Object) interface{} {
//msgs, err := model.GetMessageByNotState(this.SnId, model.MSGSTATE_REMOVEED)
//if err == nil {
// return msgs
//} else {
// logger.Logger.Warnf("[%v] LoadMessage err:%v", this.Name, err)
//}
msgs, err := model.GetMessage(this.Platform, this.SnId) // model.GetNotDelMessage(this.Platform, this.SnId)
if err == nil {
return msgs
} else {
logger.Logger.Warnf("[%v] LoadMessage err:%v", this.Name, err)
}
return nil
}),
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
//msgs, err := model.GetMessageByNotState(this.SnId, model.MSGSTATE_REMOVEED)
//if err == nil {
// return msgs
//} else {
// logger.Logger.Warnf("[%v] LoadMessage err:%v", this.Name, err)
//}
msgs, err := model.GetMessage(this.Platform, this.SnId) // model.GetNotDelMessage(this.Platform, this.SnId)
if err == nil {
return msgs
} else {
logger.Logger.Warnf("[%v] LoadMessage err:%v", this.Name, err)
}
return nil
}),
task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
if data != nil {
if msgs, ok := data.([]model.Message); ok {
@ -612,7 +611,7 @@ func (this *Player) LoadMessage(lastLogoutTime int64, isFirstLogin, isSkipWeek b
if bHasAddToPlayer == false {
newMsg := model.NewMessage(msg.Id.Hex(), msg.SrcId, "", this.SnId, msg.MType, msg.Title,
msg.Content, msg.Coin, msg.Diamond, model.MSGSTATE_UNREAD, msg.CreatTs, msg.AttachState,
msg.GiftId, msg.Params, msg.Platform, msg.ShowId)
msg.GiftId, msg.Params, msg.Platform, msg.ShowId, msg.Channel)
dbMsgs = append(dbMsgs, newMsg)
}
}
@ -661,6 +660,9 @@ func (this *Player) SendMessage(showId int64) {
for _, msg := range this.msgs {
if msg.State != model.MSGSTATE_REMOVEED && (msg.ShowId == model.HallAll || msg.ShowId&showId != 0) {
if len(msg.Channel) > 0 && !common.InSliceString(msg.Channel, this.LastChannel) {
continue
}
giftState := int32(0)
//if len(msg.GiftId) > 0 {
@ -846,6 +848,10 @@ func (this *Player) AddMessage(msg *model.Message) {
return
}
if len(msg.Channel) > 0 && !common.InSliceString(msg.Channel, this.LastChannel) {
return
}
if _, exist := this.msgs[msg.Id.Hex()]; !exist {
this.msgs[msg.Id.Hex()] = msg
@ -1036,7 +1042,7 @@ func (this *Player) SendIosInstallStableMail() {
var newMsg *model.Message
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
newMsg = model.NewMessage("", 0, "", this.SnId, model.MSGTYPE_IOSINSTALLSTABLE, "系统通知", fmt.Sprintf("感谢您下载稳定版本,额外奖励%d元请查收", int(model.GameParamData.IosStableInstallPrize/100)),
int64(model.GameParamData.IosStableInstallPrize), 0, 0, time.Now().Unix(), 0, "", nil, this.Platform, model.HallAll)
int64(model.GameParamData.IosStableInstallPrize), 0, 0, time.Now().Unix(), 0, "", nil, this.Platform, model.HallAll, nil)
return model.InsertMessage(this.Platform, newMsg)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
if data == nil {
@ -1055,7 +1061,7 @@ func (this *Player) TestMail() {
otherParams = append(otherParams, 20001, 3)
otherParams = append(otherParams, 20002, 3)
newMsg = model.NewMessage("", 0, "", this.SnId, model.MSGTYPE_ITEM, "系统通知道具test", "测试",
100000, 100, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, this.Platform, 0)
100000, 100, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, this.Platform, 0, nil)
return model.InsertMessage(this.Platform, newMsg)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
if data == nil {
@ -1075,7 +1081,7 @@ func (this *Player) TestSubMail() {
otherParams = append(otherParams, 20001, 3)
otherParams = append(otherParams, 20002, 3)
newMsg = model.NewMessage("", 0, "", 0, model.MSGTYPE_ITEM, "系统", "测试",
100000, 100, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, this.Platform, model.HallTienlen)
100000, 100, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, this.Platform, model.HallTienlen, nil)
return model.InsertMessage(this.Platform, newMsg)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
if data == nil {

View File

@ -84,7 +84,7 @@ func (this *PlayerRankSeason) sendEmailAward(rankType int32) {
content := i18n.Tr("languages", "RankAward")
newMsg = model.NewMessage("", 0, "", this.SnId, model.MSGTYPE_RANK_REWARD,
title, content, coin, diamond, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, this.Platform, model.HallTienlen)
title, content, coin, diamond, model.MSGSTATE_UNREAD, time.Now().Unix(), 0, "", otherParams, this.Platform, model.HallTienlen, nil)
return model.InsertMessage(this.Platform, newMsg)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {

View File

@ -3229,6 +3229,10 @@ func init() {
diamond := msg.GetDiamond()
otherParams := msg.GetParams()
showId := msg.GetShowId()
channel := msg.GetOnChannelName()
if destSnid > 0 {
channel = []string{}
}
if messageType == model.MSGTYPE_ITEM && len(otherParams) != 0 && len(otherParams)%2 != 0 {
pack.Tag = webapiproto.TagCode_FAILED
@ -3243,6 +3247,9 @@ func init() {
if p.IsRob == true { //排除掉机器人
continue
}
if len(channel) > 0 && !common.InSliceString(channel, p.LastChannel) { // 渠道过滤
continue
}
if platform == "" || p.Platform == platform {
onlinePlayerSnid = append(onlinePlayerSnid, p.SnId)
}
@ -3265,7 +3272,7 @@ func init() {
// var otherParams []int32
newMsg = model.NewMessage("", int32(srcSnid), "", int32(destSnid), int32(messageType), title, content, coin, diamond,
model.MSGSTATE_UNREAD, time.Now().Unix(), model.MSGATTACHSTATE_DEFAULT, "", otherParams, platform, showId)
model.MSGSTATE_UNREAD, time.Now().Unix(), model.MSGATTACHSTATE_DEFAULT, "", otherParams, platform, showId, channel)
if newMsg != nil {
err := model.InsertMessage(platform, newMsg)
if err != nil {
@ -3278,7 +3285,7 @@ func init() {
if destSnid == 0 {
for _, psnid := range onlinePlayerSnid {
newMsg := model.NewMessage(newMsg.Id.Hex(), newMsg.SrcId, "", psnid, newMsg.MType, newMsg.Title, newMsg.Content, newMsg.Coin, newMsg.Diamond,
newMsg.State, newMsg.CreatTs, newMsg.AttachState, newMsg.GiftId, otherParams, platform, newMsg.ShowId)
newMsg.State, newMsg.CreatTs, newMsg.AttachState, newMsg.GiftId, otherParams, platform, newMsg.ShowId, channel)
if newMsg != nil {
dbMsgs = append(dbMsgs, newMsg)
}