签到开启条件
This commit is contained in:
parent
660ccc107a
commit
2e9027c655
@ -33,6 +33,5 @@ func (this *ModuleSys) GetType() core.M_Modules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModuleSys) IsAccess(funcName string, userId string) (code pb.ErrorCode) {
|
func (this *ModuleSys) IsAccess(funcName string, userId string) (code pb.ErrorCode) {
|
||||||
// return this.modelSys.IsAccess(funcName, userId)
|
return this.modelSys.IsAccess(funcName, userId)
|
||||||
return pb.ErrorCode_Success
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.UserSignReq) (code
|
|||||||
update map[string]interface{}
|
update map[string]interface{}
|
||||||
bReward bool
|
bReward bool
|
||||||
)
|
)
|
||||||
|
if code = this.module.ModuleSys.IsAccess(comm.Sign, session.GetUserId()); code != pb.ErrorCode_Success {
|
||||||
|
return
|
||||||
|
}
|
||||||
update = make(map[string]interface{}, 0)
|
update = make(map[string]interface{}, 0)
|
||||||
if sign, err := this.module.modelSign.GetUserSign(session.GetUserId()); err == nil {
|
if sign, err := this.module.modelSign.GetUserSign(session.GetUserId()); err == nil {
|
||||||
start, _ := utils.GetMonthStartEnd()
|
start, _ := utils.GetMonthStartEnd()
|
||||||
|
@ -69,58 +69,3 @@ func (this *ModelSign) updateSignData(uid string, sign *pb.DBSign) (err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测是否达到重置日期
|
|
||||||
func (this *ModelSign) checkResetSignData(session comm.IUserSession) (code pb.ErrorCode) {
|
|
||||||
var (
|
|
||||||
update map[string]interface{}
|
|
||||||
bReward bool
|
|
||||||
)
|
|
||||||
|
|
||||||
update = make(map[string]interface{}, 0)
|
|
||||||
if sign, err := this.module.modelSign.GetUserSign(session.GetUserId()); err == nil {
|
|
||||||
start, _ := utils.GetMonthStartEnd()
|
|
||||||
if sign.RTime < start { // 重置
|
|
||||||
sign.RTime = configure.Now().Unix()
|
|
||||||
sign.SignTime = sign.RTime
|
|
||||||
sign.SignCount = 1
|
|
||||||
if newGroup := this.module.configure.GetSignResetConf(sign.Cid + 1); newGroup != -1 { // 获取当前的组id
|
|
||||||
sign.Cid += 1
|
|
||||||
sign.Group = newGroup
|
|
||||||
update["cid"] = sign.Cid
|
|
||||||
update["group"] = sign.Group
|
|
||||||
}
|
|
||||||
update["rTime"] = sign.RTime
|
|
||||||
update["signTime"] = sign.SignTime
|
|
||||||
update["signCount"] = sign.SignCount
|
|
||||||
this.Change(session.GetUserId(), update)
|
|
||||||
bReward = true
|
|
||||||
} else {
|
|
||||||
if !utils.IsToday(sign.SignTime) {
|
|
||||||
sign.SignCount += 1
|
|
||||||
update["signCount"] = sign.SignCount
|
|
||||||
sign.SignTime = configure.Now().Unix()
|
|
||||||
update["signTime"] = sign.SignTime
|
|
||||||
sign.RTime = sign.SignTime
|
|
||||||
update["rTime"] = sign.RTime
|
|
||||||
this.Change(session.GetUserId(), update)
|
|
||||||
bReward = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_data := this.module.configure.GetSignConf(sign.Cid, sign.Group)
|
|
||||||
if _data != nil { // 发奖
|
|
||||||
if bReward {
|
|
||||||
this.module.DispenseRes(session, _data.Loopgift, true)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if bReward {
|
|
||||||
this.module.DispenseRes(session, this.module.globalConf.UnifiedReward, true) // 发放通用奖励
|
|
||||||
}
|
|
||||||
}
|
|
||||||
session.SendMsg(string(this.module.GetType()), "sign", &pb.UserSignResp{
|
|
||||||
Data: sign,
|
|
||||||
Reward: bReward,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user