作废链接和取消订单
This commit is contained in:
@@ -189,6 +189,28 @@ func (h *MerchantHandler) CreateTestOrder(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
type merchantCancelOrderReq struct {
|
||||
Reason string `json:"reason" binding:"required,max=512"`
|
||||
}
|
||||
|
||||
// CancelOrder 商户后台取消订单:全额退还积分并回补库存,取消后订单不可再发货。
|
||||
func (h *MerchantHandler) CancelOrder(c *gin.Context) {
|
||||
var req merchantCancelOrderReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.BadRequest(c, "参数错误:取消原因必填且最长 512 字")
|
||||
return
|
||||
}
|
||||
order, err := h.fulfillmentSvc.CancelOrderByUser(middleware.GetMerchantID(c), middleware.GetUserID(c), c.Param("order_no"), req.Reason)
|
||||
if err != nil {
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, gin.H{
|
||||
"order": order,
|
||||
"refund_amount": order.Amount,
|
||||
})
|
||||
}
|
||||
|
||||
func (h *MerchantHandler) GetDeliveryLink(c *gin.Context) {
|
||||
link, err := h.deliverySvc.GetOrCreateDeliveryLink(middleware.GetMerchantID(c), c.Param("order_no"), requestBaseURL(c))
|
||||
if err != nil {
|
||||
@@ -199,7 +221,7 @@ func (h *MerchantHandler) GetDeliveryLink(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *MerchantHandler) RevokeDeliveryLink(c *gin.Context) {
|
||||
if err := h.deliverySvc.RevokeDeliveryLink(middleware.GetMerchantID(c), c.Param("order_no")); err != nil {
|
||||
if err := h.deliverySvc.RevokeDeliveryLink(middleware.GetMerchantID(c), middleware.GetUserID(c), c.Param("order_no")); err != nil {
|
||||
writeDeliveryError(c, err)
|
||||
return
|
||||
}
|
||||
@@ -207,7 +229,7 @@ func (h *MerchantHandler) RevokeDeliveryLink(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *MerchantHandler) RestoreDeliveryLink(c *gin.Context) {
|
||||
link, err := h.deliverySvc.RestoreDeliveryLink(middleware.GetMerchantID(c), c.Param("order_no"), requestBaseURL(c))
|
||||
link, err := h.deliverySvc.RestoreDeliveryLink(middleware.GetMerchantID(c), middleware.GetUserID(c), c.Param("order_no"), requestBaseURL(c))
|
||||
if err != nil {
|
||||
writeDeliveryError(c, err)
|
||||
return
|
||||
|
||||
@@ -121,7 +121,7 @@ func (h *OpenV1Handler) QueryOrder(c *gin.Context) {
|
||||
}
|
||||
|
||||
type openCancelOrderReq struct {
|
||||
Reason string `json:"reason"`
|
||||
Reason string `json:"reason" binding:"max=512"`
|
||||
}
|
||||
|
||||
func (h *OpenV1Handler) CancelOrder(c *gin.Context) {
|
||||
@@ -129,7 +129,7 @@ func (h *OpenV1Handler) CancelOrder(c *gin.Context) {
|
||||
var req openCancelOrderReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
openlog.Warn(c, "cancel_order bind_fail err=%v", err)
|
||||
response.BadRequest(c, "参数错误")
|
||||
response.BadRequest(c, "参数错误:reason 最长 512 字")
|
||||
return
|
||||
}
|
||||
orderNo := c.Param("order_no")
|
||||
|
||||
Reference in New Issue
Block a user