Compare commits

...

8 Commits

Author SHA1 Message Date
Sinh 1b89d5f368 update onpoint payload 2022-10-05 09:19:54 +07:00
Sinh 86845399e3 update onpoint payload 2022-10-05 09:15:36 +07:00
Sinh baf8a98e35 Merge branch 'master' of github.com:Selly-Modules/natsio into integrate-onpoint 2022-10-04 15:33:53 +07:00
Sinh d06719b0e6 define api get supplier orders 2022-09-22 09:34:16 +07:00
Sinh 73181bc583 add order func 2022-09-21 17:40:49 +07:00
Sinh 9e4e6868a4 add warehouse subject 2022-09-19 15:01:54 +07:00
Sinh b5ba7c7bf1 update OR nats model 2022-09-19 14:18:51 +07:00
Sinh 48e585dc16 update OR request model 2022-09-19 11:10:23 +07:00
6 changed files with 81 additions and 5 deletions

View File

@ -98,3 +98,24 @@ func (o Order) ORNotUpdateStatus(p model.OrderORsNotUpdateStatus) error {
}
return nil
}
// GetSupplierOrders ...
func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrderList, error) {
msg, err := natsio.GetServer().Request(subject.Order.GetSupplierOrders, toBytes(p))
if err != nil {
return nil, err
}
var (
r struct {
Data model.SupplierOrderList `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
}

View File

@ -38,3 +38,13 @@ type OrderUpdateLogisticInfoFailed struct {
type OrderORsNotUpdateStatus struct {
ORCodes []string `json:"orCodes"`
}
// OrderSupplierQuery ...
type OrderSupplierQuery struct {
Limit int64 `json:"limit"`
Page int64 `json:"page"`
FromDate string `json:"fromDate"`
ToDate string `json:"toDate"`
SupplierID string `json:"supplierId"`
WarehouseIDs []string `json:"warehouseIDs"`
}

35
model/order_response.go Normal file
View File

@ -0,0 +1,35 @@
package model
import "time"
// SupplierOrderList ...
type SupplierOrderList struct {
List []SupplierOrder `json:"list"`
Total int64 `json:"total" example:"100"`
Limit int64 `json:"limit" example:"20"`
}
// SupplierOrder ...
type SupplierOrder struct {
ID string `json:"_id"`
Code string `json:"code"`
CreatedAt time.Time `json:"createdAt"`
Status string `json:"status"`
WarehouseStatus string `json:"warehouseStatus"`
Items []SupplierOrderItem `json:"items"`
Delivery SupplierOrderDelivery `json:"delivery"`
}
// SupplierOrderItem ...
type SupplierOrderItem struct {
ID string `json:"_id" example:"1231"`
SupplierSKU string `json:"supplierSku" example:"SUPPLIER_SKU"`
Quantity int64 `json:"quantity" example:"2"`
}
// SupplierOrderDelivery ...
type SupplierOrderDelivery struct {
Code string `json:"code" example:"123187287"`
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"`
}

View File

@ -36,9 +36,11 @@ type InsuranceOpts struct {
// OutboundRequestItem ...
type OutboundRequestItem struct {
SupplierSKU string `json:"supplierSKU"`
Quantity int64 `json:"quantity"`
UnitCode string `json:"unitCode"`
SupplierSKU string `json:"supplierSKU"`
Quantity int64 `json:"quantity"`
UnitCode string `json:"unitCode"`
Price float64 `json:"price"`
Name string `json:"name"`
}
// CustomerInfo ...
@ -63,18 +65,22 @@ type UpdateOutboundRequestLogisticInfoPayload struct {
ShippingLabel string `json:"shippingLabel"`
TrackingCode string `json:"trackingCode"`
ORCode string `json:"orCode"`
TPLCode string `json:"tplCode"`
OrderID string `json:"orderId"`
}
// CancelOutboundRequest ...
type CancelOutboundRequest struct {
ORCode string `json:"orCode"`
Note string `json:"note"`
ORCode string `json:"orCode"`
OrderID string `json:"orderId"`
Note string `json:"note"`
}
// SyncORStatusRequest ...
type SyncORStatusRequest struct {
ORCode string `json:"orCode"`
OrderCode string `json:"orderCode"`
OrderID string `json:"orderId"`
}
// UpdateSupplierIsClosedRequest ...

View File

@ -12,10 +12,12 @@ var Order = struct {
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"),
}

View File

@ -14,6 +14,7 @@ var Warehouse = struct {
SyncORStatus string
WebhookTNC string
WebhookGlobalCare string
WebhookOnPoint string
FindOne string
FindByCondition string
Distinct string
@ -32,6 +33,7 @@ var Warehouse = struct {
SyncORStatus: getWarehouseValue("sync_or_status"),
WebhookTNC: getWarehouseValue("webhook_tnc"),
WebhookGlobalCare: getWarehouseValue("webhook_global_care"),
WebhookOnPoint: getWarehouseValue("webhook_on_point"),
FindOne: getWarehouseValue("find_one"),
FindByCondition: getWarehouseValue("find_all_by_condition"),
Distinct: getWarehouseValue("distinct"),