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) {