|
|
@@ -11,10 +11,8 @@ import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"github.com/go-redis/redis" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@@ -89,6 +87,7 @@ func StatisticsUserEggIndex(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
var resp md.StatisticsEggPointResp |
|
|
|
var tempResp md.StatisticsEggPointResp |
|
|
|
var err error |
|
|
|
|
|
|
|
var esIndexName string |
|
|
@@ -101,79 +100,110 @@ func StatisticsUserEggIndex(c *gin.Context) { |
|
|
|
} |
|
|
|
yearAndWeekStr := req.Year + req.Week |
|
|
|
redisKey := fmt.Sprintf(md.AutoCachingEggPointRedisKey, yearAndWeekStr) |
|
|
|
err1 := cache.GetJson(redisKey, &resp) |
|
|
|
if err1 != nil && !errors.Is(err1, redis.Nil) { |
|
|
|
e.OutErr(c, e.ERR, err1.Error()) |
|
|
|
return |
|
|
|
} else if errors.Is(err1, redis.Nil) { |
|
|
|
// 缓存不存在数据直接查询 |
|
|
|
//统计用户"ecpm"范围 |
|
|
|
resp.StatisticsUserEggEcpmRange, err = egg_energy.StatisticsUserEggEcpmRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"拉新人数"范围 |
|
|
|
resp.StatisticsUserEggInviteUserNumsRange, err = egg_energy.StatisticsUserEggInviteUserNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"团队活跃次数"范围 |
|
|
|
resp.StatisticsUserEggTeamActivityNumsRange, err = egg_energy.StatisticsUserEggTeamActivityNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"签到次数"范围 |
|
|
|
resp.StatisticsUserEggSignInNumsRange, err = egg_energy.StatisticsUserEggSignInNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"发红包次数"范围 |
|
|
|
resp.StatisticsUserEggSendRedPackageNumsRange, err = egg_energy.StatisticsUserEggSendRedPackageNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"蛋蛋能量兑换余额数量"范围 |
|
|
|
resp.StatisticsUserEggEggEnergyExchangeAccountBalanceRange, err = egg_energy.StatisticsUserEggEggEnergyExchangeAccountBalanceRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"蛋蛋能量兑换余额数量"范围 |
|
|
|
resp.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange, err = egg_energy.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
var err1 error |
|
|
|
err1 = cache.GetJson(redisKey, &tempResp) |
|
|
|
if err1 != nil { |
|
|
|
if err1.Error() != "redigo: nil returned" { |
|
|
|
e.OutErr(c, e.ERR, err1.Error()) |
|
|
|
return |
|
|
|
} else { |
|
|
|
// 缓存不存在数据直接查询 |
|
|
|
//统计用户"ecpm"范围 |
|
|
|
tempResp.StatisticsUserEggEcpmRange, err = egg_energy.StatisticsUserEggEcpmRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"拉新人数"范围 |
|
|
|
tempResp.StatisticsUserEggInviteUserNumsRange, err = egg_energy.StatisticsUserEggInviteUserNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"团队活跃次数"范围 |
|
|
|
tempResp.StatisticsUserEggTeamActivityNumsRange, err = egg_energy.StatisticsUserEggTeamActivityNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"签到次数"范围 |
|
|
|
tempResp.StatisticsUserEggSignInNumsRange, err = egg_energy.StatisticsUserEggSignInNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"发红包次数"范围 |
|
|
|
tempResp.StatisticsUserEggSendRedPackageNumsRange, err = egg_energy.StatisticsUserEggSendRedPackageNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"蛋蛋能量兑换余额数量"范围 |
|
|
|
tempResp.StatisticsUserEggEggEnergyExchangeAccountBalanceRange, err = egg_energy.StatisticsUserEggEggEnergyExchangeAccountBalanceRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"蛋蛋能量兑换余额数量"范围 |
|
|
|
tempResp.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange, err = egg_energy.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"发朋友圈次数"范围 |
|
|
|
tempResp.StatisticsUserEggSendCircleOfFriendNumsRange, err = egg_energy.StatisticsUserEggSendCircleOfFriendNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"论坛评论次数"范围 |
|
|
|
tempResp.StatisticsUserEggForumCommentsNumsRange, err = egg_energy.StatisticsUserEggForumCommentsNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"学院学习次数"范围 |
|
|
|
tempResp.StatisticsUserEggCollegeLearningNumsRange, err = egg_energy.StatisticsUserEggCollegeLearningNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"违规次数"范围 |
|
|
|
tempResp.StatisticsUserEggViolateNumsRange, err = egg_energy.StatisticsUserEggViolateNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"浏览界面次数"范围 |
|
|
|
tempResp.StatisticsUserEggBrowseInterfaceNumsRange, err = egg_energy.StatisticsUserEggBrowseInterfaceNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"个人活跃积分增量值"范围 |
|
|
|
tempResp.StatisticsUserEggPersonAddActivityValueRange, err = egg_energy.StatisticsUserEggPersonAddActivityValueRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
// 更新缓存 |
|
|
|
cache.SetJson(redisKey, tempResp, -1) |
|
|
|
} |
|
|
|
//统计用户"发朋友圈次数"范围 |
|
|
|
resp.StatisticsUserEggSendCircleOfFriendNumsRange, err = egg_energy.StatisticsUserEggSendCircleOfFriendNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"论坛评论次数"范围 |
|
|
|
resp.StatisticsUserEggForumCommentsNumsRange, err = egg_energy.StatisticsUserEggForumCommentsNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"学院学习次数"范围 |
|
|
|
resp.StatisticsUserEggCollegeLearningNumsRange, err = egg_energy.StatisticsUserEggCollegeLearningNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"违规次数"范围 |
|
|
|
resp.StatisticsUserEggViolateNumsRange, err = egg_energy.StatisticsUserEggViolateNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"浏览界面次数"范围 |
|
|
|
resp.StatisticsUserEggBrowseInterfaceNumsRange, err = egg_energy.StatisticsUserEggBrowseInterfaceNumsRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
//统计用户"个人活跃积分增量值"范围 |
|
|
|
resp.StatisticsUserEggPersonAddActivityValueRange, err = egg_energy.StatisticsUserEggPersonAddActivityValueRange(esIndexName) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
} |
|
|
|
// 更新缓存 |
|
|
|
cache.SetJson(redisKey, resp, -1) |
|
|
|
} |
|
|
|
switch req.Kind { |
|
|
|
case "1": |
|
|
|
resp.StatisticsUserEggEcpmRange = tempResp.StatisticsUserEggEcpmRange |
|
|
|
case "2": |
|
|
|
resp.StatisticsUserEggInviteUserNumsRange = tempResp.StatisticsUserEggInviteUserNumsRange |
|
|
|
case "3": |
|
|
|
resp.StatisticsUserEggTeamActivityNumsRange = tempResp.StatisticsUserEggTeamActivityNumsRange |
|
|
|
case "4": |
|
|
|
resp.StatisticsUserEggSignInNumsRange = tempResp.StatisticsUserEggSignInNumsRange |
|
|
|
case "5": |
|
|
|
resp.StatisticsUserEggSendRedPackageNumsRange = tempResp.StatisticsUserEggSendRedPackageNumsRange |
|
|
|
case "6": |
|
|
|
resp.StatisticsUserEggEggEnergyExchangeAccountBalanceRange = tempResp.StatisticsUserEggEggEnergyExchangeAccountBalanceRange |
|
|
|
case "7": |
|
|
|
resp.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange = tempResp.StatisticsUserEggAccountBalanceExchangeEggEnergyNumsRange |
|
|
|
case "8": |
|
|
|
resp.StatisticsUserEggSendCircleOfFriendNumsRange = tempResp.StatisticsUserEggSendCircleOfFriendNumsRange |
|
|
|
case "9": |
|
|
|
resp.StatisticsUserEggForumCommentsNumsRange = tempResp.StatisticsUserEggForumCommentsNumsRange |
|
|
|
case "10": |
|
|
|
resp.StatisticsUserEggCollegeLearningNumsRange = tempResp.StatisticsUserEggCollegeLearningNumsRange |
|
|
|
case "11": |
|
|
|
resp.StatisticsUserEggViolateNumsRange = tempResp.StatisticsUserEggViolateNumsRange |
|
|
|
case "12": |
|
|
|
resp.StatisticsUserEggBrowseInterfaceNumsRange = tempResp.StatisticsUserEggBrowseInterfaceNumsRange |
|
|
|
case "13": |
|
|
|
resp.StatisticsUserEggPersonAddActivityValueRange = tempResp.StatisticsUserEggPersonAddActivityValueRange |
|
|
|
} |
|
|
|
|
|
|
|
resp.YearAndWeekList, err = egg_energy.GetYearsAndWeeks() |
|
|
|