From d0023bddc90419a6269ff9703c4d953ef09ed542 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 20 Feb 2024 11:14:16 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=B8=80=E4=B8=AA=E5=9C=88=E5=9C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...latoon_double_network_relate_commission.go | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/rule/public_platoon_double_network_relate_commission.go b/rule/public_platoon_double_network_relate_commission.go index 506c93d..c7b9313 100644 --- a/rule/public_platoon_double_network_relate_commission.go +++ b/rule/public_platoon_double_network_relate_commission.go @@ -97,6 +97,41 @@ func EstimateUserPosition(engine *xorm.Engine, uid int, dbName string) (total, l return } +/* +NowUserPosition 当前用户位置 +level 当前排名 +levelRank 用户当前层级排名 +*/ +func NowUserPosition(engine *xorm.Engine, uid int, dbName string) (level, levelRank int, err error) { + //1、查找 `user_public_platoon_setting` 基础设置 + userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{ + "key": "is_open", + "value": 1, + }) + if err != nil { + return + } + if userPublicPlatoonSetting == nil { + return + } + //2、查询出 `user_public_platoon_relation` 中相关记录 + userPublicPlatoonRelation, err := db.UserPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{ + "key": "uid", + "value": uid, + }) + if err != nil { + return + } + if userPublicPlatoonRelation != nil { + err = errors.New("未查询到当前用户公网记录") + return + } + level = userPublicPlatoonRelation.Level + levelPosition1 := getLevelForFirstPosition(level, userPublicPlatoonSetting.SeveralTimes) + levelRank = userPublicPlatoonRelation.Position - levelPosition1 + 1 + return +} + func CalcUserRank(engine *xorm.Engine, uid string) (rank, total int, amount string, err error) { sql := "SELECT id, uid, amount, @rank := @rank + 1 AS rank FROM `user_public_platoon_double_network_user_coin_record`, (SELECT @rank:=0) r ORDER BY amount DESC;" nativeString, _ := db.QueryNativeString(engine, sql)