refactor-location #134
			
				
			
		
		
		
	|  | @ -98,3 +98,24 @@ func (o Order) ORNotUpdateStatus(p model.OrderORsNotUpdateStatus) error { | ||||||
| 	} | 	} | ||||||
| 	return nil | 	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 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ package client | ||||||
| import ( | import ( | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"errors" | 	"errors" | ||||||
|  | 	"fmt" | ||||||
| 
 | 
 | ||||||
| 	"git.selly.red/Selly-Modules/natsio" | 	"git.selly.red/Selly-Modules/natsio" | ||||||
| 	"git.selly.red/Selly-Modules/natsio/model" | 	"git.selly.red/Selly-Modules/natsio/model" | ||||||
|  | @ -163,3 +164,21 @@ func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWareho | ||||||
| 	} | 	} | ||||||
| 	return r.Data, nil | 	return r.Data, nil | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // UpdateORDeliveryStatus ...
 | ||||||
|  | func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatus) error { | ||||||
|  | 	msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p)) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	var r struct { | ||||||
|  | 		Error string `json:"error"` | ||||||
|  | 	} | ||||||
|  | 	if err = json.Unmarshal(msg.Data, &r); err != nil { | ||||||
|  | 		return fmt.Errorf("nats: update_or_delivery_status %v", err) | ||||||
|  | 	} | ||||||
|  | 	if r.Error != "" { | ||||||
|  | 		return errors.New(r.Error) | ||||||
|  | 	} | ||||||
|  | 	return nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ package model | ||||||
| 
 | 
 | ||||||
| // OrderUpdateORStatus ...
 | // OrderUpdateORStatus ...
 | ||||||
