Procházet zdrojové kódy

update 一个圈圈

master
DengBiao před 8 měsíci
rodič
revize
d0023bddc9
1 změnil soubory, kde provedl 35 přidání a 0 odebrání
  1. +35
    -0
      rule/public_platoon_double_network_relate_commission.go

+ 35
- 0
rule/public_platoon_double_network_relate_commission.go Zobrazit soubor

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


Načítá se…
Zrušit
Uložit