From e1bb4b963de5f8fb3a4771559e38d7be0972f79b Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 25 Dec 2024 17:07:06 +0800 Subject: [PATCH] 1 --- server/payserver/api/v1/ingame/ingame.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/server/payserver/api/v1/ingame/ingame.go b/server/payserver/api/v1/ingame/ingame.go index 24365f2..6b40590 100644 --- a/server/payserver/api/v1/ingame/ingame.go +++ b/server/payserver/api/v1/ingame/ingame.go @@ -12,7 +12,7 @@ import ( "github.com/gin-gonic/gin" ) -type InGameApi struct { +type InGameApi struct { } func (this *InGameApi) PreOrder(c *gin.Context) { @@ -129,6 +129,12 @@ func (this *InGameApi) PayDone(c *gin.Context) { return } + sessionkeytime := q5.SafeToInt64(data["update_time"]) + if service.Wxpay.CheckExpireCache(accountId, sessionkeytime) { + f5.RspErr(c, 402, "session expired") + return + } + status := orderModel.Status rspObj := struct { ErrorCode int32 `json:"errcode"` @@ -140,7 +146,7 @@ func (this *InGameApi) PayDone(c *gin.Context) { } for status < 2 { gameid := q5.SafeToInt64(strs[1]) - openid := strs[2] + openid := q5.SafeToString(data["openid"]) sessionkey := q5.SafeToString(data["session_key"]) userip := this.getIP(c) balance, errcode, err := int64(0), int32(0), error(nil) @@ -160,6 +166,8 @@ func (this *InGameApi) PayDone(c *gin.Context) { status = 1 orderModel.Status = 3 orderModel.UpdateFields([]string{"status"}) + + rspObj.Diamond = balance } } @@ -168,8 +176,6 @@ func (this *InGameApi) PayDone(c *gin.Context) { rspObj.ErrMsg = "session overtime" } - rspObj.Diamond = balance - break } @@ -226,10 +232,12 @@ func (this *InGameApi) OrderInfo(c *gin.Context) { ErrMsg string `json:"errmsg"` OrderId string `json:"order_id"` GoodsId int32 `json:"goods_id"` + Count int32 `json:"count"` Status int32 `json:"status"` }{ OrderId: orderModel.OrderId, GoodsId: orderModel.ItemId, + Count: orderModel.SpAmount, Status: orderModel.Status, } @@ -255,7 +263,8 @@ func (this *InGameApi) OrderInfo(c *gin.Context) { errcode = service.Wxpay.QueryPay(openid, gameid, userip, sessionkey, int32(count), orderModel.OrderId) if errcode == constant.WX_ERRCODE_OK { orderModel.Status = 1 - orderModel.UpdateFields([]string{"status"}) + orderModel.SpAmount = int32(count) + orderModel.UpdateFields([]string{"status", "sp_amount"}) } } }