From be7fe8c75456711c20ef0846baa39ebdd84e906a Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 5 Dec 2024 12:30:23 +0800 Subject: [PATCH] update --- go.mod | 2 +- go.sum | 1 + ...activity_coin_ready_exchange_egg_energy.go | 2 +- rule/egg_energy/give_activty_coin.go | 36 ++++++++++++++++--- rule/egg_energy/home_page_watch_over_ad.go | 2 +- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 05a327f..a133682 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module code.fnuoos.com/EggPlanet/egg_system_rules.git go 1.19 // go.mod文件中 -//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models +replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models require ( code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 diff --git a/go.sum b/go.sum index 93dde90..b07269c 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241128102555-fc839292d728 h1:BHW0yPeka1RRS4pIcZKwiatVg9U4mE8iiTl1+YCk1vQ= code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241128102555-fc839292d728/go.mod h1:+bDK4gfBq4LEkhh6K/A46+0urH/sgxDxnjIjlxb9HI8= +code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241204145112-7b4c29691a6d/go.mod h1:+bDK4gfBq4LEkhh6K/A46+0urH/sgxDxnjIjlxb9HI8= code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be h1:zuleX5JnIGQpt6wDAmCFs++lLgOmE6kWo3xkJnjrSck= code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be/go.mod h1:Yuc7XnUQ15eaC0ZobcJG7XwkVTttVqp52OTanXhI1Qk= code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 h1:dqvWJqlJi0WXCwTxbWPLvSOsKPjP+iEDBVgLcAl9nOE= diff --git a/rule/egg_energy/activity_coin_ready_exchange_egg_energy.go b/rule/egg_energy/activity_coin_ready_exchange_egg_energy.go index 5ed3fb8..a3e7557 100644 --- a/rule/egg_energy/activity_coin_ready_exchange_egg_energy.go +++ b/rule/egg_energy/activity_coin_ready_exchange_egg_energy.go @@ -41,7 +41,7 @@ func ActivityCoinReadyExchangeEggEnergy(engine *xorm.Engine, uid int64, ch *rabb if err != nil { return } - if videoRewardSystem.RewardValue == "" || videoRewardSystem.RewardTotalNum == "" || videoRewardSystem.IntervalMinutes == "" || videoRewardSystem.EachRoundHour == "" { + if videoRewardSystem.RewardTotalNum == "" || videoRewardSystem.IntervalMinutes == "" || videoRewardSystem.EachRoundHour == "" { err = errors.New("视屏奖励机制设置未完全!") return } diff --git a/rule/egg_energy/give_activty_coin.go b/rule/egg_energy/give_activty_coin.go index c92905a..fa26a9c 100644 --- a/rule/egg_energy/give_activty_coin.go +++ b/rule/egg_energy/give_activty_coin.go @@ -1,6 +1,7 @@ package egg_energy import ( + db "code.fnuoos.com/EggPlanet/egg_models.git/src" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" @@ -47,7 +48,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ch *rabbit if err != nil { return } - if videoRewardSystem.RewardValue == "" || videoRewardSystem.RewardTotalNum == "" || videoRewardSystem.IntervalMinutes == "" || videoRewardSystem.EachRoundHour == "" { + if videoRewardSystem.RewardTotalNum == "" || videoRewardSystem.IntervalMinutes == "" || videoRewardSystem.EachRoundHour == "" { err = errors.New("视屏奖励机制设置未完全!") return } @@ -62,16 +63,33 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ch *rabbit return } - rewardValue := egg_system_rules.StrToFloat64(videoRewardSystem.RewardValue) //TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制) + var rewardValue float64 //TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制) + redisConn := cache.GetPool().Get() + sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn) + videoRewardUnitPrice := sysCfgDb.SysCfgGetWithDb(enum.VideoRewardUnitPrice) + if videoRewardUnitPrice != "" { //处理ecpm + var coin model.VirtualCoin + _, err = engine.Where("id = ?", eggEnergyBasicSetting.PersonEggPointsCoinId).Get(&coin) + if err != nil { + return err + } + activePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin.ExchangeRatio) + videoRewardUnitPriceValue, _ := decimal.NewFromString(videoRewardUnitPrice) + rewardValue, _ = videoRewardUnitPriceValue.Mul(activePointsCoinExchangeRatioValue).Float64() + } else { + rewardValue = egg_system_rules.StrToFloat64(videoRewardSystem.RewardValue) + } + var newUserRewardRules *md2.NewUserRewardRules err = json.Unmarshal([]byte(eggEnergyBasicSetting.NewUserIncentiveRules), &newUserRewardRules) if err != nil { return } userCreateAt := egg_system_rules.String2Time(user.CreateAt) - if int(now.Sub(userCreateAt).Hours()/24) <= newUserRewardRules.ContinueDays { + if int(now.Sub(userCreateAt).Hours()/24) <= newUserRewardRules.ContinueDays { //处理新用户机制 rewardValue *= newUserRewardRules.RewardCoefficient } + score := 60.00 esIndex := es.GetLatestEffectiveIndexFromAlias(now) esIndexName := md.EggEnergyUserEggScoreEsAlias + "_" + esIndex @@ -89,10 +107,18 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ch *rabbit } score = doc.ScoreValue } - if score > 60 { - //TODO::按照蛋蛋分比重× + eggPointPartitionCoefficientManagementDb := implement.NewEggPointPartitionCoefficientManagementDb(db.Db) + eggPointPartitionCoefficientManagements, err1 := eggPointPartitionCoefficientManagementDb.EggPointPartitionCoefficientManagementGetAll() + if err1 != nil { + return err1 + } + for _, v := range *eggPointPartitionCoefficientManagements { //处理蛋蛋分机制 + if egg_system_rules.StrToFloat64(v.StartScore) <= score && egg_system_rules.StrToFloat64(v.EndScore) >= score { + rewardValue *= egg_system_rules.StrToFloat64(v.Coefficient) + } } + //处理圈层奖励 var rewardSystemMap = map[int]*md2.RewardSystemStruct{} for _, v := range rewardSystem { rewardSystemMap[v.Level] = v diff --git a/rule/egg_energy/home_page_watch_over_ad.go b/rule/egg_energy/home_page_watch_over_ad.go index 457468f..6896e9f 100644 --- a/rule/egg_energy/home_page_watch_over_ad.go +++ b/rule/egg_energy/home_page_watch_over_ad.go @@ -60,7 +60,7 @@ func settlementPublicGiveActivityCoin(engine *xorm.Engine, uid int64, ch *rabbit if err != nil { return err } - if videoRewardSystem.RewardValue == "" || videoRewardSystem.RewardTotalNum == "" || videoRewardSystem.IntervalMinutes == "" || videoRewardSystem.EachRoundHour == "" { + if videoRewardSystem.RewardTotalNum == "" || videoRewardSystem.IntervalMinutes == "" || videoRewardSystem.EachRoundHour == "" { err = errors.New("视屏奖励机制设置未完全!") return err }