dengbiao пре 5 дана
родитељ
комит
6b24a3d780
1 измењених фајлова са 50 додато и 32 уклоњено
  1. +50
    -32
      app/hdl/hdl_home_page.go

+ 50
- 32
app/hdl/hdl_home_page.go Прегледај датотеку

@@ -379,39 +379,55 @@ func IsCanSignIn(c *gin.Context) {
return
}

//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
}

var isCan bool
now := time.Now()
if userWatchRecords != nil && userWatchRecords.ResidueWatchAdNum == rewardTotalNum && userWatchRecords.NextWatchAdDate.After(now) {
isCan = true
cacheKey := fmt.Sprintf("IsCanSignIn:%d", user.Id)
var isCan bool
if cache.Exists(cacheKey) {
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)
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
}
}
}

utils.FilePutContents("HomePageIsCanSignIn", utils.SerializeStr(map[string]interface{}{
@@ -423,6 +439,8 @@ func IsCanSignIn(c *gin.Context) {
resp := md.IsCanSignInResp{
IsCan: isCan,
}

cache.SetEx(cacheKey, "run", 30)
e.OutSuc(c, resp, nil)
return
}


Loading…
Откажи
Сачувај