通过邮件id 批量发送邮件
This commit is contained in:
parent
30c284b222
commit
8452a0062b
@ -50,9 +50,10 @@ type (
|
||||
SendNewMail(mail *pb.DBMailData, uid ...string) bool // 批量发送邮件 支持跨服
|
||||
SendMailByUID(uid string, cid string, res []*cfg.Gameatn, Param []string) bool
|
||||
IGetReddot
|
||||
|
||||
// 所有邮件奖励统一调这个接口
|
||||
SendRewardMailByCid(session IUserSession, cid string, res []*cfg.Gameatn) bool
|
||||
// 批量发邮件结果: cid 邮件表ID, 没有附件 res 传空
|
||||
SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn) bool // 批量发送邮件 支持跨服
|
||||
}
|
||||
//道具背包接口
|
||||
IItems interface {
|
||||
|
@ -301,6 +301,7 @@ func (this *Mail) SendMailByUID(uid string, cid string, res []*cfg.Gameatn, Para
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *Mail) SendRewardMailByCid(session comm.IUserSession, cid string, res []*cfg.Gameatn) bool {
|
||||
var (
|
||||
resReward []*pb.UserAssets
|
||||
@ -328,7 +329,7 @@ func (this *Mail) SendRewardMailByCid(session comm.IUserSession, cid string, res
|
||||
ObjId: primitive.NewObjectID().Hex(),
|
||||
Uid: session.GetUserId(),
|
||||
CreateTime: uint64(configure.Now().Unix()),
|
||||
DueTime: uint64(configure.Now().Unix() + 30*24*3600),
|
||||
DueTime: uint64(configure.Now().Unix() + int64(conf.Duration)*3600),
|
||||
Items: resReward,
|
||||
Cid: cid,
|
||||
Param: []string{},
|
||||
@ -363,3 +364,78 @@ func (this *Mail) SendRewardMailByCid(session comm.IUserSession, cid string, res
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *Mail) SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn) bool {
|
||||
var (
|
||||
resReward []*pb.UserAssets
|
||||
)
|
||||
|
||||
// 获取额外配置
|
||||
conf := this.configure.GetMailConf(cid)
|
||||
if conf == nil {
|
||||
this.Errorf("can't found mail by cid: %s", cid)
|
||||
return false
|
||||
}
|
||||
if len(conf.Reword) > 0 {
|
||||
res = append(res, conf.Reword...)
|
||||
|
||||
}
|
||||
for _, v := range res {
|
||||
resReward = append(resReward, &pb.UserAssets{
|
||||
A: v.A,
|
||||
T: v.T,
|
||||
N: v.N,
|
||||
})
|
||||
}
|
||||
|
||||
if db.IsCross() {
|
||||
for _, id := range uids {
|
||||
if tag, _, b := utils.UIdSplit(id); b {
|
||||
if conn, err := db.ServerDBConn(tag); err == nil {
|
||||
// 构建一个每日奖励邮件对象
|
||||
mail := &pb.DBMailData{
|
||||
ObjId: primitive.NewObjectID().Hex(),
|
||||
Uid: id,
|
||||
CreateTime: uint64(configure.Now().Unix()),
|
||||
DueTime: uint64(configure.Now().Unix() + int64(conf.Duration)*3600),
|
||||
Items: resReward,
|
||||
Cid: cid,
|
||||
Param: []string{},
|
||||
}
|
||||
dbModel := db.NewDBModel(comm.TableMail, time.Hour, conn)
|
||||
mail.ObjId = primitive.NewObjectID().Hex()
|
||||
mail.Check = false
|
||||
mail.Reward = true
|
||||
|
||||
if len(mail.GetItems()) > 0 {
|
||||
mail.Reward = false
|
||||
}
|
||||
_, err = dbModel.DB.InsertOne(comm.TableMail, mail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for _, id := range uids {
|
||||
mail := &pb.DBMailData{
|
||||
ObjId: primitive.NewObjectID().Hex(),
|
||||
Uid: id,
|
||||
CreateTime: uint64(configure.Now().Unix()),
|
||||
DueTime: uint64(configure.Now().Unix() + int64(conf.Duration)*3600),
|
||||
Items: resReward,
|
||||
Cid: cid,
|
||||
Param: []string{},
|
||||
}
|
||||
mail.Uid = id
|
||||
mail.ObjId = primitive.NewObjectID().Hex()
|
||||
mail.Check = false
|
||||
mail.Reward = true
|
||||
|
||||
if len(mail.GetItems()) > 0 {
|
||||
mail.Reward = false
|
||||
}
|
||||
this.modelMail.DB.InsertOne(comm.TableMail, mail)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user