|
|
@@ -426,3 +426,35 @@ func GetUserRankAmount(engine *xorm.Engine, rank string) (amount string, err err |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func ResetPublicPlatoonDoubleNetwork(engine *xorm.Engine, dbName string) (err error) { |
|
|
|
//1、查找 `user_public_platoon_setting` 基础设置 |
|
|
|
now := time.Now() |
|
|
|
userPublicPlatoonDoubleNetworkSetting, err := db.UserPublicPlatoonDoubleNetworkSettingGetOneByParams(engine, map[string]interface{}{ |
|
|
|
"key": "is_open", |
|
|
|
"value": 1, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if userPublicPlatoonDoubleNetworkSetting.IsOpen != 1 { |
|
|
|
return errors.New("未开启公排双网!") |
|
|
|
} |
|
|
|
if userPublicPlatoonDoubleNetworkSetting.SettlementDate != now.Format("2006-01-02") { |
|
|
|
return errors.New("非重置日期!") |
|
|
|
} |
|
|
|
|
|
|
|
//2、计算排名数据 |
|
|
|
//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) |
|
|
|
//if len(nativeString) <= 0 { |
|
|
|
// return errors.New("当前无排名数据") |
|
|
|
//} |
|
|
|
//for _, v := range nativeString { |
|
|
|
// if rank == v["rank"] { |
|
|
|
// amount = v["amount"] |
|
|
|
// break |
|
|
|
// } |
|
|
|
//} |
|
|
|
return |
|
|
|
} |