支付金额对不上直接失败
This commit is contained in:
parent
c6adfd9a29
commit
e3566ae9e3
|
@ -19,4 +19,5 @@ const (
|
||||||
ORDER_STATUS_ReFUNDING = 6
|
ORDER_STATUS_ReFUNDING = 6
|
||||||
ORDER_STATUS_ReFUNDEND = 7
|
ORDER_STATUS_ReFUNDEND = 7
|
||||||
ORDER_STATUS_ReFUNDFAIL = 8
|
ORDER_STATUS_ReFUNDFAIL = 8
|
||||||
|
ORDER_STATUS_TIMEOUT = 9
|
||||||
)
|
)
|
||||||
|
|
|
@ -127,6 +127,6 @@ func OrderNotify(c *gin.Context) {
|
||||||
c.Header("partnerTxSriNo", time.Now().Format("20060102150405")+utils.RandomNumber(10))
|
c.Header("partnerTxSriNo", time.Now().Format("20060102150405")+utils.RandomNumber(10))
|
||||||
c.Header("reqTime", time.Now().Format("20060102150405"))
|
c.Header("reqTime", time.Now().Format("20060102150405"))
|
||||||
var request = controllers.GetRequest(c).(*front.YouChuRequest)
|
var request = controllers.GetRequest(c).(*front.YouChuRequest)
|
||||||
response := services.OrderNotify(*request)
|
response := services.OrderNotify(*request, c)
|
||||||
c.JSON(http.StatusOK, response)
|
c.JSON(http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
"qteam/app/constants/common"
|
"qteam/app/constants/common"
|
||||||
"qteam/app/constants/errorcode"
|
"qteam/app/constants/errorcode"
|
||||||
"qteam/app/http/entities/front"
|
"qteam/app/http/entities/front"
|
||||||
|
@ -194,7 +195,7 @@ func OrderDelete(id string) error {
|
||||||
return err
|
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)
|
requestStr, _ := json.Marshal(request)
|
||||||
utils.Log(nil, "订单回调请求--原始数据:", string(requestStr))
|
utils.Log(nil, "订单回调请求--原始数据:", string(requestStr))
|
||||||
response := youchu.DecryptResponse(string(requestStr), true)
|
response := youchu.DecryptResponse(string(requestStr), true)
|
||||||
|
@ -213,6 +214,15 @@ func OrderNotify(request front.YouChuRequest) (NotifyResponse front.YouChuOrderN
|
||||||
var orderDetail ordersmodel.Orders
|
var orderDetail ordersmodel.Orders
|
||||||
var order ordersmodel.Orders
|
var order ordersmodel.Orders
|
||||||
has, err := ordersmodel.GetInstance().GetDb().Where("voucher_link = ?", "").Where("order_no = ?", YouChuOrderNotifyRequest.ReqTraceId).Get(&orderDetail)
|
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 {
|
if err != nil || !has {
|
||||||
utils.Log(nil, "notify err", err, YouChuOrderNotifyRequest.ReqTraceId, YouChuOrderNotifyRequest.OrderNo)
|
utils.Log(nil, "notify err", err, YouChuOrderNotifyRequest.ReqTraceId, YouChuOrderNotifyRequest.OrderNo)
|
||||||
return front.YouChuOrderNotifyResponse{RespCode: "000003", RespMsg: "订单不存在"}
|
return front.YouChuOrderNotifyResponse{RespCode: "000003", RespMsg: "订单不存在"}
|
||||||
|
|
Loading…
Reference in New Issue