diff --git a/modules/mail/module.go b/modules/mail/module.go index edb5390a9..6bc778c8f 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -4,10 +4,14 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/db" + "go_dreamfactory/utils" "time" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" + + "go.mongodb.org/mongo-driver/bson/primitive" ) /* @@ -38,16 +42,6 @@ func (this *Mail) OnInstallComp() { this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp) } -// mail := &pb.DBMailData{ -// ObjId: primitive.NewObjectID().Hex(), -// Uid: uId, -// Title: "系统邮件", -// Contex: "恭喜获得专属礼包一份", -// CreateTime: uint64(time.Now().Unix()), -// DueTime: uint64(time.Now().Unix()) + 30*24*3600, // 30天需要走配置文件 -// Check: false, -// Reward: false, -// } func (this *Mail) CreateNewMail(session comm.IUserSession, mail *pb.DBMailData) bool { t := time.Now() defer func() { @@ -56,10 +50,27 @@ func (this *Mail) CreateNewMail(session comm.IUserSession, mail *pb.DBMailData) if mail == nil { return false } - err := this.modelMail.MailInsertUserMail(mail) - if err != nil { - this.Errorf("create mail failed :%v", err) - return false + if db.IsCross() { // 如果是跨服 则取本服的db + tag, _, b := utils.UIdSplit(session.GetUserId()) + 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 { + err := this.modelMail.MailInsertUserMail(mail) + if err != nil { + this.Errorf("create mail failed :%v", err) + return false + } } // 通知玩家 this.AddNewMailPush(session, mail) diff --git a/modules/pagoda/api_getlist.go b/modules/pagoda/api_getlist.go index bc852f809..1009e57b0 100644 --- a/modules/pagoda/api_getlist.go +++ b/modules/pagoda/api_getlist.go @@ -21,6 +21,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq var ( list *pb.DBPagoda ) + this.GetListCheck(session, req) expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId()) if err != nil { code = pb.ErrorCode_DBError diff --git a/modules/pagoda/pagoda_test.go b/modules/pagoda/pagoda_test.go index 9a8f6b8ef..9dfc86751 100644 --- a/modules/pagoda/pagoda_test.go +++ b/modules/pagoda/pagoda_test.go @@ -89,5 +89,34 @@ func Test_Modules(t *testing.T) { } func TestXxx(t *testing.T) { + // if !this.module.IsCross() { + // if conn, err := db.Cross(); err == nil { + // userinfo := this.module.ModuleUser.GetUser(session.GetUserId()) + // newData := &pb.DBPagodaRecord{ + // Id: primitive.NewObjectID().Hex(), + // Uid: session.GetUserId(), + // PagodaId: 100, + // Type: 201, + // Nickname: userinfo.Name, + // Icon: "", // icon 暂无 + // Lv: userinfo.Lv, + // CostTime: 1001, + // } + // menbers := make([]*redis.Z, 2) + // menbers[0] = &redis.Z{Score: float64(123), Member: "dfmxf_001"} + // menbers[1] = &redis.Z{Score: float64(13), Member: "dfmxf_002"} + // pipe := conn.Redis.RedisPipe(context.TODO()) + // if cmd := pipe.ZAdd("ranklist", menbers...); err != nil { + // this.module.Errorln(err) + // } else { + // if _, err = cmd.Result(); err != nil { + // this.module.Errorln(err) + // return + // } + // } + + // conn.Mgo.InsertOne(comm.TablePagodaRecord, newData) + // } + // } }