huangjiajun преди 4 дни
родител
ревизия
eafd411344
променени са 1 файла, в които са добавени 35 реда и са изтрити 42 реда
  1. +35
    -42
      app/hdl/hdl_home_page.go

+ 35
- 42
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
}


Зареждане…
Отказ
Запис