新增订单轮询
This commit is contained in:
parent
bc00864737
commit
b04e028d22
|
@ -11,6 +11,7 @@ import (
|
|||
"qteam/app/models/ordersmodel"
|
||||
"qteam/app/services"
|
||||
"qteam/app/utils"
|
||||
"qteam/app/utils/encrypt"
|
||||
"qteam/config"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -75,6 +76,29 @@ func OrderQuery(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
func OrderState(c *gin.Context) {
|
||||
var request = controllers.GetRequest(c).(*front.OrderQueryRequest)
|
||||
orderId, _ := strconv.Atoi(request.OrderId)
|
||||
order := ordersmodel.Orders{}
|
||||
order.Id = orderId
|
||||
order.OrderNo = request.OrderNo
|
||||
order.UserId = controllers.GetUserId(c)
|
||||
var orderQueryResponse front.OrderStateResponse
|
||||
has, err := services.OrderDetailService(&order)
|
||||
if err != nil {
|
||||
controllers.Error(c, 500, "订单查询失败")
|
||||
return
|
||||
}
|
||||
if has {
|
||||
orderQueryResponse.Id = order.Id
|
||||
order.VoucherLink = string(encrypt.AesDecryptCBC(order.VoucherLink, []byte(config.GetConf().OpenApiMarketConfig.SecretKey)))
|
||||
orderQueryResponse.State = order.State
|
||||
controllers.Success(c, orderQueryResponse, "请求成功")
|
||||
} else {
|
||||
controllers.HandCodeRes(c, nil, errorcode.NotFound)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func OrderRefund(c *gin.Context) {
|
||||
var request = controllers.GetRequest(c).(*front.OrderQueryRequest)
|
||||
|
|
|
@ -62,6 +62,12 @@ func (p *OrderListResponse) ResponseFromDb(l ordersmodel.OrdersProductsList) {
|
|||
return
|
||||
}
|
||||
|
||||
type OrderStateResponse struct {
|
||||
Id int `json:"id"`
|
||||
State int `json:"state"`
|
||||
VoucherLink string `json:"voucher_link"`
|
||||
}
|
||||
|
||||
type OrderQueryResponse struct {
|
||||
Id int `json:"id"`
|
||||
OrderNo string `json:"order_no"`
|
||||
|
|
|
@ -24,4 +24,6 @@ var FrontRequestMap = map[string]func() interface{}{
|
|||
common.FRONT_API_V1_Auth + "/order/refund": func() interface{} { return new(front.OrderQueryRequest) },
|
||||
//退款订单
|
||||
common.FRONT_API_V1_Auth + "/order/delete": func() interface{} { return new(front.OrderQueryRequest) },
|
||||
//退款订单
|
||||
common.FRONT_API_V1_Auth + "/order/state": func() interface{} { return new(front.OrderQueryRequest) },
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ func RegisterRoute(router *gin.Engine) {
|
|||
order.POST("/query", front.OrderQuery)
|
||||
order.POST("/refund", front.OrderRefund)
|
||||
order.POST("/delete", front.OrderDelete)
|
||||
order.POST("/state", front.OrderState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue