check heromint

This commit is contained in:
yangduo 2024-08-21 20:17:48 +08:00
parent 993061616c
commit ded5802429
5 changed files with 107 additions and 74 deletions

View File

@ -1,10 +1,8 @@
package game_switch
import (
"f5"
"main/constant"
"main/service"
"net/http"
"q5"
"github.com/gin-gonic/gin"
)
@ -16,34 +14,10 @@ type GameSwitchApi struct {
func (this *GameSwitchApi) List(c *gin.Context) {
now := f5.GetApp().GetRealSeconds()
if now > this.time+30 {
this.data = map[string]int32{}
this.time = now
f5.GetGoStyleDb().RawQuery(
constant.CONF_DB,
"SELECT * FROM t_game_switch WHERE 1=1",
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 1,
"message": err.Error(),
})
return
}
for ds.Next() {
this.data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open"))
}
})
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "获取成功",
"contributionPoint": "",
"data": this.data,
"data": service.GameSwitches.GetSwitchList(),
})
}

View File

@ -1,33 +1,34 @@
package ingame
import (
"q5"
"f5"
"main/mt"
"main/common"
"main/constant"
. "main/global"
"main/mt"
"marketserver/service"
"q5"
"github.com/gin-gonic/gin"
)
type InGameApi struct {
}
func (this *InGameApi) HeroList(c *gin.Context) {
reqJson := struct {
PageSize interface{} `json:"page_size"`
Cursor interface{} `json:"cursor"`
Search struct {
Cursor interface{} `json:"cursor"`
Search struct {
Name string `json:"name"`
} `json:"search"`
Filter struct {
ItemIds []interface{} `json:"item_ids"`
ItemIds []interface{} `json:"item_ids"`
HeroRanks []interface{} `json:"hero_ranks"`
} `json:"filter"`
Sort struct {
Fields [] struct {
Name string `json:"name"`
Fields []struct {
Name string `json:"name"`
Type interface{} `json:"type"`
} `json:"fields"`
} `json:"sort"`
@ -45,10 +46,10 @@ func (this *InGameApi) HeroList(c *gin.Context) {
}
rspObj := struct {
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"`
Rows [] interface{} `json:"rows"`
ErrCode int32 `json:"errcode"`
ErrMsg string `json:"errmsg"`
Page common.StreamPagination `json:"page"`
Rows []interface{} `json:"rows"`
}{}
q5.NewSlice(&rspObj.Rows, 0, 10)
@ -56,26 +57,31 @@ func (this *InGameApi) HeroList(c *gin.Context) {
heroList,
q5.SafeToInt32(reqJson.PageSize),
q5.SafeToInt64(reqJson.Cursor),
func (kv interface{}) bool {
func(kv interface{}) bool {
return true
},
func (a interface{}, b interface{}) bool {
func(a interface{}, b interface{}) bool {
return true
},
func (p *f5.StreamPagination) {
func(p *f5.StreamPagination) {
rspObj.Page.FillPage(p)
},
func (kv interface{}) {
func(kv interface{}) {
q5.AppendSlice(&rspObj.Rows, kv)
})
c.JSON(200, rspObj)
}
func (this *InGameApi) HeroMint(c *gin.Context) {
if service.GameSwitches.CheckSwitch(constant.GAME_SWITCH_HERO_MINT) == 0 {
f5.RspErr(c, 404, "unavailable request")
return
}
reqJson := struct {
NetId interface{} `json:"net_id"`
To string `json:"to"`
HeroUniIds []string `json:"hero_uniids"`
NetId interface{} `json:"net_id"`
To string `json:"to"`
HeroUniIds []string `json:"hero_uniids"`
}{}
if err := c.ShouldBindJSON(&reqJson); err != nil {
f5.RspErr(c, 401, "params parse error")
@ -99,29 +105,28 @@ func (this *InGameApi) HeroMint(c *gin.Context) {
{"account_id", accountId},
{"idx", uniid},
},
func (err error, ds *f5.DataSet) {
func(err error, ds *f5.DataSet) {
if err != nil {
f5.RspErr(c, 500, "server internal error")
return
}
if ds.Next() {
params := map[string]string{
"c": "OutAppMint",
"a": "mintHero",
"account_id": accountId,
"c": "OutAppMint",
"a": "mintHero",
"account_id": accountId,
"account_address": accountAddress,
"to_address": reqJson.To,
"uniid": uniid,
"to_address": reqJson.To,
"uniid": uniid,
}
rspObj := &struct {
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
TransId string `json:"trans_id"`
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
TransId string `json:"trans_id"`
TransReq interface{} `json:"trans_req"`
}{
}
}{}
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",
mt.Table.Config.GetGameApiUrl()+"/webapp/index.php",
params,
func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil {
@ -146,10 +151,15 @@ func (this *InGameApi) HeroMint(c *gin.Context) {
}
func (this *InGameApi) newHeroMint(c *gin.Context) {
if service.GameSwitches.CheckSwitch(constant.GAME_SWITCH_HERO_MINT) == 0 {
f5.RspErr(c, 404, "unavailable request")
return
}
reqJson := struct {
NetId interface{} `json:"net_id"`
To string `json:"to"`
HeroUniIds []string `json:"hero_uniids"`
NetId interface{} `json:"net_id"`
To string `json:"to"`
HeroUniIds []string `json:"hero_uniids"`
}{}
if err := c.ShouldBindJSON(&reqJson); err != nil {
f5.RspErr(c, 401, "params parse error")
@ -173,29 +183,28 @@ func (this *InGameApi) newHeroMint(c *gin.Context) {
{"account_id", accountId},
{"idx", uniid},
},
func (err error, ds *f5.DataSet) {
func(err error, ds *f5.DataSet) {
if err != nil {
f5.RspErr(c, 500, "server internal error")
return
}
if ds.Next() {
params := map[string]string{
"c": "OutAppMint",
"a": "mintHero",
"account_id": accountId,
"c": "OutAppMint",
"a": "mintHero",
"account_id": accountId,
"account_address": accountAddress,
"to_address": reqJson.To,
"uniid": uniid,
"to_address": reqJson.To,
"uniid": uniid,
}
rspObj := &struct {
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
TransId string `json:"trans_id"`
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
TransId string `json:"trans_id"`
TransReq interface{} `json:"trans_req"`
}{
}
}{}
f5.GetHttpCliMgr().SendGoStyleRequest(
mt.Table.Config.GetGameApiUrl() + "/webapp/index.php",
mt.Table.Config.GetGameApiUrl()+"/webapp/index.php",
params,
func(rsp f5.HttpCliResponse) {
if rsp.GetErr() != nil {

View File

@ -26,3 +26,7 @@ const (
RECHARGE_CURRENCY_MAX_DECIMAL = 6
RECHARGE_CURRENCY_MAX_BUY_NUM = 9999
)
const (
GAME_SWITCH_HERO_MINT = "heroMint"
)

View File

@ -7,6 +7,7 @@ import (
var Contribution = new(contribution)
var _serviceMgr = new(serviceMgr)
var GameSwitches = new(gameSwitch)
func init() {
global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr)

View File

@ -0,0 +1,45 @@
package service
import (
"f5"
"marketserver/constant"
"q5"
)
type gameSwitch struct {
data map[string]int32
time int64
}
func (this *gameSwitch) GetSwitchList() map[string]int32 {
now := f5.GetApp().GetRealSeconds()
if now > this.time+30 {
this.data = map[string]int32{}
this.time = now
f5.GetGoStyleDb().RawQuery(
constant.CONF_DB,
"SELECT * FROM t_game_switch WHERE 1=1",
[]string{},
func(err error, ds *f5.DataSet) {
if err != nil {
return
}
for ds.Next() {
this.data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open"))
}
})
}
return this.data
}
func (this *gameSwitch) CheckSwitch(gs string) int32 {
v, exist := this.data[gs]
if exist {
return v
}
return 0
}