diff --git a/comm/const.go b/comm/const.go index 3f52107d6..049662455 100644 --- a/comm/const.go +++ b/comm/const.go @@ -669,16 +669,15 @@ const ( Sign = "sign" ) -// 特权类型 const ( - PrivilegeType1 int32 = iota + 1 //每日获得 - PrivilegeType2 //金币商店每日免费刷新次数 - PrivilegeType3 //维京远征每日可购买挑战次数 - PrivilegeType4 //狩猎每日可购买挑战次数 - PrivilegeType5 //竞技场每日可购买挑战次数 - PrivilegeType6 //梦境每日可购买挑战次数 - PrivilegeType7 //巨怪商队背包容量 - PrivilegeType8 //美食馆每日最大制作时间 - PrivilegeType9 //武馆每日最大练功时间 - PrivilegeType10 //铁匠铺每日最大锻造时间 + PrivilegeType1 = iota + 1 //每日获得 + PrivilegeType2 //金币商店每日免费刷新次数 + PrivilegeType3 //维京远征每日可购买挑战次数 + PrivilegeType4 //狩猎每日可购买挑战次数 + PrivilegeType5 //竞技场每日可购买挑战次数 + PrivilegeType6 //梦境每日可购买挑战次数 + PrivilegeType7 //巨怪商队背包容量 + PrivilegeType8 //美食馆每日最大制作时间 + PrivilegeType9 //武馆每日最大练功时间 + PrivilegeType10 //铁匠铺每日最大锻造时间 ) diff --git a/comm/imodule.go b/comm/imodule.go index f66976a3e..a574be6d7 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -306,7 +306,8 @@ type ( // 查询所有特权 key 对应comm.PrivilegeType1类型 CheckAllPrivilege(session IUserSession) map[int32]*pb.PrivilegeList // 通过特权类型获取特权对应的增加数量 - GetCountByPrivilegeId(uid string, pId int32) (count int32) + + GetCountByPrivilegeId(uid string, pType int32) (count int32) } //武馆 IMartialhall interface { diff --git a/modules/privilege/module.go b/modules/privilege/module.go index f693a0dfe..8248e3c31 100644 --- a/modules/privilege/module.go +++ b/modules/privilege/module.go @@ -410,13 +410,13 @@ func (this *Privilege) SendDailyPrivilegeMail(session comm.IUserSession, cId []i this.mail.SendMailByCid(session, comm.VipDaily, res) } } -func (this *Privilege) GetCountByPrivilegeId(uid string, pId int32) (count int32) { +func (this *Privilege) GetCountByPrivilegeId(uid string, pType int32) (count int32) { if this.IsCross() { // 跨服情况 if model, err := this.GetDBModuleByUid(uid, comm.TableVip, time.Hour); err == nil { vip := &pb.DBVip{} if err = model.Get(uid, vip); err == nil { - if v, ok := vip.Privilege[pId]; ok { - data := this.configure.GetPrivilegeByType(pId) + if v, ok := vip.Privilege[pType]; ok { + data := this.configure.GetPrivilegeByType(pType) for _, v1 := range v.PrivilegeID { if c, ok1 := data[v1]; ok1 { count += c @@ -426,19 +426,16 @@ func (this *Privilege) GetCountByPrivilegeId(uid string, pId int32) (count int32 } } } 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 + if vip, err := this.modelVip.getVipList(uid); err == nil { + if v, ok := vip.Privilege[pType]; ok { + data := this.configure.GetPrivilegeByType(pType) + for _, v1 := range v.PrivilegeID { + if c, ok1 := data[v1]; ok1 { + count += c + } } } } } - return }