|
|
@@ -24,7 +24,7 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
// 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 |
|
|
|
now := time.Now() |
|
|
|
|
|
|
@@ -64,7 +64,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin |
|
|
|
|
|
|
|
go dealEcpm(user, ecpm, ch) //TODO::协程处理ecpm的变化 |
|
|
|
|
|
|
|
var rewardValue float64 //TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制) |
|
|
|
//TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制) |
|
|
|
redisConn := cache.GetPool().Get() |
|
|
|
sysCfgDb := implement.NewSysCfgDb(engine, redisConn) |
|
|
|
videoRewardUnitPrice := sysCfgDb.SysCfgGetWithDb(enum.VideoRewardUnitPrice) |
|
|
@@ -72,7 +72,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin |
|
|
|
var coin model.VirtualCoin |
|
|
|
_, err = engine.Where("id = ?", eggEnergyBasicSetting.PersonEggPointsCoinId).Get(&coin) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return rewardValue, err |
|
|
|
} |
|
|
|
activePointsCoinExchangeRatioValue, _ := decimal.NewFromString(coin.ExchangeRatio) |
|
|
|
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)) |
|
|
|
if err1 != nil { |
|
|
|
if !elastic.IsNotFound(err1) { |
|
|
|
return err1 |
|
|
|
return rewardValue, err1 |
|
|
|
} |
|
|
|
} |
|
|
|
if !elastic.IsNotFound(err1) { |
|
|
@@ -111,7 +111,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin |
|
|
|
eggPointPartitionCoefficientManagementDb := implement.NewEggPointPartitionCoefficientManagementDb(engine) |
|
|
|
eggPointPartitionCoefficientManagements, err1 := eggPointPartitionCoefficientManagementDb.EggPointPartitionCoefficientManagementGetAll() |
|
|
|
if err1 != nil { |
|
|
|
return err1 |
|
|
|
return rewardValue, err1 |
|
|
|
} |
|
|
|
for _, v := range *eggPointPartitionCoefficientManagements { //处理蛋蛋分机制 |
|
|
|
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, |
|
|
|
}) |
|
|
|
if err1 != nil { |
|
|
|
return err1 |
|
|
|
return rewardValue, err1 |
|
|
|
} |
|
|
|
|
|
|
|
var rewardFather []struct { |
|
|
@@ -148,7 +148,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin |
|
|
|
"value": id, |
|
|
|
}) |
|
|
|
if err11 != nil { |
|
|
|
return err11 |
|
|
|
return rewardValue, err11 |
|
|
|
} |
|
|
|
if tmpOneCirclesPublicPlatoonUserRelation == nil { |
|
|
|
continue |
|
|
@@ -164,7 +164,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin |
|
|
|
var m model.EggSignIn |
|
|
|
has, err33 := engine.Where("uid =?", fatherUid).And("end_time >=?", time.Now().Format("2006-01-02 15:04:05")).Get(&m) |
|
|
|
if err33 != nil { |
|
|
|
return err33 |
|
|
|
return rewardValue, err33 |
|
|
|
} |
|
|
|
if !has { |
|
|
|
//不活跃不需要奖励 |
|
|
@@ -174,7 +174,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin |
|
|
|
userRelateDb := implement.NewUserRelateDb(engine) |
|
|
|
userCount, _, err2 := userRelateDb.SumUserRelateByParentUid(fatherUid) |
|
|
|
if err2 != nil { |
|
|
|
return err2 |
|
|
|
return rewardValue, err2 |
|
|
|
} |
|
|
|
|
|
|
|
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, |
|
|
|
}) |
|
|
|
if err1 != nil { |
|
|
|
return err1 |
|
|
|
return rewardValue, err1 |
|
|
|
} |
|
|
|
now := time.Now() |
|
|
|
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"), |
|
|
|
}) |
|
|
|
if err2 != nil { |
|
|
|
return err2 |
|
|
|
return rewardValue, err2 |
|
|
|
} |
|
|
|
} else { |
|
|
|
residueWatchAdNum := eggEnergyUserWatchRecords.ResidueWatchAdNum - 1 |
|
|
@@ -227,7 +227,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin |
|
|
|
eggEnergyUserWatchRecords.NextWatchAdDate = nextWatchAdDate |
|
|
|
_, err2 := eggEnergyUserWatchRecordsDb.EggEnergyUserWatchRecordsUpdate(eggEnergyUserWatchRecords.Id, eggEnergyUserWatchRecords, "residue_watch_ad_num", "next_watch_ad_date") |
|
|
|
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 { |
|
|
|
_ = session.Rollback() |
|
|
|
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() |
|
|
|
if err != nil { |
|
|
|
_ = session.Rollback() |
|
|
|
return errors.New("事务提交失败") |
|
|
|
return rewardValue, errors.New("事务提交失败") |
|
|
|
} |
|
|
|
|
|
|
|
redisKey := fmt.Sprintf(md2.UserNextWatchAdDate, uid) |
|
|
|