批量发邮件
This commit is contained in:
parent
7204c77266
commit
77030e561d
@ -16,6 +16,7 @@ type (
|
||||
//邮件业务模块对外接口定义 提供给其他模块使用的
|
||||
Imail interface {
|
||||
CreateNewMail(session IUserSession, mail *pb.DBMailData) bool
|
||||
SendNewMail(mail *pb.DBMailData, uid ...string) bool // 批量发送邮件 支持跨服
|
||||
}
|
||||
//道具背包接口
|
||||
IItems interface {
|
||||
|
@ -83,3 +83,40 @@ func (this *Mail) AddNewMailPush(session comm.IUserSession, mail *pb.DBMailData)
|
||||
session.SendMsg(string(this.GetType()), "getnewmail", &pb.MailGetNewMailPush{Mail: mail})
|
||||
return
|
||||
}
|
||||
|
||||
// 给多个用户发邮件
|
||||
func (this *Mail) SendNewMail(mail *pb.DBMailData, uid ...string) bool {
|
||||
if db.IsCross() {
|
||||
for _, id := range uid {
|
||||
tag, _, b := utils.UIdSplit(id)
|
||||
if b {
|
||||
if conn, err := db.ServerDBConn(tag); err == nil {
|
||||
dbModel := db.NewDBModel(comm.TableMail, time.Hour, conn)
|
||||
mail.ObjId = primitive.NewObjectID().Hex()
|
||||
mail.Check = false
|
||||
mail.Reward = false
|
||||
|
||||
if len(mail.GetItems()) > 0 {
|
||||
mail.Reward = false
|
||||
}
|
||||
_, err = dbModel.DB.InsertOne(comm.TableMail, mail)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, id := range uid {
|
||||
mail.Uid = id
|
||||
mail.ObjId = primitive.NewObjectID().Hex()
|
||||
mail.Check = false
|
||||
mail.Reward = false
|
||||
|
||||
if len(mail.GetItems()) > 0 {
|
||||
mail.Reward = false
|
||||
}
|
||||
this.modelMail.DB.InsertOne(comm.TableMail, mail)
|
||||
}
|
||||
}
|
||||
mail.Uid = ""
|
||||
this.SendMsgToUsers(string(this.GetType()), "getnewmail", &pb.MailGetNewMailPush{Mail: mail}, uid...)
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user