From 1836b09bcd41f1cb1519066c4f5ddcc100921ea2 Mon Sep 17 00:00:00 2001 From: "qiyunfanbo126.com" <815699> Date: Fri, 18 Oct 2024 10:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/http/controllers/front/OrderController.go | 9 +++++++++ app/http/entities/front/Order.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/app/http/controllers/front/OrderController.go b/app/http/controllers/front/OrderController.go index 0738bed..6d725e2 100644 --- a/app/http/controllers/front/OrderController.go +++ b/app/http/controllers/front/OrderController.go @@ -37,6 +37,8 @@ func OrderList(c *gin.Context) { if count > 0 { linq.From(orderList).SelectT(func(in ordersmodel.OrdersProductsList) (out front.OrderListResponse) { out.ResponseFromDb(in) + out.PlainText = config.GetConf().YouChu.MchtNo + "|" + out.OrderNo + "|" + out.Price + out.Sign = utils.HmacSha256To16(config.GetConf().YouChu.Sha, out.PlainText) return out }).ToSlice(&rsp) } @@ -50,6 +52,11 @@ func OrderQuery(c *gin.Context) { order.Id = orderId order.OrderNo = request.OrderNo order.UserId = controllers.GetUserId(c) + if request.OrderId == "" || request.OrderNo == "" { + utils.Log(nil, "err", "参数不正确") + controllers.Error(c, 500, "订单查询失败") + return + } var OrderQueryResponse front.OrderQueryResponse has, err := services.OrderDetailService(&order) if err != nil { @@ -71,6 +78,8 @@ func OrderQuery(c *gin.Context) { } OrderQueryResponse.ResponseFromDb(order) OrderQueryResponse.MainImage = services.GetProductImage(order.ProductId) + OrderQueryResponse.PlainText = config.GetConf().YouChu.MchtNo + "|" + order.OrderNo + "|" + order.Price + OrderQueryResponse.Sign = utils.HmacSha256To16(config.GetConf().YouChu.Sha, OrderQueryResponse.PlainText) controllers.Success(c, OrderQueryResponse, "请求成功") } else { controllers.HandCodeRes(c, nil, errorcode.NotFound) diff --git a/app/http/entities/front/Order.go b/app/http/entities/front/Order.go index 2a3440c..ec7db5c 100644 --- a/app/http/entities/front/Order.go +++ b/app/http/entities/front/Order.go @@ -37,6 +37,8 @@ type OrderListResponse struct { NotifyUrl string `json:"notify_url"` ExchangeTime string `json:"exchange_time"` Brand string `json:"brand"` + Sign string `json:"sign"` + PlainText string `json:"plain_text"` } func (p *OrderListResponse) ResponseFromDb(l ordersmodel.OrdersProductsList) { @@ -81,6 +83,8 @@ type OrderQueryResponse struct { NotifyUrl string `json:"notify_url"` ExchangeTime string `json:"exchange_time"` Brand string `json:"brand"` + Sign string `json:"sign"` + PlainText string `json:"plain_text"` } func (p *OrderQueryResponse) ResponseFromDb(l ordersmodel.OrdersProductsList) {