From 48e585dc163b66da7b1a279b0974c1515687c4a3 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 11:10:23 +0700 Subject: [PATCH 01/59] update OR request model --- model/warehouse_request.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 543fc68..4e15ff7 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -29,9 +29,11 @@ type InsuranceOpts struct { // OutboundRequestItem ... type OutboundRequestItem struct { - SupplierSKU string `json:"supplierSKU"` - Quantity int64 `json:"quantity"` - UnitCode string `json:"unitCode"` + SupplierSKU string `json:"supplierSKU"` + Quantity int64 `json:"quantity"` + UnitCode string `json:"unitCode"` + Price float64 `json:"price"` + Name string `json:"name"` } // CustomerInfo ... From b5ba7c7bf1866b83b1062cc7545a43a37fe0e691 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 14:18:51 +0700 Subject: [PATCH 02/59] update OR nats model --- model/warehouse_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 4e15ff7..7bf920f 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -58,6 +58,7 @@ type UpdateOutboundRequestLogisticInfoPayload struct { ShippingLabel string `json:"shippingLabel"` TrackingCode string `json:"trackingCode"` ORCode string `json:"orCode"` + TPLCode string `json:"tplCode"` } // CancelOutboundRequest ... From 9e4e6868a495e446c59d3ac82d033fafb256d340 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 15:01:54 +0700 Subject: [PATCH 03/59] add warehouse subject --- subject/warehouse.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/warehouse.go b/subject/warehouse.go index 5d0a81c..b6be006 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -14,6 +14,7 @@ var Warehouse = struct { SyncORStatus string WebhookTNC string WebhookGlobalCare string + WebhookOnPoint string FindOne string FindByCondition string Distinct string @@ -30,6 +31,7 @@ var Warehouse = struct { SyncORStatus: getWarehouseValue("sync_or_status"), WebhookTNC: getWarehouseValue("webhook_tnc"), WebhookGlobalCare: getWarehouseValue("webhook_global_care"), + WebhookOnPoint: getWarehouseValue("webhook_on_point"), FindOne: getWarehouseValue("find_one"), FindByCondition: getWarehouseValue("find_all_by_condition"), Distinct: getWarehouseValue("distinct"), From 73181bc5836149a8c1cc07f0ae7c4af08476b162 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 21 Sep 2022 17:40:49 +0700 Subject: [PATCH 04/59] add order func --- client/order.go | 21 +++++++++++++++++++++ model/order_request.go | 10 ++++++++++ model/order_response.go | 34 ++++++++++++++++++++++++++++++++++ subject/order.go | 2 ++ 4 files changed, 67 insertions(+) create mode 100644 model/order_response.go diff --git a/client/order.go b/client/order.go index 7d23cee..db325a1 100644 --- a/client/order.go +++ b/client/order.go @@ -98,3 +98,24 @@ func (o Order) ORNotUpdateStatus(p model.OrderORsNotUpdateStatus) error { } return nil } + +// GetSupplierOrders ... +func (o Order) GetSupplierOrders(p model.OrderSupplierQuery) (*model.SupplierOrderList, error) { + msg, err := natsio.GetServer().Request(subject.Order.GetSupplierOrders, toBytes(p)) + if err != nil { + return nil, err + } + var ( + r struct { + Data model.SupplierOrderList `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 +} diff --git a/model/order_request.go b/model/order_request.go index af4989d..ba920f4 100644 --- a/model/order_request.go +++ b/model/order_request.go @@ -38,3 +38,13 @@ type OrderUpdateLogisticInfoFailed struct { type OrderORsNotUpdateStatus struct { ORCodes []string `json:"orCodes"` } + +// OrderSupplierQuery ... +type OrderSupplierQuery struct { + Limit int64 `json:"limit"` + Page int64 `json:"page"` + FromDate string `json:"fromDate"` + ToDate string `json:"toDate"` + SupplierID string `json:"supplierId"` + WarehouseIDs []string `json:"warehouseIDs"` +} diff --git a/model/order_response.go b/model/order_response.go new file mode 100644 index 0000000..cbde555 --- /dev/null +++ b/model/order_response.go @@ -0,0 +1,34 @@ +package model + +import "time" + +// SupplierOrderList ... +type SupplierOrderList struct { + List []SupplierOrder `json:"list"` + Total int64 `json:"total" example:"100"` + Limit int64 `json:"limit" example:"20"` +} + +// SupplierOrder ... +type SupplierOrder struct { + ID string `json:"_id"` + Code string `json:"code"` + CreatedAt time.Time `json:"createdAt"` + Status string `json:"status"` + Items []SupplierOrderItem `json:"items"` + Delivery SupplierOrderDelivery `json:"delivery"` +} + +// SupplierOrderItem ... +type SupplierOrderItem struct { + ID string `json:"_id" example:"1231"` + SupplierSKU string `json:"supplierSku" example:"SUPPLIER_SKU"` + Quantity int64 `json:"quantity" example:"2"` +} + +// SupplierOrderDelivery ... +type SupplierOrderDelivery struct { + Code string `json:"code" example:"123187287"` + 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"` +} diff --git a/subject/order.go b/subject/order.go index 1452de3..017f2be 100644 --- a/subject/order.go +++ b/subject/order.go @@ -12,10 +12,12 @@ var Order = struct { ChangeDeliveryStatus string UpdateLogisticInfoFailed string ORNotUpdateStatus string + GetSupplierOrders 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"), } From d06719b0e6b4377ebbd82e1cd9da5fd12cafd2f2 Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 22 Sep 2022 09:34:16 +0700 Subject: [PATCH 05/59] define api get supplier orders --- model/order_response.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/model/order_response.go b/model/order_response.go index cbde555..c08f87a 100644 --- a/model/order_response.go +++ b/model/order_response.go @@ -11,12 +11,13 @@ type SupplierOrderList struct { // SupplierOrder ... type SupplierOrder struct { - ID string `json:"_id"` - Code string `json:"code"` - CreatedAt time.Time `json:"createdAt"` - Status string `json:"status"` - Items []SupplierOrderItem `json:"items"` - Delivery SupplierOrderDelivery `json:"delivery"` + ID string `json:"_id"` + Code string `json:"code"` + CreatedAt time.Time `json:"createdAt"` + Status string `json:"status"` + WarehouseStatus string `json:"warehouseStatus"` + Items []SupplierOrderItem `json:"items"` + Delivery SupplierOrderDelivery `json:"delivery"` } // SupplierOrderItem ... From 86845399e3dadfd3fffb251f3ce9cb1fe112470d Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 5 Oct 2022 09:15:36 +0700 Subject: [PATCH 06/59] update onpoint payload --- model/warehouse_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 5563ef4..7c418a7 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -66,6 +66,7 @@ type UpdateOutboundRequestLogisticInfoPayload struct { TrackingCode string `json:"trackingCode"` ORCode string `json:"orCode"` TPLCode string `json:"tplCode"` + OrderCode string `json:"orderCode"` } // CancelOutboundRequest ... From 1b89d5f3684a21b701d8ba32a0c07339c0f25959 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 5 Oct 2022 09:19:54 +0700 Subject: [PATCH 07/59] update onpoint payload --- model/warehouse_request.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 7c418a7..b8ad0ff 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -66,19 +66,21 @@ type UpdateOutboundRequestLogisticInfoPayload struct { TrackingCode string `json:"trackingCode"` ORCode string `json:"orCode"` TPLCode string `json:"tplCode"` - OrderCode string `json:"orderCode"` + OrderID string `json:"orderId"` } // CancelOutboundRequest ... type CancelOutboundRequest struct { - ORCode string `json:"orCode"` - Note string `json:"note"` + ORCode string `json:"orCode"` + OrderID string `json:"orderId"` + Note string `json:"note"` } // SyncORStatusRequest ... type SyncORStatusRequest struct { ORCode string `json:"orCode"` OrderCode string `json:"orderCode"` + OrderID string `json:"orderId"` } // UpdateSupplierIsClosedRequest ... From 22396d8f40455bded146430a9de76a8aeafb53a4 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 17 Oct 2022 14:32:14 +0700 Subject: [PATCH 08/59] update nats payload --- model/warehouse_request.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index b8ad0ff..4cd857a 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -2,17 +2,18 @@ package model // OutboundRequestPayload ... type OutboundRequestPayload struct { - OrderID string `json:"orderId"` - OrderCode string `json:"orderCode"` - TrackingCode string `json:"trackingCode"` - WarehouseID string `json:"warehouseId"` - SupplierID string `json:"supplierId"` - Note string `json:"note"` - CODAmount float64 `json:"codAmount"` - TPLCode string `json:"tplCode"` - Customer CustomerInfo `json:"customer"` - Items []OutboundRequestItem `json:"items"` - Insurance *InsuranceOpts `json:"insurance"` + OrderID string `json:"orderId"` + OrderCode string `json:"orderCode"` + TrackingCode string `json:"trackingCode"` + WarehouseID string `json:"warehouseId"` + SupplierID string `json:"supplierId"` + Note string `json:"note"` + CODAmount float64 `json:"codAmount"` + TPLCode string `json:"tplCode"` + Customer CustomerInfo `json:"customer"` + Items []OutboundRequestItem `json:"items"` + Insurance *InsuranceOpts `json:"insurance"` + PaymentMethod string `json:"paymentMethod"` } // InsuranceOpts ... From 91d8ffe40fd75c42de6041a0a4a33c060f1bb563 Mon Sep 17 00:00:00 2001 From: Sinh Date: Tue, 18 Oct 2022 14:57:14 +0700 Subject: [PATCH 09/59] add warehouse client method --- client/warehouse.go | 19 +++++++++++ model/warehouse_request.go | 8 +++++ subject/warehouse.go | 66 ++++++++++++++++++++------------------ 3 files changed, 61 insertions(+), 32 deletions(-) diff --git a/client/warehouse.go b/client/warehouse.go index 944c2cb..beb3a6f 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "errors" + "fmt" "git.selly.red/Selly-Modules/natsio" "git.selly.red/Selly-Modules/natsio/model" @@ -163,3 +164,21 @@ func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWareho } return r.Data, nil } + +// UpdateORDeliveryStatus ... +func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatus) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p)) + if err != nil { + return err + } + var r struct { + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return fmt.Errorf("nats: update_or_delivery_status %v", err) + } + if r.Error != "" { + return errors.New(r.Error) + } + return nil +} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 4cd857a..b6cecb1 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -105,3 +105,11 @@ type GetWarehousesRequest struct { Page int64 `json:"page"` Limit int64 `json:"limit"` } + +// WarehouseORUpdateDeliveryStatus ... +type WarehouseORUpdateDeliveryStatus struct { + ORCode string `json:"orCode"` + OrderCode string `json:"orderCode"` + OrderID string `json:"orderId"` + DeliveryStatus string `json:"deliveryStatus"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index f6f4cc8..bb184b5 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -9,39 +9,41 @@ func getWarehouseValue(val string) string { var Warehouse = struct { CreateWarehouseIntoServiceSupplier string UpdateWarehouseIntoServiceSupplier string - CreateOutboundRequest string - UpdateOutboundRequestLogistic string - CancelOutboundRequest string - GetConfiguration string - SyncORStatus string - WebhookTNC string - WebhookGlobalCare string - WebhookOnPoint string - FindOne string - FindByCondition string - Distinct string - Count string - AfterUpdateWarehouse string - AfterCreateWarehouse string - UpdateIsClosedSupplier string - GetWarehouses string + CreateOutboundRequest string + UpdateOutboundRequestLogistic string + CancelOutboundRequest string + GetConfiguration string + SyncORStatus string + WebhookTNC string + WebhookGlobalCare string + WebhookOnPoint string + FindOne string + FindByCondition string + Distinct string + Count string + AfterUpdateWarehouse string + AfterCreateWarehouse string + UpdateIsClosedSupplier string + GetWarehouses string + UpdateORDeliveryStatus string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), - AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), - AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), - CreateOutboundRequest: getWarehouseValue("create_outbound_request"), - UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"), - CancelOutboundRequest: getWarehouseValue("cancel_outbound_request"), - GetConfiguration: getWarehouseValue("get_configuration"), - SyncORStatus: getWarehouseValue("sync_or_status"), - WebhookTNC: getWarehouseValue("webhook_tnc"), - WebhookGlobalCare: getWarehouseValue("webhook_global_care"), - WebhookOnPoint: getWarehouseValue("webhook_on_point"), - FindOne: getWarehouseValue("find_one"), - FindByCondition: getWarehouseValue("find_all_by_condition"), - Distinct: getWarehouseValue("distinct"), - Count: getWarehouseValue("count"), - UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), - GetWarehouses: getWarehouseValue("get_warehouses"), + AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), + AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), + CreateOutboundRequest: getWarehouseValue("create_outbound_request"), + UpdateOutboundRequestLogistic: getWarehouseValue("update_outbound_request_logistic_info"), + CancelOutboundRequest: getWarehouseValue("cancel_outbound_request"), + GetConfiguration: getWarehouseValue("get_configuration"), + SyncORStatus: getWarehouseValue("sync_or_status"), + WebhookTNC: getWarehouseValue("webhook_tnc"), + WebhookGlobalCare: getWarehouseValue("webhook_global_care"), + WebhookOnPoint: getWarehouseValue("webhook_on_point"), + FindOne: getWarehouseValue("find_one"), + FindByCondition: getWarehouseValue("find_all_by_condition"), + Distinct: getWarehouseValue("distinct"), + Count: getWarehouseValue("count"), + UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), + GetWarehouses: getWarehouseValue("get_warehouses"), + UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), } From 4bc71955633337d402f676e4487eacd5f6098a39 Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 21 Oct 2022 09:26:37 +0700 Subject: [PATCH 10/59] update OR payload --- model/order_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/order_request.go b/model/order_request.go index ba920f4..bd1fa73 100644 --- a/model/order_request.go +++ b/model/order_request.go @@ -2,6 +2,7 @@ package model // OrderUpdateORStatus ... type OrderUpdateORStatus struct { + ID string `json:"id"` OrderCode string `json:"orderCode"` ORCode string `json:"orCode"` Status string `json:"status"` From e324b88fe6a68527739ab3533dc08a6e8fe4f2f6 Mon Sep 17 00:00:00 2001 From: Tue Date: Fri, 28 Oct 2022 09:31:39 +0700 Subject: [PATCH 11/59] build authsms --- client/supplier_role.go | 58 +++++++++++++++++++++++++++++ client/supplier_user.go | 65 +++++++++++++++++++++++++++------ model/supplier_role_request.go | 14 +++++++ model/supplier_role_response.go | 5 +++ model/supplier_user_request.go | 36 +++++++++++------- model/supplier_user_response.go | 8 +++- subject/config.go | 2 + subject/supplier_role.go | 15 ++++++++ subject/supplier_user.go | 24 +++++++----- 9 files changed, 191 insertions(+), 36 deletions(-) create mode 100644 client/supplier_role.go create mode 100644 model/supplier_role_request.go create mode 100644 model/supplier_role_response.go create mode 100644 subject/supplier_role.go diff --git a/client/supplier_role.go b/client/supplier_role.go new file mode 100644 index 0000000..3bf068d --- /dev/null +++ b/client/supplier_role.go @@ -0,0 +1,58 @@ +package client + +import ( + "encoding/json" + "errors" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// SupplierRole ... +type SupplierRole struct{} + +// GetSupplierRole ... +func GetSupplierRole() SupplierRole { + return SupplierRole{} +} + +func (s SupplierRole) CreateRole(p model.CreateRoleRequest) (*model.CreateRoleResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.CreateRoleResponse `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 +} + +func (s SupplierRole) UpdateRole(p model.UpdateRoleRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierRole.Update, 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 +} diff --git a/client/supplier_user.go b/client/supplier_user.go index 8bb10c5..fb6a2db 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -16,15 +16,15 @@ func GetSupplierUser() SupplierUser { return SupplierUser{} } -func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateSupplierOwnerUserRequest) (*model.CreateSupplierUserOwnerResponse, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateSupplierOwnerUser, toBytes(p)) +func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateOwnerRequest) (*model.CreateOwnerResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateOwner, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.CreateSupplierUserOwnerResponse `json:"data"` - Error string `json:"error"` + Data *model.CreateOwnerResponse `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { @@ -37,8 +37,8 @@ func (s SupplierUser) CreateSupplierOwnerUsers(p model.CreateSupplierOwnerUserRe return r.Data, nil } -func (s SupplierUser) UpdateSupplierOwnerUsers(p model.UpdateSupplierOwnerUserRequest) error { - msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateSupplierOwnerUser, toBytes(p)) +func (s SupplierUser) UpdateSupplierOwnerUsers(p model.UpdateOwnerRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateOwner, toBytes(p)) if err != nil { return err } @@ -57,15 +57,15 @@ func (s SupplierUser) UpdateSupplierOwnerUsers(p model.UpdateSupplierOwnerUserRe return nil } -func (s SupplierUser) CreateSupplierStaffUsers(p model.CreateSupplierStaffUserRequest) (*model.CreateSupplierUserStaffResponse, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateSupplierStaffUser, toBytes(p)) +func (s SupplierUser) CreateSupplierStaffUsers(p model.CreateStaffRequest) (*model.CreateStaffResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.CreateStaff, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.CreateSupplierUserStaffResponse `json:"data"` - Error string `json:"error"` + Data *model.CreateStaffResponse `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { @@ -78,8 +78,8 @@ func (s SupplierUser) CreateSupplierStaffUsers(p model.CreateSupplierStaffUserRe return r.Data, nil } -func (s SupplierUser) UpdateSupplierStaffUsers(p model.CreateSupplierStaffUserRequest) error { - msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateSupplierStaffUser, toBytes(p)) +func (s SupplierUser) UpdateSupplierStaffUsers(p model.UpdateStaffRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStaff, toBytes(p)) if err != nil { return err } @@ -97,3 +97,44 @@ func (s SupplierUser) UpdateSupplierStaffUsers(p model.CreateSupplierStaffUserRe return nil } + +func (s SupplierUser) UpdateStatus(p model.UpdateStatusRequest) error { + msg, err := natsio.GetServer().Request(subject.SupplierUser.UpdateStaff, 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 +} + +func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetPasswordResponse, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.ResetPassword, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResetPasswordResponse `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 +} diff --git a/model/supplier_role_request.go b/model/supplier_role_request.go new file mode 100644 index 0000000..6402622 --- /dev/null +++ b/model/supplier_role_request.go @@ -0,0 +1,14 @@ +package model + +type CreateRoleRequest struct { + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` +} + +type UpdateRoleRequest struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Type string `json:"type"` +} diff --git a/model/supplier_role_response.go b/model/supplier_role_response.go new file mode 100644 index 0000000..d7b68fc --- /dev/null +++ b/model/supplier_role_response.go @@ -0,0 +1,5 @@ +package model + +type CreateRoleResponse struct { + ID string `json:"_id"` +} diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index f4556b2..66ccb17 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -1,6 +1,6 @@ package model -type CreateSupplierOwnerUserRequest struct { +type CreateOwnerRequest struct { Name string `json:"name"` Phone string `json:"phone"` Email string `json:"email"` @@ -9,7 +9,7 @@ type CreateSupplierOwnerUserRequest struct { Password string `json:"password"` } -type UpdateSupplierOwnerUserRequest struct { +type UpdateOwnerRequest struct { ID string `json:"_id"` SupplierID string `json:"supplierId"` Name string `json:"name"` @@ -18,7 +18,7 @@ type UpdateSupplierOwnerUserRequest struct { RoleID string `json:"roleId"` } -type CreateSupplierStaffUserRequest struct { +type CreateStaffRequest struct { Name string `json:"name"` Phone string `json:"phone"` Email string `json:"email"` @@ -28,14 +28,24 @@ type CreateSupplierStaffUserRequest struct { Warehouses []string `json:"warehouses"` } -type UpdateSupplierStaffUserRequest struct { - ID string `json:"_id"` - Name string `json:"name"` - Phone string `json:"phone"` - Email string `json:"email"` - SupplierID string `json:"supplierId"` - Role string `json:"role"` - Password string `json:"password"` - Warehouses []string `json:"warehouses"` - RoleId string `json:"roleId"` +type UpdateStaffRequest struct { + ID string `json:"_id"` + Name string `json:"name"` + Phone string `json:"phone"` + Email string `json:"email"` + SupplierID string `json:"supplierId"` + RoleID string `json:"roleId"` + Password string `json:"password"` + SupplierUserWarehouseID string `json:"supplierUserWarehouseId"` + Warehouses []string `json:"warehouses"` +} + +type UpdateStatusRequest struct { + ID string `json:"_id"` + Status string `json:"status"` +} + +type ResetPasswordRequest struct { + ID string `json:"_id"` + Password string `json:"password"` } diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 7241bad..38a1d0c 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -1,9 +1,13 @@ package model -type CreateSupplierUserOwnerResponse struct { +type CreateOwnerResponse struct { ID string `json:"_id"` } -type CreateSupplierUserStaffResponse struct { +type CreateStaffResponse struct { ID string `json:"_id"` } + +type ResetPasswordResponse struct { + Password string `json:"password"` +} diff --git a/subject/config.go b/subject/config.go index d50d9d4..90a014f 100644 --- a/subject/config.go +++ b/subject/config.go @@ -10,6 +10,7 @@ var prefixes = struct { Supplier string Seller string SupplierUser string + SupplierRole string }{ Communication: "communication", Order: "order", @@ -20,4 +21,5 @@ var prefixes = struct { Bank: "bank", Seller: "seller", SupplierUser: "supplier_user", + SupplierRole: "supplier_role", } diff --git a/subject/supplier_role.go b/subject/supplier_role.go new file mode 100644 index 0000000..8915759 --- /dev/null +++ b/subject/supplier_role.go @@ -0,0 +1,15 @@ +package subject + +import "fmt" + +func getRoleValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.SupplierRole, val) +} + +var SupplierRole = struct { + Create string + Update string +}{ + Create: getRoleValue("create"), + Update: getRoleValue("update"), +} diff --git a/subject/supplier_user.go b/subject/supplier_user.go index 7abb4c7..adc2f1f 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -2,18 +2,24 @@ package subject import "fmt" -func getAuthSMSValue(val string) string { +func getSupplierUserValue(val string) string { return fmt.Sprintf("%s.%s", prefixes.SupplierUser, val) } var SupplierUser = struct { - CreateSupplierOwnerUser string - UpdateSupplierOwnerUser string - CreateSupplierStaffUser string - UpdateSupplierStaffUser string + // Users + CreateOwner string + UpdateOwner string + CreateStaff string + UpdateStaff string + UpdateStatus string + ResetPassword string }{ - CreateSupplierOwnerUser: getAuthSMSValue("create_supplier_owner_user"), - UpdateSupplierOwnerUser: getAuthSMSValue("update_supplier_owner_user"), - CreateSupplierStaffUser: getAuthSMSValue("create_supplier_staff_user"), - UpdateSupplierStaffUser: getAuthSMSValue("update_supplier_staff_user"), + // Users + CreateOwner: getSupplierUserValue("create_owner"), + UpdateOwner: getSupplierUserValue("update_owner"), + CreateStaff: getSupplierUserValue("create_staff"), + UpdateStaff: getSupplierUserValue("update_staff"), + UpdateStatus: getSupplierUserValue("update_status"), + ResetPassword: getSupplierUserValue("reset_password"), } From c007a41a06a6ca6497933bf11d3bc39f4737ade5 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 2 Nov 2022 09:38:52 +0700 Subject: [PATCH 12/59] fix subject update OR delivery --- client/warehouse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/warehouse.go b/client/warehouse.go index beb3a6f..fb391ca 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -167,7 +167,7 @@ func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWareho // UpdateORDeliveryStatus ... func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatus) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateORDeliveryStatus, toBytes(p)) if err != nil { return err } From 598c886aa6975e1a2af346ee230cbfc53a872df2 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Mon, 14 Nov 2022 14:45:26 +0700 Subject: [PATCH 13/59] nats model campaign --- client/social_post.go | 41 +++++++++++++++++++++++++ model/file_response.go | 56 +++++++++++++++++++++++++++++++++++ model/social_post_request.go | 8 +++++ model/social_post_response.go | 49 ++++++++++++++++++++++++++++++ subject/config.go | 2 ++ subject/social_post.go | 15 ++++++++++ 6 files changed, 171 insertions(+) create mode 100644 client/social_post.go create mode 100644 model/file_response.go create mode 100644 model/social_post_request.go create mode 100644 model/social_post_response.go create mode 100644 subject/social_post.go diff --git a/client/social_post.go b/client/social_post.go new file mode 100644 index 0000000..f8bcc3b --- /dev/null +++ b/client/social_post.go @@ -0,0 +1,41 @@ +package client + +import ( + "encoding/json" + "errors" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// SocialPost ... +type SocialPost struct{} + +// GetSocialPost ... +func GetSocialPost() SocialPost { + return SocialPost{} +} + +// GetListSocialPostAppInfoByIDs ... +func (s Seller) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppByIDsRequest) (*model.ResponseListSocialPostAppInfo, error) { + msg, err := natsio.GetServer().Request(subject.SocialPost.GetListSocialPostAppInfoByIDs, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSocialPostAppInfo `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 +} diff --git a/model/file_response.go b/model/file_response.go new file mode 100644 index 0000000..6eff304 --- /dev/null +++ b/model/file_response.go @@ -0,0 +1,56 @@ +package model + +import "go.mongodb.org/mongo-driver/bson/primitive" + +// FilePhoto ... +type FilePhoto struct { + ID string `json:"_id"` + Name string `json:"name,omitempty"` + Dimensions *FileDimensions `json:"dimensions"` +} + +// FileSize ... +type FileSize struct { + Width int `json:"width"` + Height int `json:"height"` + URL string `json:"url"` +} + +// FileDimensions ... +type FileDimensions struct { + Small *FileSize `json:"sm"` + Medium *FileSize `json:"md"` +} + +// ListPhoto ... +type ListPhoto []*FilePhoto + +// Video ... +type Video struct { + ID primitive.ObjectID `json:"_id"` + Name string `json:"name"` + Dimensions *FileVideoDimensions `json:"dimensions"` + VideoExtension string `json:"ext"` + Thumbnail *FilePhoto `json:"thumbnail"` + Status string `json:"status"` +} + +// FileVideoDimensions ... +type FileVideoDimensions struct { + Dimension480p *FileVideoSize `json:"size480p"` + Dimension720p *FileVideoSize `json:"size720p"` + Dimension1080p *FileVideoSize `json:"size1080p"` + DimensionOriginal *FileVideoSize `json:"original"` +} + +// FileVideoSize ... +type FileVideoSize struct { + Name string `json:"name"` + Width int `json:"width"` + Height int `json:"height"` + Size string `json:"size"` + URL string `json:"url"` +} + +// ListVideo ... +type ListVideo []Video diff --git a/model/social_post_request.go b/model/social_post_request.go new file mode 100644 index 0000000..179e378 --- /dev/null +++ b/model/social_post_request.go @@ -0,0 +1,8 @@ +package model + +import "go.mongodb.org/mongo-driver/bson/primitive" + +// GetListSocialPostAppByIDsRequest ... +type GetListSocialPostAppByIDsRequest struct { + SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` +} diff --git a/model/social_post_response.go b/model/social_post_response.go new file mode 100644 index 0000000..cb6469b --- /dev/null +++ b/model/social_post_response.go @@ -0,0 +1,49 @@ +package model + +import ( + "go.mongodb.org/mongo-driver/bson/primitive" + "time" +) + +// ResponseListSocialPostAppInfo ... +type ResponseListSocialPostAppInfo struct { + SocialPosts []SocialPostAppInfo `json:"socialPosts"` +} + +// SocialPostAppInfo ... +type SocialPostAppInfo struct { + ID primitive.ObjectID `json:"_id"` + Title string `json:"title"` + Content string `json:"content"` + Statistic SocialPostStatistic `json:"statistic"` + Author *SocialPostSellerInfo `json:"author"` + Photos ListPhoto `json:"photos"` + PublishedAt time.Time `json:"publishedAt"` + IsLiked bool `json:"isLiked"` + IsPin bool `json:"isPin"` + Contributor *SocialPostSellerInfo `json:"contributor"` + CreatedAt time.Time `json:"createdAt"` + Status string `json:"status"` + HasUpdate bool `json:"hasUpdate"` + Order int `json:"order"` + Videos ListVideo `json:"videos"` +} + +// SocialPostStatistic ... +type SocialPostStatistic struct { + Views int `json:"views"` + UniqueViews int `json:"uniqueViews"` + Likes int `json:"likes"` + Shares int `json:"shares"` + UniqueShares int `json:"uniqueShares"` + Comments int `json:"comments"` +} + +// SocialPostSellerInfo ... +type SocialPostSellerInfo struct { + ID primitive.ObjectID `json:"_id"` + Name string `json:"name"` + Membership SellerMembershipInfo `json:"membership"` + Logo *FilePhoto `json:"logo"` + IsMine bool `json:"isMine"` +} diff --git a/subject/config.go b/subject/config.go index 90a014f..e8cf263 100644 --- a/subject/config.go +++ b/subject/config.go @@ -11,6 +11,7 @@ var prefixes = struct { Seller string SupplierUser string SupplierRole string + SocialPost string }{ Communication: "communication", Order: "order", @@ -22,4 +23,5 @@ var prefixes = struct { Seller: "seller", SupplierUser: "supplier_user", SupplierRole: "supplier_role", + SocialPost: "social_post", } diff --git a/subject/social_post.go b/subject/social_post.go new file mode 100644 index 0000000..ff585c9 --- /dev/null +++ b/subject/social_post.go @@ -0,0 +1,15 @@ +package subject + +import "fmt" + +// getSocialPostValue ... +func getSocialPostValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.SocialPost, val) +} + +// SocialPost ... +var SocialPost = struct { + GetListSocialPostAppInfoByIDs string +}{ + GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), +} From 18f4444156d1358181b6748c7118800b1396ad59 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Mon, 14 Nov 2022 15:11:04 +0700 Subject: [PATCH 14/59] fix --- client/social_post.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/social_post.go b/client/social_post.go index f8bcc3b..bae985d 100644 --- a/client/social_post.go +++ b/client/social_post.go @@ -17,7 +17,7 @@ func GetSocialPost() SocialPost { } // GetListSocialPostAppInfoByIDs ... -func (s Seller) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppByIDsRequest) (*model.ResponseListSocialPostAppInfo, error) { +func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppByIDsRequest) (*model.ResponseListSocialPostAppInfo, error) { msg, err := natsio.GetServer().Request(subject.SocialPost.GetListSocialPostAppInfoByIDs, toBytes(p)) if err != nil { From 7a213f4b4d64b3d82c55e6122f8c4d8b300935f4 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Wed, 16 Nov 2022 16:38:41 +0700 Subject: [PATCH 15/59] nats model campaign admin --- client/social_post.go | 24 ++++++++++++++++++++++++ model/social_post_request.go | 5 +++++ model/social_post_response.go | 11 +++++++++++ subject/social_post.go | 6 ++++-- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/client/social_post.go b/client/social_post.go index bae985d..e6d9395 100644 --- a/client/social_post.go +++ b/client/social_post.go @@ -39,3 +39,27 @@ func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppBy } return r.Data, nil } + +// GetBriefDetailSocialPostAdminByIDsRequest ... +func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefDetailSocialPostAdminByIDsRequest) (*model.ResponseDetailSocialPostAdminInfo, error) { + msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefDetailSocialPostAdminByIDs, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseDetailSocialPostAdminInfo `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 +} diff --git a/model/social_post_request.go b/model/social_post_request.go index 179e378..72cd803 100644 --- a/model/social_post_request.go +++ b/model/social_post_request.go @@ -6,3 +6,8 @@ import "go.mongodb.org/mongo-driver/bson/primitive" type GetListSocialPostAppByIDsRequest struct { SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` } + +// GetBriefDetailSocialPostAdminByIDsRequest ... +type GetBriefDetailSocialPostAdminByIDsRequest struct { + SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` +} diff --git a/model/social_post_response.go b/model/social_post_response.go index cb6469b..94371f5 100644 --- a/model/social_post_response.go +++ b/model/social_post_response.go @@ -47,3 +47,14 @@ type SocialPostSellerInfo struct { Logo *FilePhoto `json:"logo"` IsMine bool `json:"isMine"` } + +// ResponseDetailSocialPostAdminInfo ... +type ResponseDetailSocialPostAdminInfo struct { + SocialPosts SocialPostAdminInfo `json:"socialPosts"` +} + +type SocialPostAdminInfo struct { + ID primitive.ObjectID `json:"_id"` + Title string `json:"title"` + Status string `json:"status"` +} diff --git a/subject/social_post.go b/subject/social_post.go index ff585c9..a90106a 100644 --- a/subject/social_post.go +++ b/subject/social_post.go @@ -9,7 +9,9 @@ func getSocialPostValue(val string) string { // SocialPost ... var SocialPost = struct { - GetListSocialPostAppInfoByIDs string + GetListSocialPostAppInfoByIDs string + GetBriefDetailSocialPostAdminByIDs string }{ - GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), + GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), + GetBriefDetailSocialPostAdminByIDs: getSocialPostValue("get_brief_detail_social_post_admin_by_ids"), } From 6e21f72ac00bc7cd94bd73338adeaf01a72fb023 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:21:37 +0700 Subject: [PATCH 16/59] fix name func --- client/social_post.go | 4 ++-- model/social_post_request.go | 4 ++-- subject/social_post.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/social_post.go b/client/social_post.go index e6d9395..9e614c0 100644 --- a/client/social_post.go +++ b/client/social_post.go @@ -41,8 +41,8 @@ func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppBy } // GetBriefDetailSocialPostAdminByIDsRequest ... -func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefDetailSocialPostAdminByIDsRequest) (*model.ResponseDetailSocialPostAdminInfo, error) { - msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefDetailSocialPostAdminByIDs, toBytes(p)) +func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefInfoSocialPostAdminByIDsRequest) (*model.ResponseDetailSocialPostAdminInfo, error) { + msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefInfoSocialPostAdminByIDs, toBytes(p)) if err != nil { return nil, err diff --git a/model/social_post_request.go b/model/social_post_request.go index 72cd803..efeb983 100644 --- a/model/social_post_request.go +++ b/model/social_post_request.go @@ -7,7 +7,7 @@ type GetListSocialPostAppByIDsRequest struct { SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` } -// GetBriefDetailSocialPostAdminByIDsRequest ... -type GetBriefDetailSocialPostAdminByIDsRequest struct { +// GetBriefInfoSocialPostAdminByIDsRequest ... +type GetBriefInfoSocialPostAdminByIDsRequest struct { SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` } diff --git a/subject/social_post.go b/subject/social_post.go index a90106a..029f876 100644 --- a/subject/social_post.go +++ b/subject/social_post.go @@ -9,9 +9,9 @@ func getSocialPostValue(val string) string { // SocialPost ... var SocialPost = struct { - GetListSocialPostAppInfoByIDs string - GetBriefDetailSocialPostAdminByIDs string + GetListSocialPostAppInfoByIDs string + GetBriefInfoSocialPostAdminByIDs string }{ - GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), - GetBriefDetailSocialPostAdminByIDs: getSocialPostValue("get_brief_detail_social_post_admin_by_ids"), + GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), + GetBriefInfoSocialPostAdminByIDs: getSocialPostValue("get_brief_info_social_post_admin_by_ids"), } From 26f8b64258d5e30d1a55aa448b072b4ff0e3ec63 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:33:29 +0700 Subject: [PATCH 17/59] fix --- model/social_post_response.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/social_post_response.go b/model/social_post_response.go index 94371f5..811d791 100644 --- a/model/social_post_response.go +++ b/model/social_post_response.go @@ -48,9 +48,9 @@ type SocialPostSellerInfo struct { IsMine bool `json:"isMine"` } -// ResponseDetailSocialPostAdminInfo ... -type ResponseDetailSocialPostAdminInfo struct { - SocialPosts SocialPostAdminInfo `json:"socialPosts"` +// ResponseListSocialPostAdminInfo ... +type ResponseListSocialPostAdminInfo struct { + SocialPosts []SocialPostAdminInfo `json:"socialPosts"` } type SocialPostAdminInfo struct { From b8f10912c1129a5ca8790a869ab38a7e019ea7c6 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Thu, 17 Nov 2022 09:27:45 +0700 Subject: [PATCH 18/59] rename --- client/social_post.go | 6 +++--- model/social_post_response.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/social_post.go b/client/social_post.go index 9e614c0..72b1781 100644 --- a/client/social_post.go +++ b/client/social_post.go @@ -41,7 +41,7 @@ func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppBy } // GetBriefDetailSocialPostAdminByIDsRequest ... -func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefInfoSocialPostAdminByIDsRequest) (*model.ResponseDetailSocialPostAdminInfo, error) { +func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefInfoSocialPostAdminByIDsRequest) (*model.ResponseListSocialPostAdminInfo, error) { msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefInfoSocialPostAdminByIDs, toBytes(p)) if err != nil { @@ -49,8 +49,8 @@ func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefIn } var r struct { - Data *model.ResponseDetailSocialPostAdminInfo `json:"data"` - Error string `json:"error"` + Data *model.ResponseListSocialPostAdminInfo `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil { diff --git a/model/social_post_response.go b/model/social_post_response.go index 811d791..e0765f5 100644 --- a/model/social_post_response.go +++ b/model/social_post_response.go @@ -53,6 +53,7 @@ type ResponseListSocialPostAdminInfo struct { SocialPosts []SocialPostAdminInfo `json:"socialPosts"` } +// SocialPostAdminInfo ... type SocialPostAdminInfo struct { ID primitive.ObjectID `json:"_id"` Title string `json:"title"` From d45da3e74c6d7d02ed728c8d630c47462af6efcc Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 18 Nov 2022 10:13:41 +0700 Subject: [PATCH 19/59] nats - get supplier from old server --- client/supplier.go | 21 +++++++++++++++++++++ model/supplier_request.go | 7 +++++++ subject/supplier.go | 2 ++ 3 files changed, 30 insertions(+) diff --git a/client/supplier.go b/client/supplier.go index 1ed20d0..e278f46 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -80,6 +80,27 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl return r.Data, nil } +func (s Supplier) FindAllOld(req model.SupplierFindAllReq) (*model.SupplierAll, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.FindAllOld, toBytes(req)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierAll `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 +} + func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*model.SupplierAll, error) { msg, err := natsio.GetServer().Request(subject.Supplier.FindAll, toBytes(supplierID)) if err != nil { diff --git a/model/supplier_request.go b/model/supplier_request.go index 5a19924..118737d 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -38,3 +38,10 @@ type UpdateSupplierWarehousePayload struct { DistrictCode int `json:"districtCode"` WardCode int `json:"wardCode"` } + +type SupplierFindAllReq struct { + Page int64 `json:"page"` + Limit int64 `json:"limit"` + Segment string `json:"segment"` + IDs []string `json:"ids"` +} diff --git a/subject/supplier.go b/subject/supplier.go index 17ca8d0..92af7b3 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -10,8 +10,10 @@ var Supplier = struct { GetListSupplierInfo string GetSupplierContractBySupplierID string FindAll string + FindAllOld string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), + FindAllOld: getSupplierValue("find_all_old"), } From 549aee36d052a27e846d530202853d75789e7a21 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 18 Nov 2022 14:52:05 +0700 Subject: [PATCH 20/59] update notification opts --- js/model/selly.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/model/selly.go b/js/model/selly.go index a8e0a60..856da44 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -12,8 +12,9 @@ type PushNotification struct { // NotificationOptions ... type NotificationOptions struct { - Title string `json:"title"` - Content string `json:"content"` + Title string `json:"title"` + Content string `json:"content"` + CampaignID string `json:"campaignId,omitempty"` } // PayloadUpdateSellerAffiliateStatistic ... From 0dd3dce224ab1357c8165c18cf66376da721f49e Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Tue, 22 Nov 2022 10:04:40 +0700 Subject: [PATCH 21/59] add nats staff --- client/staff.go | 41 +++++++++++++++++++++++++++++++++++++++++ model/staff_request.go | 6 ++++++ model/staff_response.go | 12 ++++++++++++ subject/config.go | 2 ++ subject/staff.go | 14 ++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 client/staff.go create mode 100644 model/staff_request.go create mode 100644 model/staff_response.go create mode 100644 subject/staff.go diff --git a/client/staff.go b/client/staff.go new file mode 100644 index 0000000..b175f53 --- /dev/null +++ b/client/staff.go @@ -0,0 +1,41 @@ +package client + +import ( + "encoding/json" + "errors" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// Staff ... +type Staff struct{} + +func GetStaff() Staff { + return Staff{} +} + +// GetListStaffInfoByIds ... +func (s Staff) GetListStaffInfoByIds(p model.GetListStaffRequest) (*model.ResponseListStaffInfo, error) { + msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfo, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListStaffInfo `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 + +} diff --git a/model/staff_request.go b/model/staff_request.go new file mode 100644 index 0000000..176b34e --- /dev/null +++ b/model/staff_request.go @@ -0,0 +1,6 @@ +package model + +// GetListStaffRequest ... +type GetListStaffRequest struct { + StaffIds []string `json:"staffIds"` +} diff --git a/model/staff_response.go b/model/staff_response.go new file mode 100644 index 0000000..5076d0c --- /dev/null +++ b/model/staff_response.go @@ -0,0 +1,12 @@ +package model + +// ResponseListStaffInfo ... +type ResponseListStaffInfo struct { + Staffs []ResponseStaffInfo `json:"staffs"` +} + +// ResponseStaffInfo ... +type ResponseStaffInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} diff --git a/subject/config.go b/subject/config.go index e8cf263..2a2f743 100644 --- a/subject/config.go +++ b/subject/config.go @@ -12,6 +12,7 @@ var prefixes = struct { SupplierUser string SupplierRole string SocialPost string + Staff string }{ Communication: "communication", Order: "order", @@ -24,4 +25,5 @@ var prefixes = struct { SupplierUser: "supplier_user", SupplierRole: "supplier_role", SocialPost: "social_post", + Staff: "staff", } diff --git a/subject/staff.go b/subject/staff.go new file mode 100644 index 0000000..4777f06 --- /dev/null +++ b/subject/staff.go @@ -0,0 +1,14 @@ +package subject + +import "fmt" + +func getStaffValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Staff, val) +} + +// Staff ... +var Staff = struct { + GetListStaffInfo string +}{ + GetListStaffInfo: getStaffValue("get_list_staff_info"), +} From 8248069bb86310fb30d839ff03d50553ea508530 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 23 Nov 2022 10:08:52 +0700 Subject: [PATCH 22/59] count supplier --- client/supplier.go | 21 +++++++++++++++++++++ model/supplier_request.go | 5 +++++ model/supplier_response.go | 4 ++++ subject/supplier.go | 2 ++ 4 files changed, 32 insertions(+) diff --git a/client/supplier.go b/client/supplier.go index e278f46..9b53826 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -122,6 +122,27 @@ func (s Supplier) GetBankInfoByID(supplierID model.SupplierRequestPayload) (*mod return r.Data, nil } +func (s Supplier) Count(req model.SupplierCountReq) (*model.SupplierCountRes, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.Count, toBytes(req)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.SupplierCountRes `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 +} + // CreateWarehouseIntoServiceSupplier ... func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, toBytes(p)) diff --git a/model/supplier_request.go b/model/supplier_request.go index 118737d..bbba857 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -45,3 +45,8 @@ type SupplierFindAllReq struct { Segment string `json:"segment"` IDs []string `json:"ids"` } + +type SupplierCountReq struct { + Segment string `json:"segment"` + IDs []string `json:"ids"` +} diff --git a/model/supplier_response.go b/model/supplier_response.go index 975a8de..2b9dd10 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -29,3 +29,7 @@ type SupplierAll struct { Suppliers []SupplierBrief `json:"suppliers"` Total int64 `json:"total"` } + +type SupplierCountRes struct { + Total int64 `json:"total"` +} diff --git a/subject/supplier.go b/subject/supplier.go index 92af7b3..edc797f 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -11,9 +11,11 @@ var Supplier = struct { GetSupplierContractBySupplierID string FindAll string FindAllOld string + Count string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), + Count: getSupplierValue("count"), } From c47768308c66c19d120519ba5e1feaef6ff811b4 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Wed, 23 Nov 2022 10:29:50 +0700 Subject: [PATCH 23/59] add nats --- client/segmnet.go | 41 +++++++++++++++++++++++++++++++++++++++ client/staff.go | 41 +++++++++++++++++++++++++++++++++++++++ model/segment_request.go | 6 ++++++ model/segment_response.go | 12 ++++++++++++ model/staff_request.go | 6 ++++++ model/staff_response.go | 12 ++++++++++++ subject/config.go | 4 ++++ subject/segment.go | 15 ++++++++++++++ subject/staff.go | 14 +++++++++++++ 9 files changed, 151 insertions(+) create mode 100644 client/segmnet.go create mode 100644 client/staff.go create mode 100644 model/segment_request.go create mode 100644 model/segment_response.go create mode 100644 model/staff_request.go create mode 100644 model/staff_response.go create mode 100644 subject/segment.go create mode 100644 subject/staff.go diff --git a/client/segmnet.go b/client/segmnet.go new file mode 100644 index 0000000..bcc7bab --- /dev/null +++ b/client/segmnet.go @@ -0,0 +1,41 @@ +package client + +import ( + "encoding/json" + "errors" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// Segment ... +type Segment struct{} + +// GetSegment ... +func GetSegment() Segment { + return Segment{} +} + +// GetListSegmentInfoByIds ... +func (s Segment) GetListSegmentInfoByIds(p model.GetListSegmentRequest) (*model.ResponseListSegmentInfo, error) { + msg, err := natsio.GetServer().Request(subject.Segment.GetListSegmentInfo, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSegmentInfo `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 +} diff --git a/client/staff.go b/client/staff.go new file mode 100644 index 0000000..b175f53 --- /dev/null +++ b/client/staff.go @@ -0,0 +1,41 @@ +package client + +import ( + "encoding/json" + "errors" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// Staff ... +type Staff struct{} + +func GetStaff() Staff { + return Staff{} +} + +// GetListStaffInfoByIds ... +func (s Staff) GetListStaffInfoByIds(p model.GetListStaffRequest) (*model.ResponseListStaffInfo, error) { + msg, err := natsio.GetServer().Request(subject.Staff.GetListStaffInfo, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListStaffInfo `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 + +} diff --git a/model/segment_request.go b/model/segment_request.go new file mode 100644 index 0000000..138f347 --- /dev/null +++ b/model/segment_request.go @@ -0,0 +1,6 @@ +package model + +// GetListSegmentRequest ... +type GetListSegmentRequest struct { + SegmentIds []string `json:"segmentIds"` +} diff --git a/model/segment_response.go b/model/segment_response.go new file mode 100644 index 0000000..84a1571 --- /dev/null +++ b/model/segment_response.go @@ -0,0 +1,12 @@ +package model + +// ResponseSegmentInfo ... +type ResponseSegmentInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} + +// ResponseListSegmentInfo ... +type ResponseListSegmentInfo struct { + Segments []ResponseSegmentInfo `json:"segments"` +} diff --git a/model/staff_request.go b/model/staff_request.go new file mode 100644 index 0000000..176b34e --- /dev/null +++ b/model/staff_request.go @@ -0,0 +1,6 @@ +package model + +// GetListStaffRequest ... +type GetListStaffRequest struct { + StaffIds []string `json:"staffIds"` +} diff --git a/model/staff_response.go b/model/staff_response.go new file mode 100644 index 0000000..5076d0c --- /dev/null +++ b/model/staff_response.go @@ -0,0 +1,12 @@ +package model + +// ResponseListStaffInfo ... +type ResponseListStaffInfo struct { + Staffs []ResponseStaffInfo `json:"staffs"` +} + +// ResponseStaffInfo ... +type ResponseStaffInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} diff --git a/subject/config.go b/subject/config.go index 90a014f..b3117b3 100644 --- a/subject/config.go +++ b/subject/config.go @@ -11,6 +11,8 @@ var prefixes = struct { Seller string SupplierUser string SupplierRole string + Staff string + Segment string }{ Communication: "communication", Order: "order", @@ -22,4 +24,6 @@ var prefixes = struct { Seller: "seller", SupplierUser: "supplier_user", SupplierRole: "supplier_role", + Staff: "staff", + Segment: "segment", } diff --git a/subject/segment.go b/subject/segment.go new file mode 100644 index 0000000..f6021ca --- /dev/null +++ b/subject/segment.go @@ -0,0 +1,15 @@ +package subject + +import "fmt" + +// getSegmentValue ... +func getSegmentValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Segment, val) +} + +// Segment ... +var Segment = struct { + GetListSegmentInfo string +}{ + GetListSegmentInfo: getSegmentValue("get_list_segment_info"), +} diff --git a/subject/staff.go b/subject/staff.go new file mode 100644 index 0000000..4777f06 --- /dev/null +++ b/subject/staff.go @@ -0,0 +1,14 @@ +package subject + +import "fmt" + +func getStaffValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Staff, val) +} + +// Staff ... +var Staff = struct { + GetListStaffInfo string +}{ + GetListStaffInfo: getStaffValue("get_list_staff_info"), +} From dbf8ad502f061c3ff19226bafd0ff3665c1cce3b Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Wed, 23 Nov 2022 16:54:31 +0700 Subject: [PATCH 24/59] fix --- model/social_post_response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/social_post_response.go b/model/social_post_response.go index e0765f5..85a2445 100644 --- a/model/social_post_response.go +++ b/model/social_post_response.go @@ -44,7 +44,7 @@ type SocialPostSellerInfo struct { ID primitive.ObjectID `json:"_id"` Name string `json:"name"` Membership SellerMembershipInfo `json:"membership"` - Logo *FilePhoto `json:"logo"` + Logo *FilePhoto `json:"avatar"` IsMine bool `json:"isMine"` } From e3e498ed23713b3cf4f016c5f6965f124925e7d5 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Thu, 24 Nov 2022 09:06:48 +0700 Subject: [PATCH 25/59] add nasts campaign transaction --- client/campaign.go | 31 ++++++++++++++++++++++++++++++ model/campaign_request.go | 14 ++++++++++++++ model/campaign_response.go | 39 ++++++++++++++++++++++++++++++++++++++ subject/campaign.go | 15 +++++++++++++++ subject/config.go | 2 ++ 5 files changed, 101 insertions(+) create mode 100644 client/campaign.go create mode 100644 model/campaign_request.go create mode 100644 model/campaign_response.go create mode 100644 subject/campaign.go diff --git a/client/campaign.go b/client/campaign.go new file mode 100644 index 0000000..7a210e6 --- /dev/null +++ b/client/campaign.go @@ -0,0 +1,31 @@ +package client + +import ( + "encoding/json" + "errors" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// Campaign ... +type Campaign struct{} + +// GetCampaignTransaction ... +func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) (*model.ResponseCampaignTransactionAll, error) { + msg, err := natsio.GetServer().Request(subject.Campaign.GetListCampaignTransactionAdminInfoByIDs, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.ResponseCampaignTransactionAll `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 +} diff --git a/model/campaign_request.go b/model/campaign_request.go new file mode 100644 index 0000000..71227e4 --- /dev/null +++ b/model/campaign_request.go @@ -0,0 +1,14 @@ +package model + +import "time" + +// GetCampaignTransactionsRequest ... +type GetCampaignTransactionsRequest struct { + Campaign string `json:"campaign"` + Keyword string `json:"keyword"` + Status string `json:"status"` + FromAt time.Time `json:"fromAt"` + ToAt time.Time `json:"toAt"` + Page int64 `json:"page"` + Limit int64 `json:"limit"` +} diff --git a/model/campaign_response.go b/model/campaign_response.go new file mode 100644 index 0000000..7482099 --- /dev/null +++ b/model/campaign_response.go @@ -0,0 +1,39 @@ +package model + +// ResponseCampaignTransactionAll ... +type ResponseCampaignTransactionAll struct { + List []ResponseNatsCampaignTransaction `json:"list"` + Total int64 `json:"total"` + Limit int64 `json:"limit"` +} + +// ResponseNatsCampaignTransaction ... +type ResponseNatsCampaignTransaction struct { + ID string `json:"_id"` + Cash float64 `json:"cash"` + Campaign ResponseCampaignShortInfo `json:"campaign"` + Seller ResponseSellerInfo `json:"seller"` + Type string `json:"type"` + RejectedReason string `json:"rejectedReason"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` + Item *ResponseCampaignItemShortInfo `json:"item"` + ApprovedBy *ResponseStaffInfo `json:"approvedBy,omitempty"` + RejectedBy *ResponseStaffInfo `json:"rejectedBy,omitempty"` + ApprovedAt string `json:"approvedAt,omitempty"` + RejectedAt string `json:"rejectedAt,omitempty"` +} + +// ResponseCampaignShortInfo ... +type ResponseCampaignShortInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Status string `json:"status"` +} + +// ResponseCampaignItemShortInfo ... +type ResponseCampaignItemShortInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Status string `json:"status"` +} diff --git a/subject/campaign.go b/subject/campaign.go new file mode 100644 index 0000000..8c7ddac --- /dev/null +++ b/subject/campaign.go @@ -0,0 +1,15 @@ +package subject + +import "fmt" + +// getCampaignValue ... +func getCampaignValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Campaign, val) +} + +// Campaign ... +var Campaign = struct { + GetListCampaignTransactionAdminInfoByIDs string +}{ + GetListCampaignTransactionAdminInfoByIDs: getCampaignValue("get_list_campaign_transaction_admin_info_by_ids"), +} diff --git a/subject/config.go b/subject/config.go index 2a2f743..9d9b655 100644 --- a/subject/config.go +++ b/subject/config.go @@ -13,6 +13,7 @@ var prefixes = struct { SupplierRole string SocialPost string Staff string + Campaign string }{ Communication: "communication", Order: "order", @@ -26,4 +27,5 @@ var prefixes = struct { SupplierRole: "supplier_role", SocialPost: "social_post", Staff: "staff", + Campaign: "campaign", } From fb87ac7911f53a6fafed85702b42439b25cd2b14 Mon Sep 17 00:00:00 2001 From: Sinh Date: Thu, 24 Nov 2022 09:38:10 +0700 Subject: [PATCH 26/59] update nats --- model/supplier_request.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/model/supplier_request.go b/model/supplier_request.go index bbba857..18034af 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -44,9 +44,11 @@ type SupplierFindAllReq struct { Limit int64 `json:"limit"` Segment string `json:"segment"` IDs []string `json:"ids"` + Status string `json:"status"` // active,inactive } type SupplierCountReq struct { Segment string `json:"segment"` IDs []string `json:"ids"` + Status string `json:"status"` // active,inactive } From 2f278526a91303bd07bbc30f54552136dd893e17 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Thu, 24 Nov 2022 09:49:41 +0700 Subject: [PATCH 27/59] add GetCampaign --- client/campaign.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/campaign.go b/client/campaign.go index 7a210e6..82649d3 100644 --- a/client/campaign.go +++ b/client/campaign.go @@ -11,6 +11,11 @@ import ( // Campaign ... type Campaign struct{} +// GetCampaign ... +func GetCampaign() Campaign { + return Campaign{} +} + // GetCampaignTransaction ... func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) (*model.ResponseCampaignTransactionAll, error) { msg, err := natsio.GetServer().Request(subject.Campaign.GetListCampaignTransactionAdminInfoByIDs, toBytes(p)) From af807784ec3d45a707b9d791a2f30f1297f172a9 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Thu, 24 Nov 2022 11:14:15 +0700 Subject: [PATCH 28/59] fix response --- model/campaign_response.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/campaign_response.go b/model/campaign_response.go index 7482099..b563396 100644 --- a/model/campaign_response.go +++ b/model/campaign_response.go @@ -1,5 +1,7 @@ package model +import "go.mongodb.org/mongo-driver/bson/primitive" + // ResponseCampaignTransactionAll ... type ResponseCampaignTransactionAll struct { List []ResponseNatsCampaignTransaction `json:"list"` @@ -12,14 +14,14 @@ type ResponseNatsCampaignTransaction struct { ID string `json:"_id"` Cash float64 `json:"cash"` Campaign ResponseCampaignShortInfo `json:"campaign"` - Seller ResponseSellerInfo `json:"seller"` + Seller primitive.ObjectID `json:"seller"` Type string `json:"type"` RejectedReason string `json:"rejectedReason"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` Item *ResponseCampaignItemShortInfo `json:"item"` - ApprovedBy *ResponseStaffInfo `json:"approvedBy,omitempty"` - RejectedBy *ResponseStaffInfo `json:"rejectedBy,omitempty"` + ApprovedBy primitive.ObjectID `json:"approvedBy,omitempty"` + RejectedBy primitive.ObjectID `json:"rejectedBy,omitempty"` ApprovedAt string `json:"approvedAt,omitempty"` RejectedAt string `json:"rejectedAt,omitempty"` } From 8858688f0f5bed97ed78b7bc68be35bafed59ff4 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 24 Nov 2022 14:15:53 +0700 Subject: [PATCH 29/59] update options --- js/model/selly.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/model/selly.go b/js/model/selly.go index 856da44..68d3342 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -58,4 +58,8 @@ type CashFlowOptions struct { AffiliateTransactionCode string `json:"affiliateTransactionCode,omitempty"` AffiliateCampaignID string `json:"affiliateCampaignId,omitempty"` AffiliateCampaignName string `json:"affiliateCampaignName,omitempty"` + + // Campaign + CampaignID string `json:"campaignId,omitempty"` + CampaignName string `json:"campaignName,omitempty"` } From 83e9aef3c92d30816a7228c13fe130a66e4ad626 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Thu, 24 Nov 2022 15:44:25 +0700 Subject: [PATCH 30/59] add response --- model/campaign_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/campaign_response.go b/model/campaign_response.go index b563396..3a00735 100644 --- a/model/campaign_response.go +++ b/model/campaign_response.go @@ -16,6 +16,7 @@ type ResponseNatsCampaignTransaction struct { Campaign ResponseCampaignShortInfo `json:"campaign"` Seller primitive.ObjectID `json:"seller"` Type string `json:"type"` + Status string `json:"status"` RejectedReason string `json:"rejectedReason"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` From aff5a872e3f1ddb402c93ebf748594ca8b5e9fca Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Tue, 29 Nov 2022 13:54:39 +0700 Subject: [PATCH 31/59] add response --- model/campaign_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/campaign_response.go b/model/campaign_response.go index 3a00735..710ee47 100644 --- a/model/campaign_response.go +++ b/model/campaign_response.go @@ -25,6 +25,7 @@ type ResponseNatsCampaignTransaction struct { RejectedBy primitive.ObjectID `json:"rejectedBy,omitempty"` ApprovedAt string `json:"approvedAt,omitempty"` RejectedAt string `json:"rejectedAt,omitempty"` + CompletedAt string `json:"completedAt,omitempty"` } // ResponseCampaignShortInfo ... From 9cec9d8c2f6357cf77dc1868e6b842351ddbbe01 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:15:58 +0700 Subject: [PATCH 32/59] update field --- model/campaign_response.go | 39 +++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/model/campaign_response.go b/model/campaign_response.go index 710ee47..db8a90b 100644 --- a/model/campaign_response.go +++ b/model/campaign_response.go @@ -11,21 +11,22 @@ type ResponseCampaignTransactionAll struct { // ResponseNatsCampaignTransaction ... type ResponseNatsCampaignTransaction struct { - ID string `json:"_id"` - Cash float64 `json:"cash"` - Campaign ResponseCampaignShortInfo `json:"campaign"` - Seller primitive.ObjectID `json:"seller"` - Type string `json:"type"` - Status string `json:"status"` - RejectedReason string `json:"rejectedReason"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` - Item *ResponseCampaignItemShortInfo `json:"item"` - ApprovedBy primitive.ObjectID `json:"approvedBy,omitempty"` - RejectedBy primitive.ObjectID `json:"rejectedBy,omitempty"` - ApprovedAt string `json:"approvedAt,omitempty"` - RejectedAt string `json:"rejectedAt,omitempty"` - CompletedAt string `json:"completedAt,omitempty"` + ID string `json:"_id"` + Cash float64 `json:"cash"` + Campaign ResponseCampaignShortInfo `json:"campaign"` + Options ResponseCampaignTransactionOptions `json:"options"` + Seller primitive.ObjectID `json:"seller"` + Type string `json:"type"` + Status string `json:"status"` + RejectedReason string `json:"rejectedReason"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` + Item *ResponseCampaignItemShortInfo `json:"item"` + ApprovedBy primitive.ObjectID `json:"approvedBy,omitempty"` + RejectedBy primitive.ObjectID `json:"rejectedBy,omitempty"` + ApprovedAt string `json:"approvedAt,omitempty"` + RejectedAt string `json:"rejectedAt,omitempty"` + CompletedAt string `json:"completedAt,omitempty"` } // ResponseCampaignShortInfo ... @@ -41,3 +42,11 @@ type ResponseCampaignItemShortInfo struct { Name string `json:"name"` Status string `json:"status"` } + +// ResponseCampaignTransactionOptions ... +type ResponseCampaignTransactionOptions struct { + Link string `json:"link"` + SocialChannel string `json:"socialChannel"` + Milestone int64 `json:"milestone"` + MilestoneTitle string `json:"milestoneTitle"` +} From 7c05aa7011d716be204344841bd2f993f2630576 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Sun, 4 Dec 2022 20:43:54 +0700 Subject: [PATCH 33/59] get list affiliate-transaction --- client/affiliate.go | 36 ++++++++++++++++++++++++ model/affiliate_request.go | 12 ++++++++ model/affiliate_response.go | 56 +++++++++++++++++++++++++++++++++++++ subject/affiliate.go | 13 +++++++++ subject/config.go | 2 ++ 5 files changed, 119 insertions(+) create mode 100644 client/affiliate.go create mode 100644 model/affiliate_request.go create mode 100644 model/affiliate_response.go create mode 100644 subject/affiliate.go diff --git a/client/affiliate.go b/client/affiliate.go new file mode 100644 index 0000000..58e8bd0 --- /dev/null +++ b/client/affiliate.go @@ -0,0 +1,36 @@ +package client + +import ( + "encoding/json" + "errors" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// Affiliate ... +type Affiliate struct{} + +// GetAffiliate ... +func GetAffiliate() Affiliate { + return Affiliate{} +} + +// GetTransactions ... +func (w Affiliate) GetTransactions(p model.GetTransactionsRequest) (*model.GetTransactionsResponse, error) { + msg, err := natsio.GetServer().Request(subject.Affiliate.GetTransactions, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.GetTransactionsResponse `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 +} diff --git a/model/affiliate_request.go b/model/affiliate_request.go new file mode 100644 index 0000000..a4aa104 --- /dev/null +++ b/model/affiliate_request.go @@ -0,0 +1,12 @@ +package model + +// GetTransactionsRequest ... +type GetTransactionsRequest struct { + Page int64 `json:"page"` + Limit int64 `json:"limit"` + Keyword string `json:"keyword"` + Statuses string `json:"statuses"` + Source string `json:"source"` + Campaign string `json:"campaign"` + Seller string `json:"seller"` +} diff --git a/model/affiliate_response.go b/model/affiliate_response.go new file mode 100644 index 0000000..5ab3245 --- /dev/null +++ b/model/affiliate_response.go @@ -0,0 +1,56 @@ +package model + +import "time" + +// GetTransactionsResponse ... +type GetTransactionsResponse struct { + Total int64 `json:"total"` + Limit int64 `json:"limit"` + List []TransactionInfo `json:"list"` +} + +// TransactionInfo ... +type TransactionInfo struct { + ID string `json:"_id"` + Code string `json:"code"` + Campaign ResponseCampaignShort `json:"campaign"` + Seller ResponseSellerInfo `json:"seller"` + Source string `json:"source"` + Commission ResponseCampaignCommission `json:"commission"` + EstimateSellerCommission float64 `json:"estimateSellerCommission"` + TransactionTime time.Time `json:"transactionTime"` + Status string `json:"status"` + RejectedReason string `json:"rejectedReason"` + EstimateCashbackAt time.Time `json:"estimateCashbackAt"` +} + +// ResponseCampaignCommission ... +type ResponseCampaignCommission struct { + Real float64 `json:"real"` + SellerPercent float64 `json:"sellerPercent"` + Selly float64 `json:"selly"` + Seller float64 `json:"seller"` +} + +// ResponseCampaignShort ... +type ResponseCampaignShort struct { + ID string `json:"_id"` + Name string `json:"name"` + Logo *FilePhoto `json:"logo"` +} + +var ( + transcationInfoTitle = []string{ + "ID lượt thưởng", + "Tên sản phẩm", + "ID Seller", + "Tên Seller", + "Thời gian phát sinh", + "Thời gian đối soát dự kiến", + "Trạng thái", + "Hoa hồng nhận từ đối tác", + "Phần trăm hóa hồng cho Seller", + "Hoa hồng cho Seller", + "Hoa hồng cho Selly", + } +) diff --git a/subject/affiliate.go b/subject/affiliate.go new file mode 100644 index 0000000..cd59597 --- /dev/null +++ b/subject/affiliate.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getAffiliateValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Affiliate, val) +} + +var Affiliate = struct { + GetTransactions string +}{ + GetTransactions: getAffiliateValue("get_transactions"), +} diff --git a/subject/config.go b/subject/config.go index bb4e723..1954121 100644 --- a/subject/config.go +++ b/subject/config.go @@ -15,6 +15,7 @@ var prefixes = struct { Staff string Segment string Campaign string + Affiliate string }{ Communication: "communication", Order: "order", @@ -30,4 +31,5 @@ var prefixes = struct { Staff: "staff", Segment: "segment", Campaign: "campaign", + Affiliate: "affiliate", } From 599d36120e37549b914c088f164c70f7552c39c7 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Sun, 4 Dec 2022 20:57:25 +0700 Subject: [PATCH 34/59] edit getTransactionRequest --- model/affiliate_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/affiliate_request.go b/model/affiliate_request.go index a4aa104..7e04190 100644 --- a/model/affiliate_request.go +++ b/model/affiliate_request.go @@ -5,7 +5,7 @@ type GetTransactionsRequest struct { Page int64 `json:"page"` Limit int64 `json:"limit"` Keyword string `json:"keyword"` - Statuses string `json:"statuses"` + status string `json:"status"` Source string `json:"source"` Campaign string `json:"campaign"` Seller string `json:"seller"` From d7c2660ae29b67e8028a0bb920d3513cebf5b2b2 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Sun, 4 Dec 2022 21:01:43 +0700 Subject: [PATCH 35/59] edit getTransactionRequest --- model/affiliate_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/affiliate_request.go b/model/affiliate_request.go index 7e04190..1e6a369 100644 --- a/model/affiliate_request.go +++ b/model/affiliate_request.go @@ -5,7 +5,7 @@ type GetTransactionsRequest struct { Page int64 `json:"page"` Limit int64 `json:"limit"` Keyword string `json:"keyword"` - status string `json:"status"` + Status string `json:"status"` Source string `json:"source"` Campaign string `json:"campaign"` Seller string `json:"seller"` From 5b7d8329aef2d5c623060db3292e55b11f16e22b Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Sun, 4 Dec 2022 21:05:25 +0700 Subject: [PATCH 36/59] update model gettransaction --- model/affiliate_request.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/model/affiliate_request.go b/model/affiliate_request.go index 1e6a369..359391b 100644 --- a/model/affiliate_request.go +++ b/model/affiliate_request.go @@ -1,12 +1,16 @@ package model +import "time" + // GetTransactionsRequest ... type GetTransactionsRequest struct { - Page int64 `json:"page"` - Limit int64 `json:"limit"` - Keyword string `json:"keyword"` - Status string `json:"status"` - Source string `json:"source"` - Campaign string `json:"campaign"` - Seller string `json:"seller"` + Page int64 `json:"page"` + Limit int64 `json:"limit"` + Keyword string `json:"keyword"` + Status string `json:"status"` + Source string `json:"source"` + Campaign string `json:"campaign"` + Seller string `json:"seller"` + FromAt time.Time `json:"fromAt"` + ToAt time.Time `json:"toAt"` } From 0d69cc3357375c90c46e54211fd20a0f83b4dc48 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Sun, 4 Dec 2022 21:25:42 +0700 Subject: [PATCH 37/59] change model get transaction --- model/affiliate_response.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/model/affiliate_response.go b/model/affiliate_response.go index 5ab3245..80a4707 100644 --- a/model/affiliate_response.go +++ b/model/affiliate_response.go @@ -1,7 +1,5 @@ package model -import "time" - // GetTransactionsResponse ... type GetTransactionsResponse struct { Total int64 `json:"total"` @@ -18,10 +16,10 @@ type TransactionInfo struct { Source string `json:"source"` Commission ResponseCampaignCommission `json:"commission"` EstimateSellerCommission float64 `json:"estimateSellerCommission"` - TransactionTime time.Time `json:"transactionTime"` + TransactionTime string `json:"transactionTime"` Status string `json:"status"` RejectedReason string `json:"rejectedReason"` - EstimateCashbackAt time.Time `json:"estimateCashbackAt"` + EstimateCashbackAt string `json:"estimateCashbackAt"` } // ResponseCampaignCommission ... From 99894963e61c5b58ae6103ab48c510682ecd2c69 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Mon, 5 Dec 2022 12:04:43 +0700 Subject: [PATCH 38/59] add response --- model/campaign_response.go | 39 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/model/campaign_response.go b/model/campaign_response.go index db8a90b..9619035 100644 --- a/model/campaign_response.go +++ b/model/campaign_response.go @@ -11,22 +11,24 @@ type ResponseCampaignTransactionAll struct { // ResponseNatsCampaignTransaction ... type ResponseNatsCampaignTransaction struct { - ID string `json:"_id"` - Cash float64 `json:"cash"` - Campaign ResponseCampaignShortInfo `json:"campaign"` - Options ResponseCampaignTransactionOptions `json:"options"` - Seller primitive.ObjectID `json:"seller"` - Type string `json:"type"` - Status string `json:"status"` - RejectedReason string `json:"rejectedReason"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` - Item *ResponseCampaignItemShortInfo `json:"item"` - ApprovedBy primitive.ObjectID `json:"approvedBy,omitempty"` - RejectedBy primitive.ObjectID `json:"rejectedBy,omitempty"` - ApprovedAt string `json:"approvedAt,omitempty"` - RejectedAt string `json:"rejectedAt,omitempty"` - CompletedAt string `json:"completedAt,omitempty"` + ID string `json:"_id"` + Cash float64 `json:"cash"` + Campaign ResponseCampaignShortInfo `json:"campaign"` + Options ResponseCampaignTransactionOptions `json:"options"` + Seller primitive.ObjectID `json:"seller"` + Type string `json:"type"` + Status string `json:"status"` + RejectedReason string `json:"rejectedReason"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` + Item *ResponseCampaignItemShortInfo `json:"item"` + ApprovedBy primitive.ObjectID `json:"approvedBy,omitempty"` + RejectedBy primitive.ObjectID `json:"rejectedBy,omitempty"` + ApprovedAt string `json:"approvedAt,omitempty"` + RejectedAt string `json:"rejectedAt,omitempty"` + CompletedAt string `json:"completedAt,omitempty"` + RejectReason string `json:"rejectReason,omitempty"` + AdminConfirmData *ResponseCampaignTransactionAdminConfirmData `json:"adminConfirmData,omitempty"` } // ResponseCampaignShortInfo ... @@ -50,3 +52,8 @@ type ResponseCampaignTransactionOptions struct { Milestone int64 `json:"milestone"` MilestoneTitle string `json:"milestoneTitle"` } + +// ResponseCampaignTransactionAdminConfirmData ... +type ResponseCampaignTransactionAdminConfirmData struct { + FriendPublicTotal int64 `json:"friendPublicTotal"` +} From 23eebdce8adc9f9b0adc14c8a33b41b0257434c2 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Wed, 7 Dec 2022 13:48:43 +0700 Subject: [PATCH 39/59] change code --- model/affiliate_response.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/model/affiliate_response.go b/model/affiliate_response.go index 80a4707..bb8f804 100644 --- a/model/affiliate_response.go +++ b/model/affiliate_response.go @@ -36,19 +36,3 @@ type ResponseCampaignShort struct { Name string `json:"name"` Logo *FilePhoto `json:"logo"` } - -var ( - transcationInfoTitle = []string{ - "ID lượt thưởng", - "Tên sản phẩm", - "ID Seller", - "Tên Seller", - "Thời gian phát sinh", - "Thời gian đối soát dự kiến", - "Trạng thái", - "Hoa hồng nhận từ đối tác", - "Phần trăm hóa hồng cho Seller", - "Hoa hồng cho Seller", - "Hoa hồng cho Selly", - } -) From aa3a201b1819006dc786a4b788adf6d58c03b609 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Mon, 12 Dec 2022 14:07:28 +0700 Subject: [PATCH 40/59] edit response warehouse --- model/warehouse_response.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index c667290..79b02c4 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -129,19 +129,21 @@ type ResponseLatLng struct { // WarehouseNatsResponse ... type WarehouseNatsResponse struct { - ID string `json:"_id"` - Staff string `json:"staff"` - BusinessType string `json:"businessType"` - Name string `json:"name"` - SearchString string `json:"searchString"` - Slug string `json:"slug"` - Status string `json:"status"` - Supplier string `json:"supplier"` - Contact ResponseWarehouseContact `json:"contact"` - Location ResponseWarehouseLocation `json:"location"` - Configurations WarehouseConfiguration `json:"configurations"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + ID string `json:"_id"` + Staff string `json:"staff"` + BusinessType string `json:"businessType"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + Status string `json:"status"` + Supplier string `json:"supplier"` + Contact ResponseWarehouseContact `json:"contact"` + Location ResponseWarehouseLocation `json:"location"` + Configurations WarehouseConfiguration `json:"configurations"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + IsPendingActive bool `json:"isPendingActive"` + ReasonPendingInactive string `json:"reasonPendingInactive"` } // WarehouseInfo ... From c1a5444e5e948184fc7b68ff87d21fad2e5d1c82 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Mon, 12 Dec 2022 14:25:40 +0700 Subject: [PATCH 41/59] edit res warehouse --- model/warehouse_response.go | 1 - 1 file changed, 1 deletion(-) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 79b02c4..b73807e 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -142,7 +142,6 @@ type WarehouseNatsResponse struct { Configurations WarehouseConfiguration `json:"configurations"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` - IsPendingActive bool `json:"isPendingActive"` ReasonPendingInactive string `json:"reasonPendingInactive"` } From 67a5afa9338886dc3394c78f1e9725650ce0c2e8 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Wed, 14 Dec 2022 10:52:38 +0700 Subject: [PATCH 42/59] add field IsPendingInactive --- model/warehouse_response.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index b73807e..6359ae3 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -143,6 +143,7 @@ type WarehouseNatsResponse struct { CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` ReasonPendingInactive string `json:"reasonPendingInactive"` + IsPendingInactive bool `json:"isPendingInactive"` } // WarehouseInfo ... From ea80206619deaf97867f35c8f8b00588c1e9614b Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 20 Dec 2022 11:13:11 +0700 Subject: [PATCH 43/59] add field from-to holiday WarehouseNatsResponse --- model/warehouse_response.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 6359ae3..78427f3 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -144,6 +144,8 @@ type WarehouseNatsResponse struct { UpdatedAt time.Time `json:"updatedAt"` ReasonPendingInactive string `json:"reasonPendingInactive"` IsPendingInactive bool `json:"isPendingInactive"` + HolidayFrom time.Time `json:"holidayFrom"` + HolidayTo time.Time `json:"holidayTo"` } // WarehouseInfo ... From 77ec5ee6c1f1f3278c24df6298bb27adead628cc Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 20 Dec 2022 11:48:36 +0700 Subject: [PATCH 44/59] delete field form-to-holiday in WarehouseNatsResponse --- model/warehouse_response.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 78427f3..6359ae3 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -144,8 +144,6 @@ type WarehouseNatsResponse struct { UpdatedAt time.Time `json:"updatedAt"` ReasonPendingInactive string `json:"reasonPendingInactive"` IsPendingInactive bool `json:"isPendingInactive"` - HolidayFrom time.Time `json:"holidayFrom"` - HolidayTo time.Time `json:"holidayTo"` } // WarehouseInfo ... From 067db844897e007e19e9f94336820d30deccee0a Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 03:32:15 +0700 Subject: [PATCH 45/59] add get,create, update supplier-holiday --- client/warehouse.go | 63 +++++++++++++++++++++++++++++++++++++ model/warehouse_request.go | 25 +++++++++++++++ model/warehouse_response.go | 17 ++++++++++ subject/warehouse.go | 6 ++++ 4 files changed, 111 insertions(+) diff --git a/client/warehouse.go b/client/warehouse.go index fb391ca..664df43 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -182,3 +182,66 @@ func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatu } return nil } + +// CreateSupplierHoliday ... +func (w Warehouse) CreateSupplierHoliday(p model.SupplierHolidayCreatePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.CreateSupplierHoliday, toBytes(p)) + if err != nil { + return err + } + + var r struct { + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return fmt.Errorf("nats: create_supplier_holiday %v", err) + } + if r.Error != "" { + return errors.New(r.Error) + } + return nil +} + +// UpdateSupplierHoliday ... +func (w Warehouse) UpdateSupplierHoliday(p model.SupplierHolidayUpdatePayload) error { + msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateSupplierHoliday, toBytes(p)) + if err != nil { + return err + } + + var r struct { + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return fmt.Errorf("nats: create_supplier_holiday %v", err) + } + if r.Error != "" { + return errors.New(r.Error) + } + return nil +} + +// GetSupplierHoliday ... +func (w Warehouse) GetSupplierHoliday(p model.GetSupplierHolidayRequest) (*model.ResponseSupplierHoliday, error) { + msg, err := natsio.GetServer().Request(subject.Warehouse.GetSupplierHoliday, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseSupplierHoliday `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 +} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index b6cecb1..c2b267a 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -113,3 +113,28 @@ type WarehouseORUpdateDeliveryStatus struct { OrderID string `json:"orderId"` DeliveryStatus string `json:"deliveryStatus"` } + +// SupplierHolidayCreatePayload ... +type SupplierHolidayCreatePayload struct { + Supplier string `json:"supplier"` + Title string `json:"title"` + From string `json:"from"` + To string `json:"to"` + Warehouses []string `json:"warehouses"` + IsApplyAll bool `json:"isApplyAll"` +} + +// SupplierHolidayUpdatePayload ... +type SupplierHolidayUpdatePayload struct { + Supplier string `json:"supplier"` + Title string `json:"title"` + From string `json:"from"` + To string `json:"to"` + Warehouses []string `json:"warehouses"` + IsApplyAll bool `json:"isApplyAll"` +} + +// GetSupplierHolidayRequest ... +type GetSupplierHolidayRequest struct { + Conditions interface{} `json:"conditions"` +} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 6359ae3..e5d556b 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -172,3 +172,20 @@ type GetWarehousesResponse struct { Limit int64 `json:"limit"` List []WarehouseInfo `json:"list"` } + +// ResponseWarehouseShort ... +type ResponseWarehouseShort struct { + ID string `json:"_id"` + Name string `json:"name"` +} + +// ResponseSupplierHoliday ... +type ResponseSupplierHoliday struct { + Title string `json:"title"` + From string `json:"from"` + To string `json:"to"` + Status string `json:"status"` + Reason string `json:"reason"` + IsApplyAll bool `json:"isApplyAll"` + Warehouses []ResponseWarehouseShort `json:"warehouses"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index bb184b5..51be4c7 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -26,6 +26,9 @@ var Warehouse = struct { UpdateIsClosedSupplier string GetWarehouses string UpdateORDeliveryStatus string + CreateSupplierHoliday string + UpdateSupplierHoliday string + GetSupplierHoliday string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), @@ -46,4 +49,7 @@ var Warehouse = struct { UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), GetWarehouses: getWarehouseValue("get_warehouses"), UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), + CreateSupplierHoliday: getWarehouseValue("create_supplier_holiday"), + UpdateSupplierHoliday: getWarehouseValue("update_supplier_holiday"), + GetSupplierHoliday: getWarehouseValue("get_supplier_holiday"), } From e00922334c0661b1ba08dd589ca763960c7f8a26 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 11:23:31 +0700 Subject: [PATCH 46/59] fix add file source supplierHolidayPayloadCreate --- model/warehouse_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index c2b267a..6ea5bed 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -132,6 +132,7 @@ type SupplierHolidayUpdatePayload struct { To string `json:"to"` Warehouses []string `json:"warehouses"` IsApplyAll bool `json:"isApplyAll"` + Source string `json:"source"` } // GetSupplierHolidayRequest ... From 5ec216067db1071740e21c4982aada9bf25631f5 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 11:36:33 +0700 Subject: [PATCH 47/59] add field supplier-holiday --- model/warehouse_request.go | 1 + 1 file changed, 1 insertion(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 6ea5bed..550e870 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -122,6 +122,7 @@ type SupplierHolidayCreatePayload struct { To string `json:"to"` Warehouses []string `json:"warehouses"` IsApplyAll bool `json:"isApplyAll"` + Source string `json:"source"` } // SupplierHolidayUpdatePayload ... From daac1da25daf78fb46456924e11fca0b2bb15c60 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 14:47:09 +0700 Subject: [PATCH 48/59] delete suppler-holiday && add checkTokenSupplier --- client/supplier.go | 20 ++++++++++++ client/warehouse.go | 63 ------------------------------------- model/supplier_request.go | 5 +++ model/warehouse_request.go | 27 ---------------- model/warehouse_response.go | 17 ---------- subject/supplier.go | 2 ++ subject/warehouse.go | 6 ---- 7 files changed, 27 insertions(+), 113 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index 9b53826..b10f982 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -178,3 +178,23 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } return nil } + +// CheckTokenSupplier ... +func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseSupplierInfo, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Error string `json:"error"` + Data *model.ResponseSupplierInfo `json:"data"` + } + 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 +} diff --git a/client/warehouse.go b/client/warehouse.go index 664df43..fb391ca 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -182,66 +182,3 @@ func (w Warehouse) UpdateORDeliveryStatus(p model.WarehouseORUpdateDeliveryStatu } return nil } - -// CreateSupplierHoliday ... -func (w Warehouse) CreateSupplierHoliday(p model.SupplierHolidayCreatePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.CreateSupplierHoliday, toBytes(p)) - if err != nil { - return err - } - - var r struct { - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return fmt.Errorf("nats: create_supplier_holiday %v", err) - } - if r.Error != "" { - return errors.New(r.Error) - } - return nil -} - -// UpdateSupplierHoliday ... -func (w Warehouse) UpdateSupplierHoliday(p model.SupplierHolidayUpdatePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateSupplierHoliday, toBytes(p)) - if err != nil { - return err - } - - var r struct { - Error string `json:"error"` - } - - if err = json.Unmarshal(msg.Data, &r); err != nil { - return fmt.Errorf("nats: create_supplier_holiday %v", err) - } - if r.Error != "" { - return errors.New(r.Error) - } - return nil -} - -// GetSupplierHoliday ... -func (w Warehouse) GetSupplierHoliday(p model.GetSupplierHolidayRequest) (*model.ResponseSupplierHoliday, error) { - msg, err := natsio.GetServer().Request(subject.Warehouse.GetSupplierHoliday, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.ResponseSupplierHoliday `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 -} diff --git a/model/supplier_request.go b/model/supplier_request.go index 18034af..63b5459 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -52,3 +52,8 @@ type SupplierCountReq struct { IDs []string `json:"ids"` Status string `json:"status"` // active,inactive } + +// CheckTokenSupplierPayload ... +type CheckTokenSupplierPayload struct { + Token string `json:"token"` +} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 550e870..b6cecb1 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -113,30 +113,3 @@ type WarehouseORUpdateDeliveryStatus struct { OrderID string `json:"orderId"` DeliveryStatus string `json:"deliveryStatus"` } - -// SupplierHolidayCreatePayload ... -type SupplierHolidayCreatePayload struct { - Supplier string `json:"supplier"` - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Warehouses []string `json:"warehouses"` - IsApplyAll bool `json:"isApplyAll"` - Source string `json:"source"` -} - -// SupplierHolidayUpdatePayload ... -type SupplierHolidayUpdatePayload struct { - Supplier string `json:"supplier"` - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Warehouses []string `json:"warehouses"` - IsApplyAll bool `json:"isApplyAll"` - Source string `json:"source"` -} - -// GetSupplierHolidayRequest ... -type GetSupplierHolidayRequest struct { - Conditions interface{} `json:"conditions"` -} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index e5d556b..6359ae3 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -172,20 +172,3 @@ type GetWarehousesResponse struct { Limit int64 `json:"limit"` List []WarehouseInfo `json:"list"` } - -// ResponseWarehouseShort ... -type ResponseWarehouseShort struct { - ID string `json:"_id"` - Name string `json:"name"` -} - -// ResponseSupplierHoliday ... -type ResponseSupplierHoliday struct { - Title string `json:"title"` - From string `json:"from"` - To string `json:"to"` - Status string `json:"status"` - Reason string `json:"reason"` - IsApplyAll bool `json:"isApplyAll"` - Warehouses []ResponseWarehouseShort `json:"warehouses"` -} diff --git a/subject/supplier.go b/subject/supplier.go index edc797f..fe041bf 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -12,10 +12,12 @@ var Supplier = struct { FindAll string FindAllOld string Count string + CheckTokenSupplier string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), Count: getSupplierValue("count"), + CheckTokenSupplier: getSupplierValue("check_token_supplier"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index 51be4c7..bb184b5 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -26,9 +26,6 @@ var Warehouse = struct { UpdateIsClosedSupplier string GetWarehouses string UpdateORDeliveryStatus string - CreateSupplierHoliday string - UpdateSupplierHoliday string - GetSupplierHoliday string }{ CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), @@ -49,7 +46,4 @@ var Warehouse = struct { UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), GetWarehouses: getWarehouseValue("get_warehouses"), UpdateORDeliveryStatus: getWarehouseValue("update_or_delivery_status"), - CreateSupplierHoliday: getWarehouseValue("create_supplier_holiday"), - UpdateSupplierHoliday: getWarehouseValue("update_supplier_holiday"), - GetSupplierHoliday: getWarehouseValue("get_supplier_holiday"), } From b5d7425114140cc612c11814b4b6bba2b98cc11a Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Fri, 23 Dec 2022 15:13:35 +0700 Subject: [PATCH 49/59] add field permission checkTokenSupplier --- model/supplier_request.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index 63b5459..7ba0018 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -55,5 +55,6 @@ type SupplierCountReq struct { // CheckTokenSupplierPayload ... type CheckTokenSupplierPayload struct { - Token string `json:"token"` + Token string `json:"token"` + Permissions []string `json:"permissions"` } From 54f5c45488413b1df64ba153edcd3f178d58057a Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Sat, 24 Dec 2022 13:50:58 +0700 Subject: [PATCH 50/59] edit response checkTokenSupplier --- client/supplier.go | 6 +++--- model/supplier_response.go | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index b10f982..56e0670 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -180,15 +180,15 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } // CheckTokenSupplier ... -func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseSupplierInfo, error) { +func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseCheckTokenSupplier, error) { msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p)) if err != nil { return nil, err } var r struct { - Error string `json:"error"` - Data *model.ResponseSupplierInfo `json:"data"` + Error string `json:"error"` + Data *model.ResponseCheckTokenSupplier `json:"data"` } if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err diff --git a/model/supplier_response.go b/model/supplier_response.go index 2b9dd10..21dce15 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -33,3 +33,10 @@ type SupplierAll struct { type SupplierCountRes struct { Total int64 `json:"total"` } + +// ResponseCheckTokenSupplier ... +type ResponseCheckTokenSupplier struct { + Invalid bool `json:"invalid"` + Reason string `json:"reason"` + Supplier ResponseSupplierInfo `json:"supplier"` +} From 71be64db27fe0387b78d6b41fec14edeecb855c0 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:16:08 +0700 Subject: [PATCH 51/59] edit requestPayload check token supplier --- model/supplier_request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index 7ba0018..88027f2 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -55,6 +55,6 @@ type SupplierCountReq struct { // CheckTokenSupplierPayload ... type CheckTokenSupplierPayload struct { - Token string `json:"token"` - Permissions []string `json:"permissions"` + Token string `json:"token"` + Permissions string `json:"permissions"` } From 7f548f0931ee8804a2402bc024bc5cdd875c6741 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:37:48 +0700 Subject: [PATCH 52/59] fix --- model/supplier_request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/supplier_request.go b/model/supplier_request.go index 88027f2..7ba0018 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -55,6 +55,6 @@ type SupplierCountReq struct { // CheckTokenSupplierPayload ... type CheckTokenSupplierPayload struct { - Token string `json:"token"` - Permissions string `json:"permissions"` + Token string `json:"token"` + Permissions []string `json:"permissions"` } From ec9dedad0d743f5e8bf689e881b480a6606d4bfa Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Tue, 27 Dec 2022 23:49:25 +0700 Subject: [PATCH 53/59] change res check-token-supllier --- model/supplier_response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index 21dce15..2c90904 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -36,7 +36,7 @@ type SupplierCountRes struct { // ResponseCheckTokenSupplier ... type ResponseCheckTokenSupplier struct { - Invalid bool `json:"invalid"` + IsValid bool `json:"isValid"` Reason string `json:"reason"` Supplier ResponseSupplierInfo `json:"supplier"` } From 4fd0a89acd4eefb0e69d571824c28b59ff3e6877 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Thu, 29 Dec 2022 13:49:04 +0700 Subject: [PATCH 54/59] edit check token supplier user --- client/supplier.go | 20 -------------------- client/supplier_user.go | 20 ++++++++++++++++++++ model/supplier_request.go | 6 ------ model/supplier_response.go | 7 ------- model/supplier_user_request.go | 6 ++++++ model/supplier_user_response.go | 13 +++++++++++++ subject/supplier.go | 2 -- subject/supplier_user.go | 2 ++ 8 files changed, 41 insertions(+), 35 deletions(-) diff --git a/client/supplier.go b/client/supplier.go index 56e0670..9b53826 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -178,23 +178,3 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh } return nil } - -// CheckTokenSupplier ... -func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseCheckTokenSupplier, error) { - msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p)) - if err != nil { - return nil, err - } - - var r struct { - Error string `json:"error"` - Data *model.ResponseCheckTokenSupplier `json:"data"` - } - 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 -} diff --git a/client/supplier_user.go b/client/supplier_user.go index fb6a2db..535f973 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -138,3 +138,23 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP return r.Data, nil } + +// CheckTokenSupplier ... +func (s SupplierUser) CheckTokenSupplier(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { + msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckToken, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Error string `json:"error"` + Data *model.ResponseCheckTokenSupplierUser `json:"data"` + } + 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 +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 7ba0018..18034af 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -52,9 +52,3 @@ type SupplierCountReq struct { IDs []string `json:"ids"` Status string `json:"status"` // active,inactive } - -// CheckTokenSupplierPayload ... -type CheckTokenSupplierPayload struct { - Token string `json:"token"` - Permissions []string `json:"permissions"` -} diff --git a/model/supplier_response.go b/model/supplier_response.go index 2c90904..2b9dd10 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -33,10 +33,3 @@ type SupplierAll struct { type SupplierCountRes struct { Total int64 `json:"total"` } - -// ResponseCheckTokenSupplier ... -type ResponseCheckTokenSupplier struct { - IsValid bool `json:"isValid"` - Reason string `json:"reason"` - Supplier ResponseSupplierInfo `json:"supplier"` -} diff --git a/model/supplier_user_request.go b/model/supplier_user_request.go index 66ccb17..2e1c066 100644 --- a/model/supplier_user_request.go +++ b/model/supplier_user_request.go @@ -49,3 +49,9 @@ type ResetPasswordRequest struct { ID string `json:"_id"` Password string `json:"password"` } + +// CheckTokenSupplierUserPayload ... +type CheckTokenSupplierUserPayload struct { + Token string `json:"token"` + Permissions []string `json:"permissions"` +} diff --git a/model/supplier_user_response.go b/model/supplier_user_response.go index 38a1d0c..3b98d1c 100644 --- a/model/supplier_user_response.go +++ b/model/supplier_user_response.go @@ -11,3 +11,16 @@ type CreateStaffResponse struct { type ResetPasswordResponse struct { Password string `json:"password"` } + +// ResponseCheckTokenSupplierUser ... +type ResponseCheckTokenSupplierUser struct { + IsValid bool `json:"isValid"` + Reason string `json:"reason"` + User ResponseSupplierUserInfo `json:"supplier"` +} + +type ResponseSupplierUserInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + SupplierID string `json:"supplierId"` +} diff --git a/subject/supplier.go b/subject/supplier.go index fe041bf..edc797f 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -12,12 +12,10 @@ var Supplier = struct { FindAll string FindAllOld string Count string - CheckTokenSupplier string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), Count: getSupplierValue("count"), - CheckTokenSupplier: getSupplierValue("check_token_supplier"), } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index adc2f1f..f954898 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -14,6 +14,7 @@ var SupplierUser = struct { UpdateStaff string UpdateStatus string ResetPassword string + CheckToken string }{ // Users CreateOwner: getSupplierUserValue("create_owner"), @@ -22,4 +23,5 @@ var SupplierUser = struct { UpdateStaff: getSupplierUserValue("update_staff"), UpdateStatus: getSupplierUserValue("update_status"), ResetPassword: getSupplierUserValue("reset_password"), + CheckToken: getSupplierUserValue("check_token"), } From 64c7fca2cc345550887108e1c2989eaf967ebf73 Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Thu, 29 Dec 2022 13:58:16 +0700 Subject: [PATCH 55/59] rename subj --- client/supplier_user.go | 2 +- subject/supplier_user.go | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/supplier_user.go b/client/supplier_user.go index 535f973..18ca0db 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -141,7 +141,7 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP // CheckTokenSupplier ... func (s SupplierUser) CheckTokenSupplier(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { - msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckToken, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckTokenSupplierUser, toBytes(p)) if err != nil { return nil, err } diff --git a/subject/supplier_user.go b/subject/supplier_user.go index f954898..5c99eb4 100644 --- a/subject/supplier_user.go +++ b/subject/supplier_user.go @@ -8,20 +8,20 @@ func getSupplierUserValue(val string) string { var SupplierUser = struct { // Users - CreateOwner string - UpdateOwner string - CreateStaff string - UpdateStaff string - UpdateStatus string - ResetPassword string - CheckToken string + CreateOwner string + UpdateOwner string + CreateStaff string + UpdateStaff string + UpdateStatus string + ResetPassword string + CheckTokenSupplierUser string }{ // Users - CreateOwner: getSupplierUserValue("create_owner"), - UpdateOwner: getSupplierUserValue("update_owner"), - CreateStaff: getSupplierUserValue("create_staff"), - UpdateStaff: getSupplierUserValue("update_staff"), - UpdateStatus: getSupplierUserValue("update_status"), - ResetPassword: getSupplierUserValue("reset_password"), - CheckToken: getSupplierUserValue("check_token"), + CreateOwner: getSupplierUserValue("create_owner"), + UpdateOwner: getSupplierUserValue("update_owner"), + CreateStaff: getSupplierUserValue("create_staff"), + UpdateStaff: getSupplierUserValue("update_staff"), + UpdateStatus: getSupplierUserValue("update_status"), + ResetPassword: getSupplierUserValue("reset_password"), + CheckTokenSupplierUser: getSupplierUserValue("check_token_supplier_user"), } From 9b758ee7856a12748789322cf7379eff3985399f Mon Sep 17 00:00:00 2001 From: buiphuan0211 <57066954+buiphuan0211@users.noreply.github.com> Date: Thu, 29 Dec 2022 14:10:44 +0700 Subject: [PATCH 56/59] fix --- client/supplier_user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/supplier_user.go b/client/supplier_user.go index 18ca0db..7da7f6a 100644 --- a/client/supplier_user.go +++ b/client/supplier_user.go @@ -139,8 +139,8 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP return r.Data, nil } -// CheckTokenSupplier ... -func (s SupplierUser) CheckTokenSupplier(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { +// CheckTokenSupplierUser ... +func (s SupplierUser) CheckTokenSupplierUser(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) { msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckTokenSupplierUser, toBytes(p)) if err != nil { return nil, err From 39614ca4c544430d6ba3930ee041ed662785ceb5 Mon Sep 17 00:00:00 2001 From: anbuiselly <105765792+anbuiselly@users.noreply.github.com> Date: Tue, 10 Jan 2023 11:27:36 +0700 Subject: [PATCH 57/59] add get-detail-supplier-info --- client/supplier.go | 22 ++++++++++++++++++++++ model/supplier_request.go | 5 +++++ subject/supplier.go | 2 ++ 3 files changed, 29 insertions(+) diff --git a/client/supplier.go b/client/supplier.go index 9b53826..149aad6 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -38,6 +38,28 @@ func (s Supplier) GetListSupplierInfo(p model.GetSupplierRequest) ([]*model.Resp return r.Data, nil } +// GetDetailSupplierInfo ... +func (s Supplier) GetDetailSupplierInfo(p model.GetDetailSupplierRequest) (*model.ResponseSupplierInfo, error) { + msg, err := natsio.GetServer().Request(subject.Supplier.GetDetailSupplierInfo, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseSupplierInfo `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 +} + func (s Supplier) GetSupplierContractBySupplierID(p model.GetSupplierContractRequest) (*model.ResponseSupplierContract, error) { msg, err := natsio.GetServer().Request(subject.Supplier.GetSupplierContractBySupplierID, toBytes(p)) if err != nil { diff --git a/model/supplier_request.go b/model/supplier_request.go index 18034af..5d6fbe2 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -9,6 +9,11 @@ type GetSupplierRequest struct { ListID []primitive.ObjectID `json:"listID"` } +// GetDetailSupplierRequest ... +type GetDetailSupplierRequest struct { + Supplier string `json:"supplier"` +} + type GetSupplierContractRequest struct { SupplierID primitive.ObjectID `json:"supplierID"` } diff --git a/subject/supplier.go b/subject/supplier.go index edc797f..4fc3d32 100644 --- a/subject/supplier.go +++ b/subject/supplier.go @@ -8,12 +8,14 @@ func getSupplierValue(val string) string { var Supplier = struct { GetListSupplierInfo string + GetDetailSupplierInfo string GetSupplierContractBySupplierID string FindAll string FindAllOld string Count string }{ GetListSupplierInfo: getSupplierValue("get_list_supplier_info"), + GetDetailSupplierInfo: getSupplierValue("get_detail_supplier_info"), GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"), FindAll: getSupplierValue("find_all"), FindAllOld: getSupplierValue("find_all_old"), From 67b99f7774427e7bdfe393c53e2f31ff040ce78a Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Wed, 11 Jan 2023 09:27:49 +0700 Subject: [PATCH 58/59] campaign-get-seller-statistic --- client/campaign.go | 22 ++++++++++++++++++++++ model/campaign_request.go | 10 +++++++++- model/campaign_response.go | 29 +++++++++++++++++++++++++++++ subject/campaign.go | 2 ++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/client/campaign.go b/client/campaign.go index 82649d3..16fa6e4 100644 --- a/client/campaign.go +++ b/client/campaign.go @@ -34,3 +34,25 @@ func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) } return r.Data, nil } + +// GetCampaignSellerStatistic .... +func (c Campaign) GetCampaignSellerStatistic(req model.GetCampaignSellerStatisticBySellerIDs) (*model.ResponseCampaignSellerStatistic, error) { + msg, err := natsio.GetServer().Request(subject.Campaign.GetCampaignSellerStatisticBySellerIDs, toBytes(req)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseCampaignSellerStatistic `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 +} diff --git a/model/campaign_request.go b/model/campaign_request.go index 71227e4..8033196 100644 --- a/model/campaign_request.go +++ b/model/campaign_request.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "go.mongodb.org/mongo-driver/bson/primitive" + "time" +) // GetCampaignTransactionsRequest ... type GetCampaignTransactionsRequest struct { @@ -12,3 +15,8 @@ type GetCampaignTransactionsRequest struct { Page int64 `json:"page"` Limit int64 `json:"limit"` } + +// GetCampaignSellerStatisticBySellerIDs ... +type GetCampaignSellerStatisticBySellerIDs struct { + SellerIDs []primitive.ObjectID +} diff --git a/model/campaign_response.go b/model/campaign_response.go index 9619035..65199e9 100644 --- a/model/campaign_response.go +++ b/model/campaign_response.go @@ -57,3 +57,32 @@ type ResponseCampaignTransactionOptions struct { type ResponseCampaignTransactionAdminConfirmData struct { FriendPublicTotal int64 `json:"friendPublicTotal"` } + +// ResponseCampaignSellerStatisticList ... +type ResponseCampaignSellerStatisticList struct { + List []ResponseCampaignSellerStatistic `json:"list"` +} + +// ResponseCampaignSellerStatistic ... +type ResponseCampaignSellerStatistic struct { + SellerID primitive.ObjectID `json:"sellerId"` + Statistic CampaignSellerStatistic `json:"Statistic"` +} + +// CampaignSellerStatistic ... +type CampaignSellerStatistic struct { + TotalNotRejected int64 `bson:"totalNotRejected" json:"totalNotRejected"` + CashTotalNotRejected float64 `bson:"cashTotalNotRejected" json:"cashTotalNotRejected"` + + TotalCompleted int64 `bson:"totalCompleted" json:"totalCompleted"` + CashTotalCompleted float64 `bson:"cashTotalCompleted" json:"cashTotalCompleted"` + + TotalPending int64 `bson:"totalPending" json:"totalPending"` + CashTotalPending float64 `bson:"cashTotalPending" json:"cashTotalPending"` + + TotalApproved int64 `bson:"totalApproved" json:"totalApproved"` + CashTotalApproved float64 `bson:"cashTotalApproved" json:"cashTotalApproved"` + + TotalRejected int64 `bson:"totalRejected" json:"totalRejected"` + CashTotalRejected float64 `bson:"cashTotalRejected" json:"cashTotalRejected"` +} diff --git a/subject/campaign.go b/subject/campaign.go index 8c7ddac..a986f69 100644 --- a/subject/campaign.go +++ b/subject/campaign.go @@ -10,6 +10,8 @@ func getCampaignValue(val string) string { // Campaign ... var Campaign = struct { GetListCampaignTransactionAdminInfoByIDs string + GetCampaignSellerStatisticBySellerIDs string }{ GetListCampaignTransactionAdminInfoByIDs: getCampaignValue("get_list_campaign_transaction_admin_info_by_ids"), + GetCampaignSellerStatisticBySellerIDs: getCampaignValue("get_campaign_seller_statistic_by_seller_ids"), } From 2003cb4e4946341696196f71fc9d6acc3d25a10e Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Wed, 11 Jan 2023 10:21:02 +0700 Subject: [PATCH 59/59] update --- client/campaign.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/campaign.go b/client/campaign.go index 16fa6e4..8368230 100644 --- a/client/campaign.go +++ b/client/campaign.go @@ -36,15 +36,15 @@ func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) } // GetCampaignSellerStatistic .... -func (c Campaign) GetCampaignSellerStatistic(req model.GetCampaignSellerStatisticBySellerIDs) (*model.ResponseCampaignSellerStatistic, error) { +func (c Campaign) GetCampaignSellerStatistic(req model.GetCampaignSellerStatisticBySellerIDs) (*model.ResponseCampaignSellerStatisticList, error) { msg, err := natsio.GetServer().Request(subject.Campaign.GetCampaignSellerStatisticBySellerIDs, toBytes(req)) if err != nil { return nil, err } var r struct { - Data *model.ResponseCampaignSellerStatistic `json:"data"` - Error string `json:"error"` + Data *model.ResponseCampaignSellerStatisticList `json:"data"` + Error string `json:"error"` } if err = json.Unmarshal(msg.Data, &r); err != nil {