shenjiachi преди 2 дни
родител
ревизия
3d068f7a6b
променени са 4 файла, в които са добавени 119 реда и са изтрити 87 реда
  1. +104
    -74
      app/hdl/institutional_management/egg_energy/hdl_egg_point.go
  2. +1
    -0
      app/md/institutional_management/egg_energy/md_egg_point.go
  3. +1
    -0
      app/task/svc/svc_auto_caching_egg_point_statistics.go
  4. +13
    -13
      etc/cfg.yml

+ 104
- 74
app/hdl/institutional_management/egg_energy/hdl_egg_point.go Целия файл

@@ -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()


+ 1
- 0
app/md/institutional_management/egg_energy/md_egg_point.go Целия файл

@@ -5,6 +5,7 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
type StatisticsEggPointReq struct {
Year string `json:"year" example:"年份"`
Week string `json:"week" example:"周份"`
Kind string `json:"kind"`
}

type UserEggIndexReq struct {


+ 1
- 0
app/task/svc/svc_auto_caching_egg_point_statistics.go Целия файл

@@ -31,6 +31,7 @@ func AutoCachingEggPointStatistics(engine *xorm.Engine) {
return
}
cache.SetEx(AutoCachingEggPointStatisticsLockKey, "running", 10*60) // 10 min
cache.Del(AutoCachingEggPointStatisticsLockKey)

// 1. 查询所有蛋蛋分索引
aliasName := md.EggEnergyUserEggScoreEsAlias


+ 13
- 13
etc/cfg.yml Целия файл

@@ -9,26 +9,26 @@ srv_addr: ':4001'
redis_addr: '127.0.0.1:6379'
redis_password: ''

#db:
# host: '119.23.182.117:3306'
# name: 'egg'
# user: 'root'
# psw: 'Fnuo123com@'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'
db:
host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
host: '119.23.182.117:3306'
name: 'egg'
user: 'canal'
psw: 'DengBiao@1997'
user: 'root'
psw: 'Fnuo123com@'
show_log: true
max_lifetime: 30
max_open_conns: 100
max_idle_conns: 100
path: 'tmp/%s.log'
#db:
# host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
# name: 'egg'
# user: 'canal'
# psw: 'DengBiao@1997'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'

#db_back:
# host: '119.23.182.117:3306'


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