Merge pull request 'order-warning' (#155) from order-warning into master

Reviewed-on: #155
This commit is contained in:
sinhluu 2023-04-14 02:37:55 +00:00
commit 898ee7822f
6 changed files with 52 additions and 12 deletions

View File

@ -119,3 +119,22 @@ func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrd
} }
return &r.Data, nil return &r.Data, nil
} }
// GetUserTotalWarningOrder ...
func (o Order) GetUserTotalWarningOrder(p model.OrderGetTotalWarningPayload) (*model.OrderGetTotalWarningRes, error) {
msg, err := natsio.GetServer().Request(subject.Order.GetUserTotalWarningOrders, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data model.OrderGetTotalWarningRes `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
}

View File

@ -19,3 +19,9 @@ func (s Socket) EmitSocketEventDataReward(p model.PayloadEmitSocketEvent) error
_, err := natsio.GetServer().Request(subject.Socket.EmitEventReward, toBytes(p)) _, err := natsio.GetServer().Request(subject.Socket.EmitEventReward, toBytes(p))
return err return err
} }
// EmitEventToUser ...
func (s Socket) EmitEventToUser(p model.PayloadEmitSocketEvent) error {
_, err := natsio.GetServer().Request(subject.Socket.EmitEventToUser, toBytes(p))
return err
}

View File

@ -49,3 +49,7 @@ type OrderSupplierQuery struct {
SupplierID string `json:"supplierId"` SupplierID string `json:"supplierId"`
WarehouseIDs []string `json:"warehouseIDs"` WarehouseIDs []string `json:"warehouseIDs"`
} }
type OrderGetTotalWarningPayload struct {
UserID string `json:"userId"`
}

View File

@ -33,3 +33,10 @@ type SupplierOrderDelivery struct {
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"` 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"` TPLCode string `json:"tplCode" enums:"SLY,GHTK,GHN,SSC,SPY,VTP,SE,NTL,BEST"`
} }
// OrderGetTotalWarningRes ...
type OrderGetTotalWarningRes struct {
UserID string `json:"userId"`
TotalWarningOrder int64 `json:"totalWarningOrder"`
Action ActionType `json:"action"`
}

View File

@ -7,17 +7,19 @@ func getOrderValue(val string) string {
} }
var Order = struct { var Order = struct {
UpdateORStatus string UpdateORStatus string
CancelDelivery string GetUserTotalWarningOrders string
ChangeDeliveryStatus string CancelDelivery string
UpdateLogisticInfoFailed string ChangeDeliveryStatus string
ORNotUpdateStatus string UpdateLogisticInfoFailed string
GetSupplierOrders string ORNotUpdateStatus string
GetSupplierOrders string
}{ }{
UpdateORStatus: getOrderValue("update_outbound_request_status"), UpdateORStatus: getOrderValue("update_outbound_request_status"),
CancelDelivery: getOrderValue("cancel_delivery"), GetUserTotalWarningOrders: getOrderValue("get_user_total_warning_orders"),
ChangeDeliveryStatus: getOrderValue("change_delivery_status"), CancelDelivery: getOrderValue("cancel_delivery"),
UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"), ChangeDeliveryStatus: getOrderValue("change_delivery_status"),
ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"), UpdateLogisticInfoFailed: getOrderValue("update_logistic_info_failed"),
GetSupplierOrders: getOrderValue("get_supplier_orders"), ORNotUpdateStatus: getOrderValue("outbound_request_not_update_status"),
GetSupplierOrders: getOrderValue("get_supplier_orders"),
} }

View File

@ -9,6 +9,8 @@ func getSocketValue(val string) string {
// Socket ... // Socket ...
var Socket = struct { var Socket = struct {
EmitEventReward string EmitEventReward string
EmitEventToUser string
}{ }{
EmitEventReward: getSocketValue("emit_event_reward"), EmitEventReward: getSocketValue("emit_event_reward"),
EmitEventToUser: "send_message_to_socket",
} }