|
@@ -4,6 +4,7 @@ import ( |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" |
|
|
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/svc" |
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" |
|
|
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" |
|
|
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx" |
|
|
"errors" |
|
|
"errors" |
|
@@ -24,7 +25,7 @@ rank 用户总排名 |
|
|
previousRow 上一层级 |
|
|
previousRow 上一层级 |
|
|
diffValue 距离上一层级差值 |
|
|
diffValue 距离上一层级差值 |
|
|
*/ |
|
|
*/ |
|
|
func EstimateUserPosition(engine *xorm.Engine, uid int) (total, level, levelRank, rank, previousRow int, diffValue string, err error) { |
|
|
|
|
|
|
|
|
func EstimateUserPosition(engine *xorm.Engine, uid int, dbName string) (total, level, levelRank, rank, previousRow int, diffValue string, err error) { |
|
|
//1、查找 `user_public_platoon_setting` 基础设置 |
|
|
//1、查找 `user_public_platoon_setting` 基础设置 |
|
|
userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{ |
|
|
userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{ |
|
|
"key": "is_open", |
|
|
"key": "is_open", |
|
@@ -41,6 +42,39 @@ func EstimateUserPosition(engine *xorm.Engine, uid int) (total, level, levelRank |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
if rank == 0 { |
|
|
|
|
|
userPublicPlatoonDoubleNetworkSetting, err1 := db.UserPublicPlatoonDoubleNetworkSettingGetOneByParams(engine, map[string]interface{}{ |
|
|
|
|
|
"key": "is_open", |
|
|
|
|
|
"value": 1, |
|
|
|
|
|
}) |
|
|
|
|
|
if err1 != nil { |
|
|
|
|
|
err = err1 |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
coinAmount, err2 := svc.GetUserCoinAmount(engine.NewSession(), dbName, userPublicPlatoonDoubleNetworkSetting.CoinId, uid) |
|
|
|
|
|
if err2 != nil { |
|
|
|
|
|
err = err2 |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
userProfile, err3 := db.UserProfileFindByID(engine, uid) |
|
|
|
|
|
if err3 != nil { |
|
|
|
|
|
err = err3 |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
_, err4 := db.UserPublicPlatoonDoubleNetworkUserCoinRecordInsert(engine, &model.UserPublicPlatoonDoubleNetworkUserCoinRecord{ |
|
|
|
|
|
Uid: uid, |
|
|
|
|
|
LastAmount: coinAmount, |
|
|
|
|
|
Amount: coinAmount, |
|
|
|
|
|
RecommendUid: userProfile.ParentUid, |
|
|
|
|
|
CoinId: userPublicPlatoonDoubleNetworkSetting.CoinId, |
|
|
|
|
|
CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
|
|
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
|
|
}) |
|
|
|
|
|
if err4 != nil { |
|
|
|
|
|
err = err4 |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
rows := float64(userPublicPlatoonSetting.SeveralRows) |
|
|
rows := float64(userPublicPlatoonSetting.SeveralRows) |
|
|
times := float64(userPublicPlatoonSetting.SeveralTimes) |
|
|
times := float64(userPublicPlatoonSetting.SeveralTimes) |
|
|
level = makeSearchLevelByPosition(&rank, rows, ×) |
|
|
level = makeSearchLevelByPosition(&rank, rows, ×) |
|
|