单服黑名单,充值排行

master
czx 2023-08-24 16:09:00 +08:00
parent 69511ce63e
commit b1f2798eed
5 changed files with 86 additions and 5 deletions

View File

@ -591,7 +591,8 @@ func (action *Action) PlayerRegisterInfo(r *ghttp.Request) {
page := g.ListAnyAny{}
//f:=&form
openid := r.Form.Get("openid")
if openid == "" {
id := r.Form.Get("id")
if openid == "" && id == "" {
base.Succ(r,
g.Map{
"page": form.Page,
@ -601,8 +602,12 @@ func (action *Action) PlayerRegisterInfo(r *ghttp.Request) {
})
return
}
result := gameinfo.ModelUserRegisterInfo.FindOne("openId", openid)
var result *mongo.SingleResult
if openid != "" {
result = gameinfo.ModelUserRegisterInfo.FindOne("openId", openid)
} else {
result = gameinfo.ModelUserRegisterInfo.FindOne("_id", id)
}
var userRegisterInfo gameinfo.UserRegisterInfo
err := result.Decode(&userRegisterInfo)
if err != nil {
@ -1122,6 +1127,7 @@ func (action *Action) SaveSingleBlackList(r *ghttp.Request) {
blackList.Id = obj_id
blackList.Uid = uid
blackList.ServerId = serverId
blackList.CreateTime = time.Now().Unix()
if blockTime > 0 {
blackList.UnblockTime = time.Now().Unix() + blockTime*60
} else {
@ -1197,6 +1203,7 @@ func (action *Action) SingleBlackList(r *ghttp.Request) {
dayMap.Set("id", blackList.Id)
dayMap.Set("uid", blackList.Uid)
dayMap.Set("serverName", blackList.ServerName)
dayMap.Set("createTime", time.Unix(blackList.CreateTime, 0).Format(timeLayoutStr))
if blackList.UnblockTime > 0 {
dayMap.Set("unblockTime", time.Unix(blackList.UnblockTime, 0).Format(timeLayoutStr))
} else {
@ -1214,6 +1221,49 @@ func (action *Action) SingleBlackList(r *ghttp.Request) {
})
}
//删除黑名单信息
func (action *Action) DelSingleBlackList(r *ghttp.Request) {
id := r.GetString("id")
obj_id, _ := primitive.ObjectIDFromHex(id)
bs := bson.D{{"_id", obj_id}}
result := gameinfo.ModelSingleBlackList.FindOne("_id", obj_id)
var blackList gameinfo.SingleBlackList
err := result.Decode(&blackList)
if err != nil {
base.Fail(r, "删除失败")
return
}
ages := blackList.Uid + " " + "1"
cmdStr := "addblack"
singleResult := gameinfo.ModelServer.FindOne("server_id", blackList.ServerId)
var serverInfo gameinfo.ServerInfo
err = singleResult.Decode(&serverInfo)
gmip := serverInfo.GMIp
gmport := serverInfo.GMPort
if err != nil {
base.Fail(r, "查询服务器信息出现异常,"+blackList.ServerId)
}
cmd := netutil.Gmcmd{
ServerIp: gmip,
ServerPort: gmport,
Cmd: cmdStr,
Args: ages,
}
fmt.Println(cmd)
res := cmd.Creatcdk() //0 成功
if res == -100 {
base.Resp(r, 1, "thrift解析地址时出错", nil)
} else if res == -101 {
base.Resp(r, 1, "thrift打开服务器socket出错", nil)
} else if res != 0 {
base.Resp(r, 1, "操作失败", nil)
}
deleteResult := gameinfo.ModelSingleBlackList.DelBlackList(bs)
fmt.Println(deleteResult.DeletedCount)
base.Succ(r, g.Map{"code": 0, "result": deleteResult.DeletedCount})
}
//公告信息列表
func (action *Action) NoticeInfo(r *ghttp.Request) {
var timeLayoutStr = "2006-01-02 15:04:05"
@ -2139,8 +2189,28 @@ func (action *Action) GetRechargeRank(r *ghttp.Request) {
continue
}
dataMap := gmap.New()
dataMap.Set("id", rechargeTotal.Id)
dataMap.Set("openId", rechargeTotal.OpenId)
dataMap.Set("totalMoney", rechargeTotal.TotalMoney)
var registerInfo gameinfo.UserRegisterInfo
result := gameinfo.ModelUserRegisterInfo.FindOne("openId", rechargeTotal.OpenId)
err = result.Decode(&registerInfo)
if err != nil {
fmt.Printf("%s", err)
data = append(data, gconv.Map(dataMap))
continue
}
dataMap.Set("id", registerInfo.Id)
if serverId != 0 {
var userInfo gameinfo.UserInfo
result1 := gameinfo.ModelUserInfo.FindOneByBson(bson.D{{"serverId", gconv.String(serverId)}, {"openId", rechargeTotal.OpenId}})
err = result1.Decode(&userInfo)
if err != nil {
fmt.Printf("%s", err)
data = append(data, gconv.Map(dataMap))
continue
}
dataMap.Set("uid", userInfo.Uid)
}
data = append(data, gconv.Map(dataMap))
}
base.Succ(r,

View File

@ -6,7 +6,7 @@ import (
)
type RechargeTotal struct {
Id string `bson:"_id" json:"_id"`
OpenId string `bson:"_id" json:"_id"`
TotalMoney int32 `bson:"totalMoney" json:"money"`
}

View File

@ -12,6 +12,7 @@ type SingleBlackList struct {
ServerName string `bson:"serverName" json:"serverName"`
Uid string `bson:"uid" json:"uid"`
UnblockTime int64 `bson:"unblockTime" json:"unblockTime"`
CreateTime int64 `bson:"createTime" json:"createTime"`
}
var (

View File

@ -35,6 +35,15 @@ func (m *Mgo) FindOne(key string, value interface{}) *mongo.SingleResult {
return singleResult
}
// 查询单个
func (m *Mgo) FindOneByBson(filter interface{}) *mongo.SingleResult {
client := DB.Mongo
collection, _ := client.Database(m.database).Collection(m.collection).Clone()
//collection.
singleResult := collection.FindOne(context.TODO(), filter)
return singleResult
}
// 查询单个
func (m *Mgo) FindOne_ServerId(key string, value interface{}, serverId string) *mongo.SingleResult {
client := DB.Mongo

View File

@ -92,6 +92,7 @@ func bindRouter() {
group.ALL("/game/delwhitelist/{id}", gameAction.DelWhiteList)
group.GET("/game/getblacklistdetail/{id}", gameAction.GetBlackListDetail)
group.ALL("/game/delblacklist/{id}", gameAction.DelBlackList)
group.ALL("/game/delsingleblacklist/{id}", gameAction.DelSingleBlackList)
group.GET("/game/getnoticeinfodetail/{id}", gameAction.GetNoticeInfoDetail)
group.ALL("/game/delnoticeinfo/{id}", gameAction.DelNoticeInfo)
group.GET("/game/setsilence/{id}", gameAction.SetSilence)