| type OrderUpdateORStatus struct { | type OrderUpdateORStatus struct { | ||||||
|  | 	ID             string      `json:"id"` | ||||||
| 	OrderCode      string      `json:"orderCode"` | 	OrderCode      string      `json:"orderCode"` | ||||||
| 	ORCode         string      `json:"orCode"` | 	ORCode         string      `json:"orCode"` | ||||||
| 	Status         string      `json:"status"` | 	Status         string      `json:"status"` | ||||||
|  | @ -38,3 +39,13 @@ type OrderUpdateLogisticInfoFailed struct { | ||||||
| type OrderORsNotUpdateStatus struct { | type OrderORsNotUpdateStatus struct { | ||||||
| 	ORCodes []string `json:"orCodes"` | 	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"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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"` | ||||||
|  | } | ||||||
|  | @ -13,6 +13,7 @@ type OutboundRequestPayload struct { | ||||||
| 	Customer      CustomerInfo          `json:"customer"` | 	Customer      CustomerInfo          `json:"customer"` | ||||||
| 	Items         []OutboundRequestItem `json:"items"` | 	Items         []OutboundRequestItem `json:"items"` | ||||||
| 	Insurance     *InsuranceOpts        `json:"insurance"` | 	Insurance     *InsuranceOpts        `json:"insurance"` | ||||||
|  | 	PaymentMethod string                `json:"paymentMethod"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // InsuranceOpts ...
 | // InsuranceOpts ...
 | ||||||
|  | @ -39,6 +40,8 @@ type OutboundRequestItem struct { | ||||||
| 	SupplierSKU string  `json:"supplierSKU"` | 	SupplierSKU string  `json:"supplierSKU"` | ||||||
| 	Quantity    int64   `json:"quantity"` | 	Quantity    int64   `json:"quantity"` | ||||||
| 	UnitCode    string  `json:"unitCode"` | 	UnitCode    string  `json:"unitCode"` | ||||||
|  | 	Price       float64 `json:"price"` | ||||||
|  | 	Name        string  `json:"name"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // CustomerInfo ...
 | // CustomerInfo ...
 | ||||||
|  | @ -63,11 +66,14 @@ type UpdateOutboundRequestLogisticInfoPayload struct { | ||||||
| 	ShippingLabel string `json:"shippingLabel"` | 	ShippingLabel string `json:"shippingLabel"` | ||||||
| 	TrackingCode  string `json:"trackingCode"` | 	TrackingCode  string `json:"trackingCode"` | ||||||
| 	ORCode        string `json:"orCode"` | 	ORCode        string `json:"orCode"` | ||||||
|  | 	TPLCode       string `json:"tplCode"` | ||||||
|  | 	OrderID       string `json:"orderId"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // CancelOutboundRequest ...
 | // CancelOutboundRequest ...
 | ||||||
| type CancelOutboundRequest struct { | type CancelOutboundRequest struct { | ||||||
| 	ORCode  string `json:"orCode"` | 	ORCode  string `json:"orCode"` | ||||||
|  | 	OrderID string `json:"orderId"` | ||||||
| 	Note    string `json:"note"` | 	Note    string `json:"note"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -75,6 +81,7 @@ type CancelOutboundRequest struct { | ||||||
| type SyncORStatusRequest struct { | type SyncORStatusRequest struct { | ||||||
| 	ORCode    string `json:"orCode"` | 	ORCode    string `json:"orCode"` | ||||||
| 	OrderCode string `json:"orderCode"` | 	OrderCode string `json:"orderCode"` | ||||||
|  | 	OrderID   string `json:"orderId"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // UpdateSupplierIsClosedRequest ...
 | // UpdateSupplierIsClosedRequest ...
 | ||||||
|  | @ -98,3 +105,11 @@ type GetWarehousesRequest struct { | ||||||
| 	Page  int64 `json:"page"` | 	Page  int64 `json:"page"` | ||||||
| 	Limit int64 `json:"limit"` | 	Limit int64 `json:"limit"` | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // WarehouseORUpdateDeliveryStatus ...
 | ||||||
|  | type WarehouseORUpdateDeliveryStatus struct { | ||||||
|  | 	ORCode         string `json:"orCode"` | ||||||
|  | 	OrderCode      string `json:"orderCode"` | ||||||
|  | 	OrderID        string `json:"orderId"` | ||||||
|  | 	DeliveryStatus string `json:"deliveryStatus"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -12,10 +12,12 @@ var Order = struct { | ||||||
| 	ChangeDeliveryStatus     string | 	ChangeDeliveryStatus     string | ||||||
| 	UpdateLogisticInfoFailed string | 	UpdateLogisticInfoFailed string | ||||||
| 	ORNotUpdateStatus        string | 	ORNotUpdateStatus        string | ||||||
|  | 	GetSupplierOrders        string | ||||||
| }{ | }{ | ||||||
| 	UpdateORStatus:           getOrderValue("update_outbound_request_status"), | 	UpdateORStatus:           getOrderValue("update_outbound_request_status"), | ||||||
| 	CancelDelivery:           getOrderValue("cancel_delivery"), | 	CancelDelivery:           getOrderValue("cancel_delivery"), | ||||||
| 	ChangeDeliveryStatus:     getOrderValue("change_delivery_status"), | 	ChangeDeliveryStatus:     getOrderValue("change_delivery_status"), | ||||||
| 	UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), | 	UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), | ||||||
| 	ORNotUpdateStatus:        getOrderValue("outbound_request_not_update_status"), | 	ORNotUpdateStatus:        getOrderValue("outbound_request_not_update_status"), | ||||||
|  | 	GetSupplierOrders:        getOrderValue("get_supplier_orders"), | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ var Warehouse = struct { | ||||||
| 	SyncORStatus                       string | 	SyncORStatus                       string | ||||||
| 	WebhookTNC                         string | 	WebhookTNC                         string | ||||||
| 	WebhookGlobalCare                  string | 	WebhookGlobalCare                  string | ||||||
|  | 	WebhookOnPoint                     string | ||||||
| 	FindOne                            string | 	FindOne                            string | ||||||
| 	FindByCondition                    string | 	FindByCondition                    string | ||||||
| 	Distinct                           string | 	Distinct                           string | ||||||
|  | @ -24,6 +25,7 @@ var Warehouse = struct { | ||||||
| 	AfterCreateWarehouse               string | 	AfterCreateWarehouse               string | ||||||
| 	UpdateIsClosedSupplier             string | 	UpdateIsClosedSupplier             string | ||||||
| 	GetWarehouses                      string | 	GetWarehouses                      string | ||||||
|  | 	UpdateORDeliveryStatus             string | ||||||
| }{ | }{ | ||||||
| 	CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), | 	CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), | ||||||
| 	UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), | 	UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), | ||||||
|  | @ -36,10 +38,12 @@ var Warehouse = struct { | ||||||
| 	SyncORStatus:                       getWarehouseValue("sync_or_status"), | 	SyncORStatus:                       getWarehouseValue("sync_or_status"), | ||||||
| 	WebhookTNC:                         getWarehouseValue("webhook_tnc"), | 	WebhookTNC:                         getWarehouseValue("webhook_tnc"), | ||||||
| 	WebhookGlobalCare:                  getWarehouseValue("webhook_global_care"), | 	WebhookGlobalCare:                  getWarehouseValue("webhook_global_care"), | ||||||
|  | 	WebhookOnPoint:                     getWarehouseValue("webhook_on_point"), | ||||||
| 	FindOne:                            getWarehouseValue("find_one"), | 	FindOne:                            getWarehouseValue("find_one"), | ||||||
| 	FindByCondition:                    getWarehouseValue("find_all_by_condition"), | 	FindByCondition:                    getWarehouseValue("find_all_by_condition"), | ||||||
| 	Distinct:                           getWarehouseValue("distinct"), | 	Distinct:                           getWarehouseValue("distinct"), | ||||||
| 	Count:                              getWarehouseValue("count"), | 	Count:                              getWarehouseValue("count"), | ||||||
| 	UpdateIsClosedSupplier:             getWarehouseValue("update_is_closed_supplier"), | 	UpdateIsClosedSupplier:             getWarehouseValue("update_is_closed_supplier"), | ||||||
| 	GetWarehouses:                      getWarehouseValue("get_warehouses"), | 	GetWarehouses:                      getWarehouseValue("get_warehouses"), | ||||||
|  | 	UpdateORDeliveryStatus:             getWarehouseValue("update_or_delivery_status"), | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue