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