From e0f66e90ecf891814006f7c77535f8e97c199e18 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Mon, 30 Dec 2024 09:27:09 +0800 Subject: [PATCH] test --- rule/egg_energy/give_activty_coin.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/rule/egg_energy/give_activty_coin.go b/rule/egg_energy/give_activty_coin.go index 97f3e41..d8ffd42 100644 --- a/rule/egg_energy/give_activty_coin.go +++ b/rule/egg_energy/give_activty_coin.go @@ -27,7 +27,6 @@ import ( // SettlementGiveActivityCoin 结算观看激励广告得到蛋蛋积分 func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm string, ch *rabbit.Channel) (rewardValue float64, err error) { egg_system_rules.FilePutContents("SettlementGiveActivityCoin", egg_system_rules.SerializeStr(user)) - uid := user.Id now := time.Now() @@ -40,6 +39,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin return 0, errors.New("未到可观看时间~~") } } + fmt.Println("SettlementGiveActivityCoin:a:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) //1、查找 `egg_energy_basic_setting` 基础设置 eggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(engine) @@ -75,8 +75,10 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin err = errors.New("未设置奖励机制!") return } + fmt.Println("SettlementGiveActivityCoin:b:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) go dealEcpm(user, ecpm, ch) //TODO::协程处理ecpm的变化 + fmt.Println("SettlementGiveActivityCoin:c:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) //TODO::奖励多少个活跃积分(根据ecpm, 新用户机制, 蛋蛋分机制) sysCfgDb := sys_cfg.NewSysCfgDb(engine) @@ -93,6 +95,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin } else { rewardValue = egg_system_rules.StrToFloat64(videoRewardSystem.RewardValue) } + fmt.Println("SettlementGiveActivityCoin:d:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) var newUserRewardRules *md2.NewUserRewardRules err = json.Unmarshal([]byte(eggEnergyBasicSetting.NewUserIncentiveRules), &newUserRewardRules) @@ -121,6 +124,8 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin } score = doc.ScoreValue } + fmt.Println("SettlementGiveActivityCoin:e:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) + eggPointPartitionCoefficientManagementDb := implement.NewEggPointPartitionCoefficientManagementDb(engine) eggPointPartitionCoefficientManagements, err1 := eggPointPartitionCoefficientManagementDb.EggPointPartitionCoefficientManagementGetAll() if err1 != nil { @@ -158,6 +163,8 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin if publicPlatoonUserRelation != nil { fatherUids = strings.Split(publicPlatoonUserRelation.FatherUid, "-") } + fmt.Println("SettlementGiveActivityCoin:f:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) + for k, id := range fatherUids { tmpOneCirclesPublicPlatoonUserRelation, err11 := publicPlatoonUserRelationDb.PublicPlatoonUserRelationGetOneByParams(map[string]interface{}{ "key": "id", @@ -173,25 +180,31 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin //待填充位 continue } + fmt.Println("SettlementGiveActivityCoin:f1:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) fatherUid := egg_system_rules.Int64ToStr(tmpOneCirclesPublicPlatoonUserRelation.Uid) fatherReward := rewardSystemMap[k+1] //TODO::判断是否活跃 var m model.EggSignIn has, err33 := engine.Where("uid =?", fatherUid).And("end_time >=?", time.Now().Format("2006-01-02 15:04:05")).Get(&m) + fmt.Println("SettlementGiveActivityCoin:f2:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) + if err33 != nil { return rewardValue, err33 } + if !has { //不活跃不需要奖励 continue } + //判断是否满足奖励条件 userRelateDb := implement.NewUserRelateDb(engine) userCount, _, err2 := userRelateDb.SumUserRelateByParentUid(fatherUid) if err2 != nil { return rewardValue, err2 } + fmt.Println("SettlementGiveActivityCoin:f3:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) if fatherReward != nil && userCount >= egg_system_rules.StrToInt64(fatherReward.RewardCondition) { fatherRewardValue := rewardValue * (egg_system_rules.StrToFloat64(fatherReward.RewardValue) / 100) @@ -230,6 +243,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin fatherRewardValue = 0 } } + fmt.Println("SettlementGiveActivityCoin:g:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) session := engine.NewSession() defer func() { @@ -254,6 +268,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin fmt.Println("err:::::2222", err) return rewardValue, err } + fmt.Println("SettlementGiveActivityCoin:i:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) //给相应的用户上级加上"团队"活跃积分 if fatherRewardValue > 0 { @@ -271,6 +286,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin return rewardValue, err } } + fmt.Println("SettlementGiveActivityCoin:j:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) //给相应的用户加上"团队"活跃积分 for _, vv := range rewardFather { @@ -294,6 +310,8 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin }, md2.EggEnergyTeamAssistance) } } + fmt.Println("SettlementGiveActivityCoin:k:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) + err = session.Commit() if err != nil { _ = session.Rollback() @@ -342,6 +360,7 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin return rewardValue, err2 } } + fmt.Println("SettlementGiveActivityCoin:l:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) var watchAdDate string if eggEnergyUserWatchRecords.ResidueWatchAdNum == egg_system_rules.StrToInt(videoRewardSystem.RewardTotalNum) { @@ -354,6 +373,8 @@ func SettlementGiveActivityCoin(engine *xorm.Engine, user model.User, ecpm strin watchAdDate = time.Now().Add(time.Duration(egg_system_rules.StrToInt64(videoRewardSystem.IntervalMinutes)) * time.Second).Format("2006-01-02 15:04:05") } cache.SetEx(redisKey, watchAdDate, 60*60*24) //TODO::默认缓存1小时 + fmt.Println("SettlementGiveActivityCoin:m:", egg_system_rules.Int64ToStr(user.Id)+":"+ecpm+":", time.Since(now)) + return }