From 041dd4361602d147208ef099b242a93cedd90e45 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 27 Mar 2023 15:10:21 +0700 Subject: [PATCH] update order client --- client/order.go | 19 +++++++++++++++++++ model/order_request.go | 4 ++++ model/order_response.go | 6 ++++++ subject/order.go | 26 ++++++++++++++------------ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/client/order.go b/client/order.go index a6ab736..f701bd3 100644 --- a/client/order.go +++ b/client/order.go @@ -119,3 +119,22 @@ func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrd } return &r.Data, nil } + +// GetUserTotalWarningOrder ... +func (o Order) GetUserTotalWarningOrder(p model.OrderGetTotalWarningPayload) (*model.OrderGetTotalWarningRes, error) { + msg, err := natsio.GetServer().Request(subject.Order.GetUserTotalWarningOrders, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data model.OrderGetTotalWarningRes `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return &r.Data, nil +} diff --git a/model/order_request.go b/model/order_request.go index bd1fa73..ae70cd8 100644 --- a/model/order_request.go +++ b/model/order_request.go @@ -49,3 +49,7 @@ type OrderSupplierQuery struct { SupplierID string `json:"supplierId"` WarehouseIDs []string `json:"warehouseIDs"` } + +type OrderGetTotalWarningPayload struct { + UserID string `json:"userId"` +} diff --git a/model/order_response.go b/model/order_response.go index c08f87a..d2791c6 100644 --- a/model/order_response.go +++ b/model/order_response.go @@ -33,3 +33,9 @@ type SupplierOrderDelivery struct { Status string `json:"status" enums:"waiting_to_confirm,waiting_to_pick,picking,picked,delay_pickup,pickup_failed,delivering,delay_delivery,delivered,cancelled,delivery_failed,waiting_to_return,returning,delay_return,compensation,returned"` TPLCode string `json:"tplCode" enums:"SLY,GHTK,GHN,SSC,SPY,VTP,SE,NTL,BEST"` } + +// OrderGetTotalWarningRes ... +type OrderGetTotalWarningRes struct { + UserID string `json:"userId"` + TotalWarningOrders int64 `json:"totalWarningOrders"` +} diff --git a/subject/order.go b/subject/order.go index 017f2be..ad7c786 100644 --- a/subject/order.go +++ b/subject/order.go @@ -7,17 +7,19 @@ func getOrderValue(val string) string { } var Order = struct { - UpdateORStatus string - CancelDelivery string - ChangeDeliveryStatus string - UpdateLogisticInfoFailed string - ORNotUpdateStatus string - GetSupplierOrders string + UpdateORStatus string + GetUserTotalWarningOrders string + CancelDelivery string + ChangeDeliveryStatus string + UpdateLogisticInfoFailed string + ORNotUpdateStatus string + GetSupplierOrders string }{ - UpdateORStatus: getOrderValue("update_outbound_request_status"), - CancelDelivery: getOrderValue("cancel_delivery"), - ChangeDeliveryStatus: getOrderValue("change_delivery_status"), - UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), - ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), - GetSupplierOrders: getOrderValue("get_supplier_orders"), + UpdateORStatus: getOrderValue("update_outbound_request_status"), + GetUserTotalWarningOrders: getOrderValue("get_user_total_warning_orders"), + CancelDelivery: getOrderValue("cancel_delivery"), + ChangeDeliveryStatus: getOrderValue("change_delivery_status"), + UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), + ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), + GetSupplierOrders: getOrderValue("get_supplier_orders"), }