sync data warehouse into service supplier

This commit is contained in:
QuanTT0110 2022-11-08 11:05:34 +07:00
parent 708fad7c59
commit ae16428783
3 changed files with 36 additions and 64 deletions

View File

@ -101,27 +101,9 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod
return r.Data, nil return r.Data, nil
} }
// CreateWarehouseIntoServiceSupplier ... // SyncWarehouseIntoServiceSupplier ...
func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { func (s Supplier) SyncWarehouseIntoServiceSupplier(p model.SyncSupplierWarehousePayload) error {
msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) msg, err := natsio.GetServer().Request(subject.Warehouse.SyncWarehouseIntoServiceSupplier, toBytes(p))
if err != nil {
return err
}
var r struct {
Error string `json:"error"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}
// UpdateWarehouseIntoServiceSupplier ...
func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWarehousePayload) error {
msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseIntoServiceSupplier, toBytes(p))
if err != nil { if err != nil {
return err return err
} }

View File

@ -23,15 +23,7 @@ type SupplierRequestPayload struct {
ContractStatus string ContractStatus string
} }
type CreateSupplierWarehousePayload struct { type SyncSupplierWarehousePayload struct {
Supplier string `json:"supplier"`
Warehouse string `json:"warehouse"`
ProvinceCode int `json:"provinceCode"`
DistrictCode int `json:"districtCode"`
WardCode int `json:"wardCode"`
}
type UpdateSupplierWarehousePayload struct {
Supplier string `json:"supplier"` Supplier string `json:"supplier"`
Warehouse string `json:"warehouse"` Warehouse string `json:"warehouse"`
ProvinceCode int `json:"provinceCode"` ProvinceCode int `json:"provinceCode"`

View File

@ -7,8 +7,7 @@ func getWarehouseValue(val string) string {
} }
var Warehouse = struct { var Warehouse = struct {
CreateWarehouseIntoServiceSupplier string SyncWarehouseIntoServiceSupplier string
UpdateWarehouseIntoServiceSupplier string
CreateOutboundRequest string CreateOutboundRequest string
UpdateOutboundRequestLogistic string UpdateOutboundRequestLogistic string
CancelOutboundRequest string CancelOutboundRequest string
@ -25,8 +24,7 @@ var Warehouse = struct {
UpdateIsClosedSupplier string UpdateIsClosedSupplier string
GetWarehouses string GetWarehouses string
}{ }{
CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), SyncWarehouseIntoServiceSupplier: getWarehouseValue("sync_warehouse_into_service_supplier"),
UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"),
AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"),
AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"),
CreateOutboundRequest: getWarehouseValue("create_outbound_request"), CreateOutboundRequest: getWarehouseValue("create_outbound_request"),