From 1993e0e37d5eff35ba1a606261bb349126f72a12 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 1 Jan 2025 00:22:57 +0800 Subject: [PATCH] updaste --- md/es.go | 8 ++++++++ rule/egg_energy/create_es_score_and_assign_value.go | 4 ++++ rule/egg_energy/enum/es_egg_energy_score_enum.go | 2 ++ rule/egg_energy/give_activty_coin.go | 5 ++++- utils/es/base.go | 7 ++++--- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/md/es.go b/md/es.go index 7b03889..23980a2 100644 --- a/md/es.go +++ b/md/es.go @@ -30,6 +30,12 @@ const EggEnergyUserEggScoreEsMapping = ` "ecpm":{ "type": "double" }, + "ecpm_avg":{ + "type": "double" + }, + "ecpm_nums":{ + "type": "integer" + }, "invite_user_nums":{ "type": "integer" }, @@ -86,6 +92,8 @@ type EggEnergyUserEggScoreEs struct { ScoreValue float64 `json:"score_value" label:"蛋蛋分值"` ScoreValueKind int32 `json:"score_value_kind" label:"评分类型(0:未知 1:人工 2:系统)"` Ecpm float64 `json:"ecpm" label:"ecpm"` + EcpmAvg float64 `json:"ecpm_avg" label:"ecpm平均值"` + EcpmNums int `json:"ecpm_nums" label:"ecpm次数"` InviteUserNums int `json:"invite_user_nums" label:"拉新人数"` TeamActivityNums int `json:"team_activity_nums" label:"团队活跃次数"` SignInNums int `json:"sign_in_nums" label:"签到次数"` diff --git a/rule/egg_energy/create_es_score_and_assign_value.go b/rule/egg_energy/create_es_score_and_assign_value.go index d3a72e0..080cfb6 100644 --- a/rule/egg_energy/create_es_score_and_assign_value.go +++ b/rule/egg_energy/create_es_score_and_assign_value.go @@ -21,6 +21,10 @@ func CreateEsScoreAndAssignValuesDoc(index, id string, uid int64, kind enum.EggE m.ScoreValueKind = int32(utils.StrToInt64(value)) case enum.Ecpm: m.Ecpm = utils.StrToFloat64(value) + case enum.EcpmAvg: + m.EcpmAvg = utils.StrToFloat64(value) + case enum.EcpmNums: + m.EcpmNums = utils.StrToInt(value) case enum.InviteUserNums: m.InviteUserNums = utils.StrToInt(value) case enum.TeamActivityNums: diff --git a/rule/egg_energy/enum/es_egg_energy_score_enum.go b/rule/egg_energy/enum/es_egg_energy_score_enum.go index 939b9b6..38a250d 100644 --- a/rule/egg_energy/enum/es_egg_energy_score_enum.go +++ b/rule/egg_energy/enum/es_egg_energy_score_enum.go @@ -7,6 +7,8 @@ const ( ScoreValue = iota + 1 ScoreValueKind Ecpm + EcpmAvg + EcpmNums InviteUserNums TeamActivityNums SignInNums diff --git a/rule/egg_energy/give_activty_coin.go b/rule/egg_energy/give_activty_coin.go index d8ffd42..d82e7cb 100644 --- a/rule/egg_energy/give_activty_coin.go +++ b/rule/egg_energy/give_activty_coin.go @@ -107,7 +107,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin rewardValue *= newUserRewardRules.RewardCoefficient } - score := 60.00 + var score float64 esIndex := es.GetLatestEffectiveIndexFromAlias(now) esIndexName := md.EggEnergyUserEggScoreEsAlias + "_" + esIndex results, err1 := es2.FirstDoc(esIndexName, esIndex+"_"+egg_system_rules.Int64ToStr(user.Id)) @@ -124,6 +124,9 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin } score = doc.ScoreValue } + if score == 0 { + score = 60.00 + } fmt.Println("SettlementGiveActivityCoin:e:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) eggPointPartitionCoefficientManagementDb := implement.NewEggPointPartitionCoefficientManagementDb(engine) diff --git a/utils/es/base.go b/utils/es/base.go index 73fa7e5..c9ae96d 100644 --- a/utils/es/base.go +++ b/utils/es/base.go @@ -18,7 +18,8 @@ func GetAppointIndexFromAlias(year string, week string) string { // GetLatestEffectiveIndexFromAlias 获取最新有效别名 // TODO::临时默认全是60分 func GetLatestEffectiveIndexFromAlias(now time.Time) string { - if now.Weekday() > time.Wednesday || (now.Weekday() > time.Wednesday && now.Hour() > 14) { + //if now.Weekday() > time.Wednesday || (now.Weekday() > time.Wednesday && now.Hour() > 14) { + if now.Weekday() > time.Friday || (now.Weekday() > time.Friday && now.Hour() > 14) { // 当前已经过了周三下午两点 返回上周蛋蛋分 now = now.AddDate(0, 0, -7*2) } else { @@ -30,8 +31,8 @@ func GetLatestEffectiveIndexFromAlias(now time.Time) string { } func GetLatestEffectiveIndexFromAliasForAdmin(now time.Time) string { - if !(now.Weekday() > time.Tuesday || (now.Weekday() > time.Tuesday && now.Hour() > 18)) { - // 没过周三下午两点 返回上周蛋蛋分 + if !(now.Weekday() > time.Friday || (now.Weekday() > time.Friday && now.Hour() > 18)) { + // 没过周二下午六点 返回上周蛋蛋分 now = now.AddDate(0, 0, -7) } year, week := now.ISOWeek()