diff --git a/server/marketserver/api/v1/ingame/ingame.go b/server/marketserver/api/v1/ingame/ingame.go index 8fdaeb94..c92992bf 100644 --- a/server/marketserver/api/v1/ingame/ingame.go +++ b/server/marketserver/api/v1/ingame/ingame.go @@ -144,3 +144,77 @@ func (this *InGameApi) HeroMint(c *gin.Context) { } }) } + +func (this *InGameApi) newHeroMint(c *gin.Context) { + reqJson := struct { + 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") + return + } + if reqJson.To == "" { + f5.RspErr(c, 1, "to params error") + return + } + if len(reqJson.HeroUniIds) != 1 { + f5.RspErr(c, 1, "tokens params error") + return + } + uniid := reqJson.HeroUniIds[0] + accountId := c.MustGet("open_id").(string) + accountAddress := c.MustGet("account_address").(string) + f5.GetGoStyleDb().OrmSelectOne( + constant.GAME_DB, + "t_hero", + [][]string{ + {"account_id", accountId}, + {"idx", uniid}, + }, + 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, + "account_address": accountAddress, + "to_address": reqJson.To, + "uniid": uniid, + } + rspObj := &struct { + ErrCode interface{} `json:"errcode"` + ErrMsg string `json:"errmsg"` + TransId string `json:"trans_id"` + TransReq interface{} `json:"trans_req"` + }{ + } + f5.GetHttpCliMgr().SendGoStyleRequest( + "https://game2006api-test.kingsome.cn/webapp/index.php", + params, + func(rsp f5.HttpCliResponse) { + if rsp.GetErr() != nil { + rspObj.ErrCode = 500 + rspObj.ErrMsg = "server internal error1" + c.JSON(200, rspObj) + return + } + if q5.DecodeJson(rsp.GetRawData(), &rspObj) != nil { + rspObj.ErrCode = 500 + rspObj.ErrMsg = "server internal error2" + c.JSON(200, rspObj) + return + } + c.JSON(200, rspObj) + }) + } else { + f5.RspErr(c, 500, "hero not found") + return + } + }) +}