65 lines
1.3 KiB
Go
65 lines
1.3 KiB
Go
package mail
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
"time"
|
|
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/sys/cache"
|
|
"go_dreamfactory/sys/db"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
/*
|
|
模块名:Mail
|
|
描述:邮件系统模块
|
|
开发:梅雄风
|
|
*/
|
|
func NewModule() core.IModule {
|
|
m := new(Mail)
|
|
return m
|
|
}
|
|
|
|
type Mail struct {
|
|
modules.ModuleBase
|
|
api_comp *Api_Comp
|
|
configure_comp *Configure_Comp
|
|
}
|
|
|
|
func (this *Mail) GetType() core.M_Modules {
|
|
return comm.SM_MailModule
|
|
}
|
|
|
|
func (this *Mail) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
|
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
|
}
|
|
|
|
func (this *Mail) CreateNewMail(uId string) {
|
|
mail := &pb.DB_MailData{
|
|
ObjId: primitive.NewObjectID().Hex(),
|
|
UserId: uId,
|
|
Title: "系统邮件",
|
|
Contex: "恭喜获得专属礼包一份",
|
|
CreateTime: uint64(time.Now().Unix()),
|
|
DueTime: uint64(time.Now().Unix()) + 30*24*3600,
|
|
Check: false,
|
|
Reward: false,
|
|
}
|
|
err := db.Defsys.Mail_InsertUserMail(mail)
|
|
if err != nil {
|
|
log.Error("create mail failed")
|
|
}
|
|
// 通知玩家
|
|
_cache := cache.Defsys.Get(uId)
|
|
if _cache == nil {
|
|
return
|
|
}
|
|
this.SendMsgToUser("mail", "getnewEmailresp", mail, _cache)
|
|
}
|