add order func

This commit is contained in:
Sinh 2022-08-31 10:53:51 +07:00
parent b9a7d9648e
commit 12afbd81fe
4 changed files with 34 additions and 4 deletions

View File

@ -50,3 +50,19 @@ func (o Order) CancelDelivery(p model.OrderCancelDelivery) error {
}
return nil
}
// ChangeDeliveryStatus ...
func (o Order) ChangeDeliveryStatus(p model.OrderChangeDeliveryStatus) error {
msg, err := natsio.GetServer().Request(subject.Order.ChangeDeliveryStatus, toBytes(p))
if err != nil {
return err
}
var r model.CommonResponseData
if err = json.Unmarshal(msg.Data, &r); err != nil {
return err
}
if r.Error != "" {
return errors.New(r.Error)
}
return nil
}

View File

@ -15,3 +15,8 @@ type DistinctWithField struct {
Conditions interface{} `json:"conditions"`
Filed string `json:"filed"`
}
type ActionBy struct {
ID string `json:"id"`
Name string `json:"name"`
}

View File

@ -13,3 +13,10 @@ type OrderUpdateORStatus struct {
type OrderCancelDelivery struct {
OrderID string `json:"orderId"`
}
// OrderChangeDeliveryStatus ...
type OrderChangeDeliveryStatus struct {
OrderID string `json:"orderId"`
DeliveryStatus string `json:"deliveryStatus"`
ActionBy ActionBy `json:"actionBy"`
}

View File

@ -7,9 +7,11 @@ func getOrderValue(val string) string {
}
var Order = struct {
UpdateORStatus string
CancelDelivery string
UpdateORStatus string
CancelDelivery string
ChangeDeliveryStatus string
}{
UpdateORStatus: getOrderValue("update_outbound_request_status"),
CancelDelivery: getOrderValue("cancel_delivery"),
UpdateORStatus: getOrderValue("update_outbound_request_status"),
CancelDelivery: getOrderValue("cancel_delivery"),
ChangeDeliveryStatus: getOrderValue("change_delivery_status"),
}