define communication, warehouse func #5
			
				
			
		
		
		
	| 
						 | 
					@ -18,7 +18,7 @@ func GetOrder() Order {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateORStatus ...
 | 
					// UpdateORStatus ...
 | 
				
			||||||
func (w Order) UpdateORStatus(p model.OrderUpdateORStatus) error {
 | 
					func (o Order) UpdateORStatus(p model.OrderUpdateORStatus) error {
 | 
				
			||||||
	msg, err := natsio.GetServer().Request(subject.OrderUpdateORStatus, toBytes(p))
 | 
						msg, err := natsio.GetServer().Request(subject.OrderUpdateORStatus, toBytes(p))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
| 
						 | 
					@ -34,3 +34,19 @@ func (w Order) UpdateORStatus(p model.OrderUpdateORStatus) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// CancelDelivery ...
 | 
				
			||||||
 | 
					func (o Order) CancelDelivery(p model.OrderCancelDelivery) error {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.OrderUpdateORStatus, 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "encoding/json"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// CommonResponseData ...
 | 
				
			||||||
 | 
					type CommonResponseData struct {
 | 
				
			||||||
 | 
						Data  interface{} `json:"data"`
 | 
				
			||||||
 | 
						Error string      `json:"error"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ParseData ...
 | 
				
			||||||
 | 
					func (c CommonResponseData) ParseData(resultPointer interface{}) error {
 | 
				
			||||||
 | 
						b, err := json.Marshal(c.Data)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return json.Unmarshal(b, resultPointer)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -7,3 +7,8 @@ type OrderUpdateORStatus struct {
 | 
				
			||||||
	Status    string `json:"status"`
 | 
						Status    string `json:"status"`
 | 
				
			||||||
	Reason    string `json:"reason"`
 | 
						Reason    string `json:"reason"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// OrderCancelDelivery ...
 | 
				
			||||||
 | 
					type OrderCancelDelivery struct {
 | 
				
			||||||
 | 
						OrderID string `json:"orderId"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,4 +4,5 @@ const orderPrefix = "order_"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	OrderUpdateORStatus = orderPrefix + "update_outbound_request_status"
 | 
						OrderUpdateORStatus = orderPrefix + "update_outbound_request_status"
 | 
				
			||||||
 | 
						OrderCancelDelivery = orderPrefix + "cancel_delivery"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue