From ca99cdad86e74e3925032a1c054b4dba54873d8f Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 14:05:17 +0700 Subject: [PATCH 1/2] build auth sms --- subject/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/config.go b/subject/config.go index c838f87..97ce6be 100644 --- a/subject/config.go +++ b/subject/config.go @@ -14,6 +14,7 @@ var prefixes = struct { SupplierUser string SupplierRole string SupplierPermission string + Withdraw string }{ Communication: "communication", Order: "order", @@ -28,4 +29,5 @@ var prefixes = struct { SupplierUser: "supplier_user", SupplierRole: "supplier_role", SupplierPermission: "supplier_permission", + Withdraw: "withdraw", } From 2872e4f75b7358c7690bed687fb506438bac6a90 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 8 Nov 2022 14:15:47 +0700 Subject: [PATCH 2/2] build auth sms --- client/order.go | 21 +++++++++++++++++++++ model/order_request.go | 4 ++++ model/order_response.go | 6 ++++++ subject/order.go | 2 ++ 4 files changed, 33 insertions(+) diff --git a/client/order.go b/client/order.go index a6ab736..a49c68b 100644 --- a/client/order.go +++ b/client/order.go @@ -119,3 +119,24 @@ func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrd } return &r.Data, nil } + +// GetSupplierCash ... +func (o Order) GetSupplierCash(p model.OrderSupplierCashReq) (*model.OrderSupplierCashRes, error) { + msg, err := natsio.GetServer().Request(subject.Order.GetSupplierCash, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.OrderSupplierCashRes `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..a0ff6ee 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 OrderSupplierCashReq struct { + SupplierID string `json:"supplierId"` +} diff --git a/model/order_response.go b/model/order_response.go index c08f87a..59b80d3 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"` } + +type OrderSupplierCashRes struct { + PendingCash float64 `json:"pendingCash"` + WaitingForReconcileCash float64 `json:"waitingForReconcileCash"` + ReconciledCash float64 `json:"reconciledCash"` +} diff --git a/subject/order.go b/subject/order.go index 017f2be..e24e193 100644 --- a/subject/order.go +++ b/subject/order.go @@ -13,6 +13,7 @@ var Order = struct { UpdateLogisticInfoFailed string ORNotUpdateStatus string GetSupplierOrders string + GetSupplierCash string }{ UpdateORStatus: getOrderValue("update_outbound_request_status"), CancelDelivery: getOrderValue("cancel_delivery"), @@ -20,4 +21,5 @@ var Order = struct { UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), GetSupplierOrders: getOrderValue("get_supplier_orders"), + GetSupplierCash: getOrderValue("get_supplier_cash"), }