Merge branch 'order-warning' into develop

This commit is contained in:
Sinh 2023-03-27 15:51:46 +07:00
commit f6447a771a
6 changed files with 53 additions and 14 deletions

View File

@ -140,3 +140,22 @@ func (o Order) GetSupplierCash(p model.OrderSupplierCashReq) (*model.OrderSuppli
}
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))
return err
}
// EmitEventToUser ...
func (s Socket) EmitEventToUser(p model.PayloadEmitSocketEvent) error {
_, err := natsio.GetServer().Request(subject.Socket.EmitEventToUser, toBytes(p))
return err
}

View File

@ -53,3 +53,7 @@ type OrderSupplierQuery struct {
type OrderSupplierCashReq struct {
SupplierID string `json:"supplierId"`
}
type OrderGetTotalWarningPayload struct {
UserID string `json:"userId"`
}

View File

@ -39,3 +39,9 @@ type OrderSupplierCashRes struct {
WaitingForReconcileCash float64 `json:"waitingForReconcileCash"`
ReconciledCash float64 `json:"reconciledCash"`
}
// OrderGetTotalWarningRes ...
type OrderGetTotalWarningRes struct {
UserID string `json:"userId"`
TotalWarningOrders int64 `json:"totalWarningOrders"`
}

View File

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

View File

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