From f1b4b58460e3efac03a937d611fe01da7a13cb57 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 16 Dec 2022 14:32:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E5=A5=96=E5=8A=B1=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/privilege/module.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/privilege/module.go b/modules/privilege/module.go index 1f41b1a3d..87ac32772 100644 --- a/modules/privilege/module.go +++ b/modules/privilege/module.go @@ -226,7 +226,7 @@ func (this *Privilege) CheckPrivilege(session comm.IUserSession, cId string) boo // 检查特权 并发送每日邮件 func (this *Privilege) CheckDailyPrivilegeMail(session comm.IUserSession) { - privilgeList, err := this.modelVip.getVipList(session.GetUserId()) + vipList, err := this.modelVip.getVipList(session.GetUserId()) if err != nil { return } @@ -246,7 +246,7 @@ func (this *Privilege) CheckDailyPrivilegeMail(session comm.IUserSession) { data := this.configure.GetPrivilegeData(id) if data != nil { - if v, ok := privilgeList.Privilege[data.PrivilegeType]; ok { + if v, ok := vipList.Privilege[data.PrivilegeType]; ok { for i, v1 := range v.PrivilegeID { if v1 == id { @@ -257,7 +257,7 @@ func (this *Privilege) CheckDailyPrivilegeMail(session comm.IUserSession) { } } } - update["privilege"] = privilgeList.Privilege + update["privilege"] = vipList.Privilege this.modelVip.modifyVipData(session.GetUserId(), update) // 更新数据 } else { // 检查 每日奖励是否发放 @@ -273,13 +273,20 @@ func (this *Privilege) CheckDailyPrivilegeMail(session comm.IUserSession) { dt := configure.Now().Unix() - utils.GetZeroTime(v.RewardTime) count := dt / (24 * 3600) this.SendDailyMail(session, v.CId, int32(count+1), conf.PType) - // 找特权类型为1的 - listVip, err := this.modelVip.getVipList(session.GetUserId()) - if err == nil { - if v, ok := listVip.Privilege[comm.PrivilegeType1]; ok { - this.SendDailyPrivilegeMail(session, v.PrivilegeID) - } - } + + } + } + if !utils.IsToday(v.RewardTime) { + // 每日奖励 + if v, ok := vipList.Privilege[comm.PrivilegeType1]; ok { + this.SendDailyPrivilegeMail(session, v.PrivilegeID) + } + vipList.RewardTime = configure.Now().Unix() + if err = this.modelVip.Change(session.GetUserId(), map[string]interface{}{ + "rewardTime": v.RewardTime, + }); err != nil { + this.Errorf("err:%v", err) + return } } }