diff --git a/bin/payserver/res/wxconfig@wxconfig.json b/bin/payserver/res/wxconfig@wxconfig.json index fcd633f..9333256 100644 --- a/bin/payserver/res/wxconfig@wxconfig.json +++ b/bin/payserver/res/wxconfig@wxconfig.json @@ -13,6 +13,7 @@ "appkey": "CrIjLw1wiExEnNBVqBQqWGMy0yToREC7", "appsecret": "148509437b331acd15580b279e8511af", "zoneid": "1", - "offerid": "1450318181" + "offerid": "1450318181", + "notifyurl": "https://game2004api-test.kingsome.cn/index.php" } ] \ No newline at end of file diff --git a/server/payserver/api/v1/mainservice/mainservice.go b/server/payserver/api/v1/mainservice/mainservice.go index ac1a5e9..830116e 100644 --- a/server/payserver/api/v1/mainservice/mainservice.go +++ b/server/payserver/api/v1/mainservice/mainservice.go @@ -222,8 +222,48 @@ func (this *MainServiceApi) WxNotifyPurchase(c *gin.Context) { orderModel.GameId = int32(gameid) f5.GetSysLog().Debug("notify url:%s, %s", appid, notifyurl) + nowtimestr := q5.SafeToString(f5.GetApp().GetRealSeconds()) + originstr := "account_id=" + orderModel.AccountId + originstr += "&goodsid=" + string(orderModel.ItemId) + originstr += "&orderid=" + orderModel.OrderId + originstr += "&amount=" + q5.SafeToString(payloadobj.GoodsInfo.ActualPrice) + originstr += ":" + nowtimestr + constant.NOFITY_GAMESERVER_SALT + params := map[string]string{ + "c": "Recharge", + "a": "purchaseNotify", + "account_id": orderModel.AccountId, + "orderid": orderModel.OrderId, + "timestamp": nowtimestr, + "goodsid": string(orderModel.ItemId), + "amount": q5.SafeToString(payloadobj.GoodsInfo.ActualPrice), + "sign": q5.Md5Str(originstr), + } + f5.GetHttpCliMgr().SendGoStyleRequest( + notifyurl, + params, + func(hcr f5.HttpCliResponse) { + if hcr.GetErr() != nil { + return + } + + rspObj := struct { + ErrCode int64 `json:"errcode"` + ErrMsg string `json:"errmsg"` + }{} + + f5.GetSysLog().Debug("get game rsp:%s", hcr.GetRawData()) + if json.Unmarshal([]byte(hcr.GetRawData()), &rspObj) != nil { + return + } + + if rspObj.ErrCode == 0 { + orderModel.Status = 2 + orderModel.UpdateFields([]string{"status"}) + rspObj.ErrCode = 0 + rspObj.ErrMsg = "Success" + } + }) } c.JSON(200, rspObj) - } diff --git a/server/payserver/constant/constant.go b/server/payserver/constant/constant.go index 170e05c..8741ee6 100644 --- a/server/payserver/constant/constant.go +++ b/server/payserver/constant/constant.go @@ -55,6 +55,7 @@ const ( const ( GLOBAL_SALT = "f3a6a9a5-217a-4079-ab99-b5d69b8212be" + NOFITY_GAMESERVER_SALT = "NrN3zkVOzXF1vRzUc9eJM9ZKRO5eLooD" ) const (