check heromint
This commit is contained in:
parent
993061616c
commit
ded5802429
@ -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(),
|
||||
})
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
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) {
|
||||
@ -72,6 +73,11 @@ func (this *InGameApi) HeroList(c *gin.Context) {
|
||||
}
|
||||
|
||||
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"`
|
||||
@ -118,8 +124,7 @@ func (this *InGameApi) HeroMint(c *gin.Context) {
|
||||
ErrMsg string `json:"errmsg"`
|
||||
TransId string `json:"trans_id"`
|
||||
TransReq interface{} `json:"trans_req"`
|
||||
}{
|
||||
}
|
||||
}{}
|
||||
f5.GetHttpCliMgr().SendGoStyleRequest(
|
||||
mt.Table.Config.GetGameApiUrl()+"/webapp/index.php",
|
||||
params,
|
||||
@ -146,6 +151,11 @@ 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"`
|
||||
@ -192,8 +202,7 @@ func (this *InGameApi) newHeroMint(c *gin.Context) {
|
||||
ErrMsg string `json:"errmsg"`
|
||||
TransId string `json:"trans_id"`
|
||||
TransReq interface{} `json:"trans_req"`
|
||||
}{
|
||||
}
|
||||
}{}
|
||||
f5.GetHttpCliMgr().SendGoStyleRequest(
|
||||
mt.Table.Config.GetGameApiUrl()+"/webapp/index.php",
|
||||
params,
|
||||
|
@ -26,3 +26,7 @@ const (
|
||||
RECHARGE_CURRENCY_MAX_DECIMAL = 6
|
||||
RECHARGE_CURRENCY_MAX_BUY_NUM = 9999
|
||||
)
|
||||
|
||||
const (
|
||||
GAME_SWITCH_HERO_MINT = "heroMint"
|
||||
)
|
||||
|
@ -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)
|
||||
|
45
server/marketserver/service/gameswitch.go
Normal file
45
server/marketserver/service/gameswitch.go
Normal 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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user