Commit b8799a6a authored by chenweijian's avatar chenweijian

贵族6

parent 9f1274ec
......@@ -4,8 +4,11 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/cv/group_power_cv"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/noble_m"
)
type GroupPowerService struct {
......@@ -66,3 +69,27 @@ func (s *GroupPowerService) GroupPowerUserLeave(groupPowerId mysql.ID, userId my
})
return remainSeconds, err
}
func GetGroupPowerMaxMemberNum(model *domain.Model, familyId uint64, groupPowerGrade groupPower_e.GroupPowerGrade) (maxNum int) {
maxNum = group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade][0].Num
ownerId, err := groupPower_m.GetPowerOwner(model.Db, familyId)
if err == nil {
//检查是否是贵族
if flag, err := noble_m.CheckNobleLevel(model.Db, ownerId, 6); err != nil {
} else if flag {
newNumMap := map[groupPower_e.GroupPowerGrade]int{1: 400, 2: 600, 3: 1000, 4: 1400}
if newNum, ok := newNumMap[groupPowerGrade]; ok {
maxNum = newNum
}
}
}
users, err := groupPower_m.GetGroupPowerUser(model, familyId)
if err != nil {
return
}
memberNum := len(users)
if memberNum > maxNum {
maxNum = memberNum
}
return
}
......@@ -774,10 +774,11 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
if grade.Grade != groupPower_e.GroupPowerGradeMax {
nextExp = groupPower_e.GroupPowerGradeExp[grade.Grade+1]
}
maxNum := group_power_s.GetGroupPowerMaxMemberNum(model, gpInfo.ID, grade.Grade)
info := &group_power_cv.GroupPower{
Id: gpInfo.ID, Name: gpInfo.Name, Nameplate: gpInfo.Nameplate, Declaration: gpInfo.Declaration, Icon: gpInfo.Icon,
Grade: grade.Grade, Exp: grade.Exp, NextExp: nextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal,
MemberNum: mysql.Num(total), MemberMax: mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[grade.Grade][0].Num),
MemberNum: mysql.Num(total), MemberMax: mysql.Num(maxNum),
}
if info.Icon != "" {
info.Icon = common.MakeFullUrl(info.Icon)
......@@ -1007,7 +1008,8 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
if err != nil {
return myContext, myerr.WrapErr(err)
}
maxNum := group_power_cv.GroupPowerGradePrivilegeNum[gpInfo.Grade][0].Num
maxNum := group_power_s.GetGroupPowerMaxMemberNum(model, familyId, gpInfo.Grade)
//maxNum := group_power_cv.GroupPowerGradePrivilegeNum[gpInfo.Grade][0].Num
if nowNum+1 > int64(maxNum) {
return myContext, bizerr.GroupPowerMemberMax
}
......@@ -1109,7 +1111,8 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, err
}
grade := gradeM[apply.GroupPowerId]
maxNum := group_power_cv.GroupPowerGradePrivilegeNum[grade.Grade][0].Num
//maxNum := group_power_cv.GroupPowerGradePrivilegeNum[grade.Grade][0].Num
maxNum := group_power_s.GetGroupPowerMaxMemberNum(model, apply.GroupPowerId, grade.Grade)
if int(nowNum+1) > maxNum {
return myContext, bizerr.GroupPowerMemberMax
}
......@@ -1597,10 +1600,11 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
if grade.Grade != groupPower_e.GroupPowerGradeMax {
nextExp = groupPower_e.GroupPowerGradeExp[grade.Grade+1]
}
maxNum := group_power_s.GetGroupPowerMaxMemberNum(model, gpInfo.ID, grade.Grade)
info := &group_power_cv.GroupPower{
Id: gpInfo.ID, Name: gpInfo.Name, Nameplate: gpInfo.Nameplate, Declaration: gpInfo.Declaration, Icon: gpInfo.Icon,
Grade: grade.Grade, Exp: grade.Exp, NextExp: nextExp, GradeName: gpInfo.GradeName, GradeMedal: gpInfo.GradeMedal,
MemberNum: mysql.Num(total), MemberMax: mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[gp.ID].Grade][0].Num),
MemberNum: mysql.Num(total), MemberMax: mysql.Num(maxNum),
}
if info.Icon != "" {
info.Icon = common.MakeFullUrl(info.Icon)
......
......@@ -11,6 +11,7 @@ import (
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/msg_m"
"hilo-group/domain/model/user_m"
"hilo-group/domain/service/group_power_s"
"hilo-group/resp"
)
......@@ -48,7 +49,8 @@ func MGetGroupPowers(c *gin.Context) (*mycontext.MyContext, error) {
var memberMax mysql.Num
grade := groupPowerGrade[groupPowerId].Grade
if grade >= groupPower_e.GroupPowerGrade0 && grade <= groupPower_e.GroupPowerGradeMax {
memberMax = mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[groupPowerId].Grade][0].Num)
//memberMax = mysql.Num(group_power_cv.GroupPowerGradePrivilegeNum[groupPowerGrade[groupPowerId].Grade][0].Num)
memberMax = mysql.Num(group_power_s.GetGroupPowerMaxMemberNum(model, groupPowerId, grade))
}
memberNum := mysql.Num(len(groupPowerUsers[groupPowerId]))
if memberNum > memberMax {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment