特权类型定义 登录补发奖励
This commit is contained in:
parent
67385797e5
commit
11fd4ceb56
@ -645,3 +645,17 @@ const (
|
||||
Arena = "arena"
|
||||
Sign = "sign"
|
||||
)
|
||||
|
||||
// 特权类型
|
||||
const (
|
||||
PrivilegeType1 = iota + 1 //每日获得
|
||||
PrivilegeType2 //金币商店每日免费刷新次数
|
||||
PrivilegeType3 //维京远征每日可购买挑战次数
|
||||
PrivilegeType4 //狩猎每日可购买挑战次数
|
||||
PrivilegeType5 //竞技场每日可购买挑战次数
|
||||
PrivilegeType6 //梦境每日可购买挑战次数
|
||||
PrivilegeType7 //巨怪商队背包容量
|
||||
PrivilegeType8 //美食馆每日最大制作时间
|
||||
PrivilegeType9 //武馆每日最大练功时间
|
||||
PrivilegeType10 //铁匠铺每日最大锻造时间
|
||||
)
|
||||
|
@ -281,10 +281,10 @@ type (
|
||||
RenewPrivilegeCard(session IUserSession, cId string) (code pb.ErrorCode)
|
||||
// 检查特权
|
||||
CheckPrivilege(session IUserSession, cId string) (privilege *pb.DBPrivilege)
|
||||
// 查询玩家当前所有特权 返回特权id
|
||||
QueryPrivilege(session IUserSession) (privilegeID []int32)
|
||||
// 检查每日特权邮件
|
||||
CheckDailyPrivilegeMail(session IUserSession)
|
||||
// 获得vip
|
||||
AddVipData(session IUserSession)
|
||||
AddVipData(session IUserSession, oldVip, newVip int32)
|
||||
}
|
||||
//武馆
|
||||
IMartialhall interface {
|
||||
|
@ -51,22 +51,3 @@ func (this *ModelVip) getVipList(uid string) (vip *pb.DBVip, err error) {
|
||||
func (this *ModelVip) modifyVipData(uid string, data map[string]interface{}) error {
|
||||
return this.Change(uid, data)
|
||||
}
|
||||
|
||||
// 增加vip信息
|
||||
func (this *ModelVip) addVipData(uId string) (vip *pb.DBVip, err error) {
|
||||
|
||||
vip, err = this.getVipList(uId)
|
||||
if err != nil {
|
||||
return vip, err
|
||||
}
|
||||
if vip.Id == "" {
|
||||
vip.Id = primitive.NewObjectID().Hex()
|
||||
vip.CTime = configure.Now().Unix()
|
||||
if err = this.Add(uId, vip); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -206,8 +206,8 @@ func (this *Privilege) CheckPrivilege(session comm.IUserSession, cId string) (pr
|
||||
return
|
||||
}
|
||||
|
||||
// 查询特权信息,把过期的特权清除掉
|
||||
func (this *Privilege) QueryPrivilege(session comm.IUserSession) (privilegeID []int32) {
|
||||
// 检查特权 并发送每日邮件
|
||||
func (this *Privilege) CheckDailyPrivilegeMail(session comm.IUserSession) {
|
||||
privilgeList, err := this.modelVip.getVipList(session.GetUserId())
|
||||
if err != nil {
|
||||
return
|
||||
@ -219,7 +219,7 @@ func (this *Privilege) QueryPrivilege(session comm.IUserSession) (privilegeID []
|
||||
for _, v := range list {
|
||||
conf, err := this.configure.GetPrivilegeCard(v.CId)
|
||||
if err != nil {
|
||||
return nil
|
||||
return
|
||||
}
|
||||
if v.ETime < configure.Now().Unix() { // 判断当前特权是否过期
|
||||
|
||||
@ -302,8 +302,35 @@ func (this *Privilege) SendDailyMail(session comm.IUserSession, cId string, coun
|
||||
}
|
||||
|
||||
}
|
||||
func (this *Privilege) AddVipData(session comm.IUserSession) {
|
||||
vip, err := this.modelVip.addVipData(session.GetUserId())
|
||||
func (this *Privilege) AddVipData(session comm.IUserSession, oldVip, newVip int32) {
|
||||
if newVip <= oldVip {
|
||||
return
|
||||
}
|
||||
vip, err := this.modelVip.getVipList(session.GetUserId())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
update := map[string]interface{}{}
|
||||
for i := oldVip; i < newVip; i++ {
|
||||
conf := this.configure.GetVipConfigureData(i)
|
||||
if conf != nil {
|
||||
for _, v := range conf.VipPrivilege {
|
||||
data := this.configure.GetPrivilegeData(v)
|
||||
if data != nil {
|
||||
|
||||
if _, ok := vip.Privilege[data.PrivilegeType]; ok {
|
||||
vip.Privilege[data.PrivilegeType].PrivilegeID = append(vip.Privilege[data.PrivilegeType].PrivilegeID, v)
|
||||
} else {
|
||||
sz := &pb.PrivilegeData{}
|
||||
sz.PrivilegeID = append(sz.PrivilegeID, v)
|
||||
vip.Privilege[data.PrivilegeType] = sz
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
update["privilege"] = vip.Privilege
|
||||
this.modelVip.modifyVipData(session.GetUserId(), update)
|
||||
if err != nil { // 推送
|
||||
session.SendMsg(string(this.GetType()), PrivilegeGetListResp, &pb.PrivilegeVipListResp{Data: vip})
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype7, 1)
|
||||
|
||||
// 检查特权 并发送每日邮件
|
||||
this.module.ModulePrivilege.QueryPrivilege(session)
|
||||
this.module.ModulePrivilege.CheckDailyPrivilegeMail(session)
|
||||
//推送登录公告
|
||||
if this.module.modelUser.isLoginFirst(lastLoginTime) {
|
||||
this.chat.SendSysChatToUser(session, comm.ChatSystem2, 0, 0)
|
||||
|
@ -206,8 +206,8 @@ func (this *ModelUser) ChangeVipExp(event interface{}, next func(event interface
|
||||
}
|
||||
}
|
||||
//
|
||||
if ul.viplv == 0 && vipLv > 0 { // 新获得了vip
|
||||
this.module.ModulePrivilege.AddVipData(ul.session)
|
||||
if ul.viplv != vipLv { // 新获得了vip
|
||||
this.module.ModulePrivilege.AddVipData(ul.session, ul.viplv, vipLv)
|
||||
}
|
||||
// 推送玩家vip 经验变化
|
||||
ul.session.SendMsg(string(this.module.GetType()), UserSubTypeVipChangedPush,
|
||||
|
Loading…
Reference in New Issue
Block a user