diff --git a/server/payserver/api/v1/ingame/ingame.go b/server/payserver/api/v1/ingame/ingame.go index f81f327..bc84975 100644 --- a/server/payserver/api/v1/ingame/ingame.go +++ b/server/payserver/api/v1/ingame/ingame.go @@ -15,7 +15,7 @@ import ( type InGameApi struct { } -func (this *InGameApi) PreOrder(c *gin.Context) { +func (iga *InGameApi) PreOrder(c *gin.Context) { reqJson := struct { AccountId string `json:"account_id" binding:"required"` SessionId string `json:"session_id" binding:"required"` @@ -26,7 +26,7 @@ func (this *InGameApi) PreOrder(c *gin.Context) { return } - data, ret := this.checkSessionData(c, reqJson.AccountId) + data, ret := iga.checkSessionData(c, reqJson.AccountId) if !ret { return } @@ -37,7 +37,7 @@ func (this *InGameApi) PreOrder(c *gin.Context) { order.OrderId = q5.ToString(f5.GetApp().NewLockNodeUuid()) order.ItemId = reqJson.GoodsId order.GameId = q5.SafeToInt32(data["gameid"]) - order.IP = this.getIP(c) + order.IP = iga.getIP(c) order.CreateTime = nowTime order.ModifyTime = nowTime @@ -60,17 +60,17 @@ func (this *InGameApi) PreOrder(c *gin.Context) { c.JSON(200, rspObj) } -func (this *InGameApi) ServerPreOrder(c *gin.Context) { +func (iga *InGameApi) ServerPreOrder(c *gin.Context) { accountId := c.Query("account_id") goodsid := c.Query("goods_id") sessionid := c.Query("session_id") sign := c.Query("sign") - if strings.ToLower(q5.Md5Str(accountId+goodsid+constant.GLOBAL_SALT+sessionid)) != strings.ToLower(sign) { + if strings.EqualFold(q5.Md5Str(accountId+goodsid+constant.GLOBAL_SALT+sessionid), strings.ToLower(sign)) { f5.RspErr(c, 401, "sign err") return } - data, ret := this.checkSessionData(c, accountId) + data, ret := iga.checkSessionData(c, accountId) if !ret { return } @@ -104,12 +104,12 @@ func (this *InGameApi) ServerPreOrder(c *gin.Context) { c.JSON(200, rspObj) } -func (this *InGameApi) PayDone(c *gin.Context) { +func (iga *InGameApi) PayDone(c *gin.Context) { accountId := c.Query("account_id") orderid := c.Query("order_id") sessionid := c.Query("session_id") sign := c.Query("sign") - if strings.ToLower(q5.Md5Str(accountId+orderid+constant.GLOBAL_SALT+sessionid)) != strings.ToLower(sign) { + if strings.EqualFold(q5.Md5Str(accountId+orderid+constant.GLOBAL_SALT+sessionid), strings.ToLower(sign)) { f5.RspErr(c, 401, "sign err") return } @@ -123,7 +123,7 @@ func (this *InGameApi) PayDone(c *gin.Context) { return } - data, ret := this.checkSessionData(c, accountId) + data, ret := iga.checkSessionData(c, accountId) if !ret { return } @@ -142,7 +142,7 @@ func (this *InGameApi) PayDone(c *gin.Context) { if status < 2 { gameid := q5.SafeToInt64(data["gameid"]) openid := q5.SafeToString(data["openid"]) - userip := this.getIP(c) + userip := iga.getIP(c) balance, errcode, err := int64(0), int32(0), error(nil) if status == 0 { balance, errcode, err = service.Wxpay.QueryBalance(openid, gameid, userip, sessionkey) @@ -174,7 +174,7 @@ func (this *InGameApi) PayDone(c *gin.Context) { c.JSON(200, rspObj) } -func (this *InGameApi) ServerPrePurchase(c *gin.Context) { +func (iga *InGameApi) ServerPrePurchase(c *gin.Context) { req := struct { AccountId string `binding:"required" json:"account_id"` SessionId string `binding:"required" json:"session_id"` @@ -205,7 +205,7 @@ func (this *InGameApi) ServerPrePurchase(c *gin.Context) { return } - data, ret := this.checkSessionData(c, req.AccountId) + data, ret := iga.checkSessionData(c, req.AccountId) if !ret { return } @@ -259,7 +259,7 @@ func (this *InGameApi) ServerPrePurchase(c *gin.Context) { c.JSON(200, rspObj) } -func (this *InGameApi) OrderInfo(c *gin.Context) { +func (iga *InGameApi) OrderInfo(c *gin.Context) { reqJson := struct { AccountId string `json:"account_id" binding:"required"` SessionId string `json:"session_id" binding:"required"` @@ -270,7 +270,7 @@ func (this *InGameApi) OrderInfo(c *gin.Context) { return } - data, ret := this.checkSessionData(c, reqJson.AccountId) + data, ret := iga.checkSessionData(c, reqJson.AccountId) if !ret { return } @@ -305,7 +305,7 @@ func (this *InGameApi) OrderInfo(c *gin.Context) { if orderModel.Status == 0 { gameid := q5.SafeToInt64(data["gameid"]) openid := q5.SafeToString(data["openid"]) - userip := this.getIP(c) + userip := iga.getIP(c) sessionkey := q5.SafeToString(data["session_key"]) balance, errcode, err := service.Wxpay.QueryBalance(openid, gameid, userip, sessionkey) if err != nil { @@ -339,7 +339,7 @@ func (this *InGameApi) OrderInfo(c *gin.Context) { } } -func (this *InGameApi) OtherOrder(c *gin.Context) { +func (iga *InGameApi) OtherOrder(c *gin.Context) { reqJson := struct { AccountId string `json:"account_id" binding:"required"` SessionId string `json:"session_id" binding:"required"` @@ -349,7 +349,7 @@ func (this *InGameApi) OtherOrder(c *gin.Context) { return } - data, ret := this.checkSessionData(c, reqJson.AccountId) + data, ret := iga.checkSessionData(c, reqJson.AccountId) if !ret { return } @@ -364,7 +364,7 @@ func (this *InGameApi) OtherOrder(c *gin.Context) { gameid := q5.SafeToInt64(data["gameid"]) openid := q5.SafeToString(data["openid"]) - userip := this.getIP(c) + userip := iga.getIP(c) balance, errcode, err := service.Wxpay.QueryBalance(openid, gameid, userip, sessionkey) if err != nil { f5.RspErr(c, 500, "wx server busy") @@ -381,7 +381,7 @@ func (this *InGameApi) OtherOrder(c *gin.Context) { if errcode == constant.WX_ERRCODE_OK { order.GameId = int32(gameid) order.Channel = q5.SafeToInt32(data["channel"]) - order.IP = this.getIP(c) + order.IP = iga.getIP(c) order.Status = 2 order.SpOthers = int32(balance) order.CreateTime = nowTime @@ -401,7 +401,7 @@ func (this *InGameApi) OtherOrder(c *gin.Context) { c.JSON(200, rspObj) } -func (this *InGameApi) QueryPay(c *gin.Context) { +func (iga *InGameApi) QueryPay(c *gin.Context) { reqJson := struct { AccountId string `json:"account_id" binding:"required"` SessionId string `json:"session_id" binding:"required"` @@ -412,7 +412,7 @@ func (this *InGameApi) QueryPay(c *gin.Context) { return } - _, ret := this.checkSessionData(c, reqJson.AccountId) + _, ret := iga.checkSessionData(c, reqJson.AccountId) if !ret { return }