Merge branch 'integrate-onpoint' into develop

This commit is contained in:
Sinh 2022-10-18 15:05:12 +07:00
commit f3ef44279b
3 changed files with 61 additions and 32 deletions

View File

@ -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
}

View File

@ -105,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"`
}

View File

@ -7,7 +7,6 @@ func getWarehouseValue(val string) string {
} }
var Warehouse = struct { var Warehouse = struct {
WebhookOnPoint string
CreateWarehouseIntoServiceSupplier string CreateWarehouseIntoServiceSupplier string
UpdateWarehouseIntoServiceSupplier string UpdateWarehouseIntoServiceSupplier string
CreateOutboundRequest string CreateOutboundRequest string
@ -17,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
@ -25,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"),
@ -44,4 +45,5 @@ var Warehouse = struct {
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"),
} }