修正发货回调流程
This commit is contained in:
@@ -144,74 +144,6 @@ func (h *OpenV1Handler) CancelOrder(c *gin.Context) {
|
||||
response.OK(c, buildOpenOrderResponse(order))
|
||||
}
|
||||
|
||||
type openShipNotifyReq struct {
|
||||
OrderNo string `json:"order_no"`
|
||||
ShipStatus string `json:"ship_status" binding:"required"`
|
||||
ProviderOrderNo string `json:"provider_order_no"`
|
||||
FailReason string `json:"fail_reason"`
|
||||
Result json.RawMessage `json:"result"`
|
||||
}
|
||||
|
||||
func (h *OpenV1Handler) ShipNotify(c *gin.Context) {
|
||||
var req openShipNotifyReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
openlog.Warn(c, "client_ship_notify bind_fail err=%v", err)
|
||||
response.BadRequest(c, "参数错误:ship_status 必填")
|
||||
return
|
||||
}
|
||||
status := ""
|
||||
switch req.ShipStatus {
|
||||
case "processing":
|
||||
status = model.FulfillmentStatusProcessing
|
||||
case "success":
|
||||
status = model.FulfillmentStatusSucceeded
|
||||
case "failed":
|
||||
status = model.FulfillmentStatusFailed
|
||||
default:
|
||||
openlog.Warn(c, "client_ship_notify bad_status=%s", req.ShipStatus)
|
||||
response.BadRequest(c, "ship_status 仅支持 processing、success、failed")
|
||||
return
|
||||
}
|
||||
var result interface{}
|
||||
if len(req.Result) > 0 {
|
||||
if err := json.Unmarshal(req.Result, &result); err != nil {
|
||||
openlog.Warn(c, "client_ship_notify bad_result err=%v", err)
|
||||
response.BadRequest(c, "result 必须是有效 JSON")
|
||||
return
|
||||
}
|
||||
}
|
||||
client := middleware.GetAPIClient(c)
|
||||
orderNo := c.Param("order_no")
|
||||
if orderNo == "" {
|
||||
orderNo = req.OrderNo
|
||||
}
|
||||
if orderNo == "" {
|
||||
openlog.Warn(c, "client_ship_notify missing_order_no")
|
||||
response.BadRequest(c, "order_no 必填")
|
||||
return
|
||||
}
|
||||
openlog.Info(c, "client_ship_notify start order_no=%s ship_status=%s provider_no=%s",
|
||||
orderNo, req.ShipStatus, req.ProviderOrderNo)
|
||||
order, err := h.fulfillmentSvc.UpdateFulfillment(service.FulfillmentUpdateInput{
|
||||
MerchantID: middleware.GetMerchantID(c),
|
||||
APIClientID: client.ID,
|
||||
OrderNo: orderNo,
|
||||
Status: status,
|
||||
ProviderOrderNo: req.ProviderOrderNo,
|
||||
FailureReason: req.FailReason,
|
||||
ResultData: result,
|
||||
})
|
||||
if err != nil {
|
||||
openlog.Warn(c, "client_ship_notify fail order_no=%s ship_status=%s err=%v",
|
||||
orderNo, req.ShipStatus, err)
|
||||
response.BadRequest(c, err.Error())
|
||||
return
|
||||
}
|
||||
openlog.Info(c, "client_ship_notify ok order_no=%s status=%s",
|
||||
order.OrderNo, order.FulfillmentStatus)
|
||||
response.OK(c, buildOpenOrderResponse(order))
|
||||
}
|
||||
|
||||
func (h *OpenV1Handler) GetWallet(c *gin.Context) {
|
||||
openlog.Info(c, "get_wallet start")
|
||||
wallet, err := h.fulfillmentSvc.GetWallet(middleware.GetMerchantID(c))
|
||||
|
||||
Reference in New Issue
Block a user