From e3566ae9e3a59b8c827ce7b7ca588940a31bda9f Mon Sep 17 00:00:00 2001 From: "qiyunfanbo126.com" <815699> Date: Mon, 9 Sep 2024 10:20:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=87=91=E9=A2=9D=E5=AF=B9?= =?UTF-8?q?=E4=B8=8D=E4=B8=8A=E7=9B=B4=E6=8E=A5=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/constants/common/common.go | 1 + app/http/controllers/front/OrderController.go | 2 +- app/services/OrderService.go | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/constants/common/common.go b/app/constants/common/common.go index d495754..8af757c 100644 --- a/app/constants/common/common.go +++ b/app/constants/common/common.go @@ -19,4 +19,5 @@ const ( ORDER_STATUS_ReFUNDING = 6 ORDER_STATUS_ReFUNDEND = 7 ORDER_STATUS_ReFUNDFAIL = 8 + ORDER_STATUS_TIMEOUT = 9 ) diff --git a/app/http/controllers/front/OrderController.go b/app/http/controllers/front/OrderController.go index ced8565..b01e757 100644 --- a/app/http/controllers/front/OrderController.go +++ b/app/http/controllers/front/OrderController.go @@ -127,6 +127,6 @@ func OrderNotify(c *gin.Context) { c.Header("partnerTxSriNo", time.Now().Format("20060102150405")+utils.RandomNumber(10)) c.Header("reqTime", time.Now().Format("20060102150405")) var request = controllers.GetRequest(c).(*front.YouChuRequest) - response := services.OrderNotify(*request) + response := services.OrderNotify(*request, c) c.JSON(http.StatusOK, response) } diff --git a/app/services/OrderService.go b/app/services/OrderService.go index fda8e82..8c2bfea 100644 --- a/app/services/OrderService.go +++ b/app/services/OrderService.go @@ -2,6 +2,7 @@ package services import ( "encoding/json" + "github.com/gin-gonic/gin" "qteam/app/constants/common" "qteam/app/constants/errorcode" "qteam/app/http/entities/front" @@ -194,7 +195,7 @@ func OrderDelete(id string) error { return err } -func OrderNotify(request front.YouChuRequest) (NotifyResponse front.YouChuOrderNotifyResponse) { +func OrderNotify(request front.YouChuRequest, c *gin.Context) (NotifyResponse front.YouChuOrderNotifyResponse) { requestStr, _ := json.Marshal(request) utils.Log(nil, "订单回调请求--原始数据:", string(requestStr)) response := youchu.DecryptResponse(string(requestStr), true) @@ -213,6 +214,15 @@ func OrderNotify(request front.YouChuRequest) (NotifyResponse front.YouChuOrderN var orderDetail ordersmodel.Orders var order ordersmodel.Orders has, err := ordersmodel.GetInstance().GetDb().Where("voucher_link = ?", "").Where("order_no = ?", YouChuOrderNotifyRequest.ReqTraceId).Get(&orderDetail) + //金额对不上 + if orderDetail.Price != YouChuOrderNotifyRequest.TxnAmt { + ip, _ := c.RemoteIP() + _, err = ordersmodel.GetInstance().GetDb().Where("id = ?", orderDetail.Id).Update(ordersmodel.Orders{State: common.ORDER_STATUS_TIMEOUT}) + if ip != nil { + utils.Log(nil, "OrderNotify-fail", ip.String()) + } + return front.YouChuOrderNotifyResponse{RespCode: "000004", RespMsg: "金额不匹配"} + } if err != nil || !has { utils.Log(nil, "notify err", err, YouChuOrderNotifyRequest.ReqTraceId, YouChuOrderNotifyRequest.OrderNo) return front.YouChuOrderNotifyResponse{RespCode: "000003", RespMsg: "订单不存在"}