From 8452a0062b10fe286eee47c591f42deed224cb00 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 18 Jul 2023 17:19:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=80=9A=E8=BF=87=E9=82=AE=E4=BB=B6id=20?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 3 +- modules/mail/module.go | 78 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 2b9036861..51c90588b 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -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 { diff --git a/modules/mail/module.go b/modules/mail/module.go index 7596c9d34..2d13a2802 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -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 +} From 23b0a66fd505ee62e792504d8654ca2e1aae3828 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 18 Jul 2023 17:23:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=89=A9=E5=B1=95=20=E6=96=B0=E5=A2=9E=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 +- modules/mail/module.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 51c90588b..9d9cb7c1a 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -53,7 +53,7 @@ type ( // 所有邮件奖励统一调这个接口 SendRewardMailByCid(session IUserSession, cid string, res []*cfg.Gameatn) bool // 批量发邮件结果: cid 邮件表ID, 没有附件 res 传空 - SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn) bool // 批量发送邮件 支持跨服 + SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn, param []string) bool // 批量发送邮件 支持跨服 } //道具背包接口 IItems interface { diff --git a/modules/mail/module.go b/modules/mail/module.go index 2d13a2802..af40a615d 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -365,7 +365,7 @@ func (this *Mail) SendRewardMailByCid(session comm.IUserSession, cid string, res return true } -func (this *Mail) SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn) bool { +func (this *Mail) SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn, param []string) bool { var ( resReward []*pb.UserAssets ) @@ -400,7 +400,7 @@ func (this *Mail) SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn) DueTime: uint64(configure.Now().Unix() + int64(conf.Duration)*3600), Items: resReward, Cid: cid, - Param: []string{}, + Param: param, } dbModel := db.NewDBModel(comm.TableMail, time.Hour, conn) mail.ObjId = primitive.NewObjectID().Hex() @@ -424,7 +424,7 @@ func (this *Mail) SendMailToUsers(uids []string, cid string, res []*cfg.Gameatn) DueTime: uint64(configure.Now().Unix() + int64(conf.Duration)*3600), Items: resReward, Cid: cid, - Param: []string{}, + Param: param, } mail.Uid = id mail.ObjId = primitive.NewObjectID().Hex() From b81c5a7a747c62127bc30cbe6ec3b951f4934224 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 18 Jul 2023 17:28:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E7=AD=89=E7=BA=A7=E7=9A=84=E8=8B=B1=E9=9B=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/module.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/hero/module.go b/modules/hero/module.go index 0ac2c5d5a..b4e7c279d 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -1035,6 +1035,12 @@ func (this *Hero) PassonHero(session comm.IUserSession, heroObjID map[string]boo return } +// 构建一个虚拟等级的英雄 func (this *Hero) GetVirtualHero(hero *pb.DBHero, lv int32) (vHero *pb.DBHero) { + if vHero == nil || lv <= 0 { + return nil + } + hero.Lv = lv + this.modelHero.PropertyCompute(hero) return hero }