跨服调用获取特权接口处理

This commit is contained in:
meixiongfeng 2023-01-04 10:12:43 +08:00
parent 09fb6e67ed
commit 41e61dd3a5

View File

@ -9,6 +9,7 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"time"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
) )
@ -410,17 +411,34 @@ func (this *Privilege) SendDailyPrivilegeMail(session comm.IUserSession, cId []i
} }
} }
func (this *Privilege) GetCountByPrivilegeId(uid string, pId int32) (count int32) { func (this *Privilege) GetCountByPrivilegeId(uid string, pId int32) (count int32) {
vip, err := this.modelVip.getVipList(uid) if this.IsCross() { // 跨服情况
if err != nil { if model, err := this.GetDBModuleByUid(uid, comm.TableVip, time.Hour); err == nil {
return vip := &pb.DBVip{}
} if err = model.Get(uid, vip); err == nil {
if v, ok := vip.Privilege[pId]; ok { if v, ok := vip.Privilege[pId]; ok {
data := this.configure.GetPrivilegeByType(pId) data := this.configure.GetPrivilegeByType(pId)
for _, v1 := range v.PrivilegeID { for _, v1 := range v.PrivilegeID {
if c, ok1 := data[v1]; ok1 { if c, ok1 := data[v1]; ok1 {
count += c count += c
}
}
}
}
}
} else {
vip, err := this.modelVip.getVipList(uid)
if err != nil {
return
}
if v, ok := vip.Privilege[pId]; ok {
data := this.configure.GetPrivilegeByType(pId)
for _, v1 := range v.PrivilegeID {
if c, ok1 := data[v1]; ok1 {
count += c
}
} }
} }
} }
return return
} }