This commit is contained in:
liwei1dao 2023-12-29 21:37:05 +08:00
commit d6c4305643
9 changed files with 174 additions and 97 deletions

View File

@ -33,6 +33,11 @@ type (
IPayDelivery interface {
Delivery(session IUserSession, pId int32) (errdata *pb.ErrorData, items []*pb.UserAtno)
}
// 修改玩家基本数据
IUpdateUserBaseInfo interface {
UpdateUserBaseInfo(session IUserSession, info *pb.BaseUserInfo) (err error)
}
)
/*
@ -274,6 +279,7 @@ type (
QiecuoFinishNotify(redUid, matchId string) error
// 红点
IGetReddot
IUpdateUserBaseInfo
}
//聊天系统

View File

@ -48,9 +48,9 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA
}
}
leftCount = int32(comm.AssistHeroCount - len(list.Data))
localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{})
randomIndex := comm.GetRandNum(0, int32(localNum))
cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(randomIndex)).SetLimit(int64(leftCount))) //.skip(1).limit(1)
// localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{})
// randomIndex := comm.GetRandNum(0, int32(localNum))
cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1)
for cur.Next(context.TODO()) {
tmp := &pb.DBFriend{}
if err = cur.Decode(tmp); err == nil {
@ -75,6 +75,23 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA
return
}
if len(list.Data) == 0 { // 异常处理
leftCount = int32(comm.AssistHeroCount - len(list.Data))
// localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{})
// randomIndex := comm.GetRandNum(0, int32(localNum))
cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1)
for cur.Next(context.TODO()) {
tmp := &pb.DBFriend{}
if err = cur.Decode(tmp); err == nil {
list.Data[tmp.Uid] = tmp.Info.Name
heros = append(heros, tmp.Hero)
}
}
err = this.module.modelAssist.modifyAssistData(session.GetUserId(), map[string]interface{}{
"data": list.Data,
})
} else {
for k := range list.Data {
uids = append(uids, k)
}
@ -90,6 +107,8 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA
for _, v := range friends {
heros = append(heros, v.Hero)
}
}
session.SendMsg(string(this.module.GetType()), "getassisthero", &pb.FriendGetAssistHeroResp{
Data: list,
Hero: heros,

View File

@ -6,10 +6,12 @@ package friend
import (
"context"
"errors"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/sys/db"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
@ -252,3 +254,31 @@ func (this *Friend) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r
return
}
func (this *Friend) UpdateUserBaseInfo(session comm.IUserSession, info *pb.BaseUserInfo) (err error) {
if db.IsCross() {
err = this.modelFriend.Change(session.GetUserId(), map[string]interface{}{
"info": info,
})
} else {
var (
model *db.DBModel
conn_ *db.DBConn
)
// 跨服
conn_, err = db.Cross() // 获取跨服数据库对象
if err != nil {
return
}
if model = db.NewDBModelByExpired(comm.TableFriend, conn_); model == nil {
err = fmt.Errorf("cand found table :%s,%v", comm.TableFriend, conn_)
return
}
err = model.Change(session.GetUserId(), map[string]interface{}{
"info": info,
})
}
return
}

View File

@ -171,8 +171,11 @@ func (this *ModuleSys) GMOpenAllCondition(uid string) {
return
}
for _, v := range opencfg.GetDataList() {
if v.ActivateType != 1 { // 跳过手动激活类型
list.Cond[v.Id] = 2
}
}
this.modelSys.ChangeOpenCondData(uid, map[string]interface{}{
"cond": list.Cond,
})

View File

@ -53,7 +53,7 @@ func (this *Activity) Start() (err error) {
return
}
timer := time.NewTicker(time.Second * 1)
this.LoadActivityData("")
this.LoadActivityData()
go func() {
locp:
@ -70,43 +70,7 @@ func (this *Activity) Start() (err error) {
//cron.AddFunc("0 0 0 ? * MON", this.TimerSeason)
return
}
func (this *Activity) LoadActivityData(id string) {
if id == "" { // 查所有的
if c, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err == nil {
var (
szEnd []string // 活动结束
szStart []string // 有活动开启
)
this.hlock.Lock()
this.curActivity = make(map[pb.HdType]*pb.DBHuodong)
this.delActivity = make(map[pb.HdType]*pb.DBHuodong)
this.futureActivity = make(map[pb.HdType]*pb.DBHuodong)
defer this.hlock.Unlock()
for c.Next(context.Background()) {
hd := &pb.DBHuodong{}
if err = c.Decode(hd); err != nil {
this.module.Errorf("err:%v", err)
continue
}
if hd.Etime <= configure.Now().Unix() {
this.delActivity[hd.Itype] = hd
szEnd = append(szEnd, hd.Id)
} else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() {
this.curActivity[hd.Itype] = hd
szStart = append(szStart, hd.Id)
} else {
this.futureActivity[hd.Itype] = hd
}
}
if len(szEnd) > 0 {
this.NotifyActivityOver(szEnd)
}
if len(szStart) > 0 {
this.NotifyActivityStart(szStart)
}
}
} else {
func (this *Activity) ReLoadActivityData(id string) {
var hd *pb.DBHuodong
if err := this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(&hd); err != nil {
return
@ -135,7 +99,34 @@ func (this *Activity) LoadActivityData(id string) {
this.futureActivity[hd.Itype] = hd
}
defer this.hlock.Unlock()
}
func (this *Activity) LoadActivityData() {
if c, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err == nil {
this.hlock.Lock()
this.curActivity = make(map[pb.HdType]*pb.DBHuodong)
this.delActivity = make(map[pb.HdType]*pb.DBHuodong)
this.futureActivity = make(map[pb.HdType]*pb.DBHuodong)
defer this.hlock.Unlock()
for c.Next(context.Background()) {
hd := &pb.DBHuodong{}
if err = c.Decode(hd); err != nil {
this.module.Errorf("err:%v", err)
continue
}
if hd.Etime <= configure.Now().Unix() {
this.delActivity[hd.Itype] = hd
} else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() {
this.curActivity[hd.Itype] = hd
} else {
this.futureActivity[hd.Itype] = hd
}
}
}
}
func (this *Activity) NotifyActivityOver(szEnd []string) {
@ -167,6 +158,7 @@ func (this *Activity) NotifyActivityStart(szStart []string) {
this.module.Errorln(err)
}
}
func (this *Activity) CheckActivityData() {
var (
szEnd []string // 活动结束

View File

@ -101,7 +101,7 @@ func (this *Timer) getDBModelByUid(uid, tableName string) (model *db.DBModel, er
// 重新加载活动数据
func (this *Timer) ReloadActivityData(id string) {
this.activity.LoadActivityData(id)
this.activity.ReLoadActivityData(id)
}
// 日志

View File

@ -2,6 +2,7 @@ package user
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
@ -92,6 +93,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
update["avatar"] = globalConf.GirlHeadPortrait
}
user.Gender = req.Gender
user.Name = req.NickName
user.CurSkin = req.Skin
user.Gender = req.Gender
session.SetMate(comm.Session_User, user)
if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil {
errdata = &pb.ErrorData{
@ -124,7 +128,27 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e
//异步逻辑
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
baseInfo := &pb.BaseUserInfo{
Uid: user.Uid,
Sid: user.Sid,
Name: user.Name,
Gender: user.Gender,
Skin: user.CurSkin,
Aframe: user.Curaframe,
Title: user.Curtitle,
Lv: user.Lv,
}
for _, m := range this.module.notifyUserinfo {
i, err := this.service.GetModule(core.M_Modules(m))
if err != nil {
this.module.Errorln(err)
continue
}
if ic, ok := i.(comm.IUpdateUserBaseInfo); ok {
ic.UpdateUserBaseInfo(session, baseInfo)
}
}
this.mail.SendMailByCid(session, comm.Welcomemail, nil)
if len(tasks) > 0 {
this.module.ModuleBuried.TriggerBuried(session, tasks...)

View File

@ -65,6 +65,7 @@ type User struct {
timerLock sync.Mutex
timerMap map[string]*time.Ticker
reddot comm.IReddot
notifyUserinfo []string // userinfo change
}
func (this *User) GetType() core.M_Modules {
@ -107,6 +108,7 @@ func (this *User) Start() (err error) {
return
}
this.reddot = module.(comm.IReddot)
this.notifyUserinfo = append(this.notifyUserinfo, string(comm.ModuleFriend)) // 只要涉及到更新userinof 信息的模块在此注册
return
}

View File

@ -248,6 +248,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype237, consumPs))
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype201, consumPs))
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype76, 1, req.BossId))
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype77, 1, req.BossId, req.Difficulty))
if bHelp {
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype180, req.BossId, 1))
}