From eafd411344e00bdc167d65cb2d7acef7de0d65ee Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 18 Dec 2024 23:26:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_home_page.go | 77 ++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/app/hdl/hdl_home_page.go b/app/hdl/hdl_home_page.go index d7c991f..b81f193 100644 --- a/app/hdl/hdl_home_page.go +++ b/app/hdl/hdl_home_page.go @@ -379,53 +379,48 @@ func IsCanSignIn(c *gin.Context) { } now := time.Now() - cacheKey := fmt.Sprintf("IsCanSignIn:%d", user.Id) - var isCan bool - if cache.Exists(cacheKey) { + var isCan = false + signInDb := implement.NewEggSignInDb(db.Db) + nowStr := now.Format("2006-01-02 15:04:05") + has, _, err := signInDb.EggSignINGetOneByTimeAndUid("", nowStr, user.Id, 0) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if has { isCan = false } else { - signInDb := implement.NewEggSignInDb(db.Db) - nowStr := now.Format("2006-01-02 15:04:05") - has, _, err := signInDb.EggSignINGetOneByTimeAndUid("", nowStr, user.Id, 0) + //1、查找 `OneCirclesPublicPlatoonBasicSetting` 基础设置 + energyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db) + eggEnergyBasicSetting, err := energyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{ + "key": "is_open", + "value": 1, + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + var videoRewardSystem *md2.VideoRewardSystemStruct + err = json.Unmarshal([]byte(eggEnergyBasicSetting.VideoRewardSystem), &videoRewardSystem) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + rewardTotalNum := utils.StrToInt(videoRewardSystem.RewardTotalNum) + + //2、查询当前用户观看视屏记录 + watchRecordsDb := implement.NewEggEnergyUserWatchRecordsDb(db.Db) + userWatchRecords, err := watchRecordsDb.EggEnergyUserWatchRecordsGetOneByParams(map[string]interface{}{ + "key": "uid", + "value": user.Id, + }) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } - if has { - isCan = false - } else { - //1、查找 `OneCirclesPublicPlatoonBasicSetting` 基础设置 - energyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db) - eggEnergyBasicSetting, err := energyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{ - "key": "is_open", - "value": 1, - }) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - var videoRewardSystem *md2.VideoRewardSystemStruct - err = json.Unmarshal([]byte(eggEnergyBasicSetting.VideoRewardSystem), &videoRewardSystem) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - rewardTotalNum := utils.StrToInt(videoRewardSystem.RewardTotalNum) - - //2、查询当前用户观看视屏记录 - watchRecordsDb := implement.NewEggEnergyUserWatchRecordsDb(db.Db) - userWatchRecords, err := watchRecordsDb.EggEnergyUserWatchRecordsGetOneByParams(map[string]interface{}{ - "key": "uid", - "value": user.Id, - }) - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - if userWatchRecords != nil && userWatchRecords.ResidueWatchAdNum == rewardTotalNum && userWatchRecords.NextWatchAdDate.After(now) { - isCan = true - } + if userWatchRecords != nil && userWatchRecords.ResidueWatchAdNum == rewardTotalNum && userWatchRecords.NextWatchAdDate.After(now) { + isCan = true } } @@ -438,8 +433,6 @@ func IsCanSignIn(c *gin.Context) { resp := md.IsCanSignInResp{ IsCan: isCan, } - - cache.SetEx(cacheKey, "run", 30) e.OutSuc(c, resp, nil) return }