Browse Source

结算观看激励广告返回积分值

master
huangjiajun 1 week ago
parent
commit
05287d4823
1 changed files with 14 additions and 14 deletions
  1. +14
    -14
      rule/egg_energy/give_activty_coin.go

+ 14
- 14
rule/egg_energy/give_activty_coin.go View File

@@ -24,7 +24,7 @@ import (
) )


// SettlementGiveActivityCoin 结算观看激励广告得到蛋蛋积分 // SettlementGiveActivityCoin 结算观看激励广告得到蛋蛋积分
func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm string, ch *rabbit.Channel) (err error) {
func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm string, ch *rabbit.Channel) (rewardValue float64, err error) {
uid := user.Id uid := user.Id
now := time.Now() now := time.Now()


@@ -64,7 +64,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin


go dealEcpm(user, ecpm, ch) //TODO::协程处理ecpm的变化 go dealEcpm(user, ecpm, ch) //TODO::协程处理ecpm的变化


var rewardValue float64 //TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制)
//TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制)
redisConn := cache.GetPool().Get() redisConn := cache.GetPool().Get()
sysCfgDb := implement.NewSysCfgDb(engine, redisConn) sysCfgDb := implement.NewSysCfgDb(engine, redisConn)
videoRewardUnitPrice := sysCfgDb.SysCfgGetWithDb(enum.VideoRewardUnitPrice) videoRewardUnitPrice := sysCfgDb.SysCfgGetWithDb(enum.VideoRewardUnitPrice)
@@ -72,7 +72,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
var coin model.VirtualCoin var coin model.VirtualCoin
_, err = engine.Where("id = ?", eggEnergyBasicSetting.PersonEggPointsCoinId).Get(&coin) _, err = engine.Where("id = ?", eggEnergyBasicSetting.PersonEggPointsCoinId).Get(&coin)
if err != nil { if err != nil {
return err
return rewardValue, err
} }
activePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin.ExchangeRatio) activePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin.ExchangeRatio)
videoRewardUnitPriceValue, _ := decimal.NewFromString(videoRewardUnitPrice) videoRewardUnitPriceValue, _ := decimal.NewFromString(videoRewardUnitPrice)
@@ -97,7 +97,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
results, err1 := es2.FirstDoc(esIndexName, esIndex+"_"+egg_system_rules.Int64ToStr(user.Id)) results, err1 := es2.FirstDoc(esIndexName, esIndex+"_"+egg_system_rules.Int64ToStr(user.Id))
if err1 != nil { if err1 != nil {
if !elastic.IsNotFound(err1) { if !elastic.IsNotFound(err1) {
return err1
return rewardValue, err1
} }
} }
if !elastic.IsNotFound(err1) { if !elastic.IsNotFound(err1) {
@@ -111,7 +111,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
eggPointPartitionCoefficientManagementDb := implement.NewEggPointPartitionCoefficientManagementDb(engine) eggPointPartitionCoefficientManagementDb := implement.NewEggPointPartitionCoefficientManagementDb(engine)
eggPointPartitionCoefficientManagements, err1 := eggPointPartitionCoefficientManagementDb.EggPointPartitionCoefficientManagementGetAll() eggPointPartitionCoefficientManagements, err1 := eggPointPartitionCoefficientManagementDb.EggPointPartitionCoefficientManagementGetAll()
if err1 != nil { if err1 != nil {
return err1
return rewardValue, err1
} }
for _, v := range *eggPointPartitionCoefficientManagements { //处理蛋蛋分机制 for _, v := range *eggPointPartitionCoefficientManagements { //处理蛋蛋分机制
if egg_system_rules.StrToFloat64(v.StartScore) <= score && egg_system_rules.StrToFloat64(v.EndScore) >= score { if egg_system_rules.StrToFloat64(v.StartScore) <= score && egg_system_rules.StrToFloat64(v.EndScore) >= score {
@@ -130,7 +130,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
"value": uid, "value": uid,
}) })
if err1 != nil { if err1 != nil {
return err1
return rewardValue, err1
} }


var rewardFather []struct { var rewardFather []struct {
@@ -148,7 +148,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
"value": id, "value": id,
}) })
if err11 != nil { if err11 != nil {
return err11
return rewardValue, err11
} }
if tmpOneCirclesPublicPlatoonUserRelation == nil { if tmpOneCirclesPublicPlatoonUserRelation == nil {
continue continue
@@ -164,7 +164,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
var m model.EggSignIn var m model.EggSignIn
has, err33 := engine.Where("uid =?", fatherUid).And("end_time >=?", time.Now().Format("2006-01-02 15:04:05")).Get(&m) has, err33 := engine.Where("uid =?", fatherUid).And("end_time >=?", time.Now().Format("2006-01-02 15:04:05")).Get(&m)
if err33 != nil { if err33 != nil {
return err33
return rewardValue, err33
} }
if !has { if !has {
//不活跃不需要奖励 //不活跃不需要奖励
@@ -174,7 +174,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
userRelateDb := implement.NewUserRelateDb(engine) userRelateDb := implement.NewUserRelateDb(engine)
userCount, _, err2 := userRelateDb.SumUserRelateByParentUid(fatherUid) userCount, _, err2 := userRelateDb.SumUserRelateByParentUid(fatherUid)
if err2 != nil { if err2 != nil {
return err2
return rewardValue, err2
} }


if fatherReward != nil && userCount >= egg_system_rules.StrToInt64(fatherReward.RewardCondition) { if fatherReward != nil && userCount >= egg_system_rules.StrToInt64(fatherReward.RewardCondition) {
@@ -196,7 +196,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
"value": uid, "value": uid,
}) })
if err1 != nil { if err1 != nil {
return err1
return rewardValue, err1
} }
now := time.Now() now := time.Now()
if eggEnergyUserWatchRecords == nil { if eggEnergyUserWatchRecords == nil {
@@ -212,7 +212,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
UpdateAt: now.Format("2006-01-02 15:04:05"), UpdateAt: now.Format("2006-01-02 15:04:05"),
}) })
if err2 != nil { if err2 != nil {
return err2
return rewardValue, err2
} }
} else { } else {
residueWatchAdNum := eggEnergyUserWatchRecords.ResidueWatchAdNum - 1 residueWatchAdNum := eggEnergyUserWatchRecords.ResidueWatchAdNum - 1
@@ -227,7 +227,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
eggEnergyUserWatchRecords.NextWatchAdDate = nextWatchAdDate eggEnergyUserWatchRecords.NextWatchAdDate = nextWatchAdDate
_, err2 := eggEnergyUserWatchRecordsDb.EggEnergyUserWatchRecordsUpdate(eggEnergyUserWatchRecords.Id, eggEnergyUserWatchRecords, "residue_watch_ad_num", "next_watch_ad_date") _, err2 := eggEnergyUserWatchRecordsDb.EggEnergyUserWatchRecordsUpdate(eggEnergyUserWatchRecords.Id, eggEnergyUserWatchRecords, "residue_watch_ad_num", "next_watch_ad_date")
if err2 != nil { if err2 != nil {
return err2
return rewardValue, err2
} }
} }


@@ -252,7 +252,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()
fmt.Println("err:::::2222", err) fmt.Println("err:::::2222", err)
return err
return rewardValue, err
} }


//给相应的用户加上"团队"活跃积分 //给相应的用户加上"团队"活跃积分
@@ -270,7 +270,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin
err = session.Commit() err = session.Commit()
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()
return errors.New("事务提交失败")
return rewardValue, errors.New("事务提交失败")
} }


redisKey := fmt.Sprintf(md2.UserNextWatchAdDate, uid) redisKey := fmt.Sprintf(md2.UserNextWatchAdDate, uid)


Loading…
Cancel
Save