diff --git a/client/bank.go b/client/bank.go deleted file mode 100644 index 5650b2f..0000000 --- a/client/bank.go +++ /dev/null @@ -1,39 +0,0 @@ -package client - -import ( - "encoding/json" - "errors" - - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" -) - -// Bank ... -type Bank struct{} - -// GetBank ... -func GetBank() Bank { - return Bank{} -} - -func (s Bank) GetBankById(bankID string) (*model.BankBrief, error) { - msg, err := natsio.GetServer().Request(subject.Bank.GetBankById, toBytes(bankID)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.BankBrief `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/bank_branch.go b/client/bank_branch.go deleted file mode 100644 index 0ca9460..0000000 --- a/client/bank_branch.go +++ /dev/null @@ -1,39 +0,0 @@ -package client - -import ( - "encoding/json" - "errors" - - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" -) - -// BankBranch ... -type BankBranch struct{} - -// GetBankBranch ... -func GetBankBranch() BankBranch { - return BankBranch{} -} - -func (s BankBranch) GetBankBranchById(bankBranchID string) (*model.BankBranchBrief, error) { - msg, err := natsio.GetServer().Request(subject.Bank.GetBankBranchById, toBytes(bankBranchID)) - if err != nil { - return nil, err - } - - var r struct { - Data *model.BankBranchBrief `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/news.go b/client/news.go deleted file mode 100644 index 6bacf54..0000000 --- a/client/news.go +++ /dev/null @@ -1,36 +0,0 @@ -package client - -import ( - "encoding/json" - "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" -) - -// News ... -type News struct{} - -// GetNews ... -func GetNews() News { - return News{} -} - -// GetProductNoticesByInventory ... -func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { - msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, toBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.GetProductNoticesByInventoryResponse `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/seller.go b/client/seller.go index 5944bdb..56a9d7c 100644 --- a/client/seller.go +++ b/client/seller.go @@ -63,3 +63,26 @@ func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*mode } return r.Data, nil } + +// GetListSellerInfoSupportChatByIDs ... +func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportChatByIDsRequest) (*model.ResponseListSellerInfoSupportChat, error) { + msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoSupportChatByIDs, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSellerInfoSupportChat `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/supplier.go b/client/supplier.go index 41a1849..700d714 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -79,39 +79,3 @@ func (s Supplier) FindAll(supplierID model.SupplierRequestPayload) (*model.Suppl return r.Data, nil } - -// CreateWarehouseIntoServiceSupplier ... -func (s Supplier) CreateWarehouseIntoServiceSupplier(p model.CreateSupplierWarehousePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.CreateWarehouseIntoServiceSupplier, 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 -} - -// UpdateWarehouseIntoServiceSupplier ... -func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWarehousePayload) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateWarehouseIntoServiceSupplier, 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/warehouse.go b/client/warehouse.go index fdb70b8..6c04925 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -17,24 +17,6 @@ func GetWarehouse() Warehouse { return Warehouse{} } -// UpdateIsClosedSupplier ... -func (w Warehouse) UpdateIsClosedSupplier(p model.UpdateSupplierIsClosedRequest) error { - msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateIsClosedSupplier, 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 -} - // AfterCreateWarehouse ... func (w Warehouse) AfterCreateWarehouse(p model.WarehouseNatsResponse) error { msg, err := natsio.GetServer().Request(subject.Warehouse.AfterCreateWarehouse, toBytes(p)) diff --git a/model/bank_branch_reponse.go b/model/bank_branch_reponse.go deleted file mode 100644 index 1fa1432..0000000 --- a/model/bank_branch_reponse.go +++ /dev/null @@ -1,11 +0,0 @@ -package model - -// BankBranchBrief ... -type BankBranchBrief struct { - ID string `json:"_id"` - City string `json:"city"` - BankCode string `json:"bankCode"` - Bank string `json:"bank"` - Active bool `json:"active"` - Name string `json:"name"` -} diff --git a/model/bank_response.go b/model/bank_response.go deleted file mode 100644 index 74fc10e..0000000 --- a/model/bank_response.go +++ /dev/null @@ -1,21 +0,0 @@ -package model - -// MultiLang ... -type MultiLang struct { - En string `json:"en"` - Vi string `json:"vi"` -} - -// BankBrief ... -type BankBrief struct { - ID string `json:"_id"` - Name MultiLang `json:"name"` - ShortName string `json:"shortName"` - Active bool `json:"active"` - BenBankName string `json:"benBankName"` - BankCode int `json:"bankCode"` - IsBranchRequired bool `json:"isBranchRequired"` - SearchString string `json:"searchString"` - BeneficiaryForVietinbank string `json:"beneficiaryForVietinbank"` - CreatedBy string `json:"createdBy,omitempty"` -} diff --git a/model/news_request.go b/model/news_request.go deleted file mode 100644 index fb886e3..0000000 --- a/model/news_request.go +++ /dev/null @@ -1,6 +0,0 @@ -package model - -// GetProductNoticesByInventoryRequest .... -type GetProductNoticesByInventoryRequest struct { - InventoryIds []string `json:"inventoryIds"` -} diff --git a/model/news_response.go b/model/news_response.go deleted file mode 100644 index 4b496c4..0000000 --- a/model/news_response.go +++ /dev/null @@ -1,38 +0,0 @@ -package model - -// GetProductNoticesByInventoryResponse .... -type GetProductNoticesByInventoryResponse struct { - Notices []NewsAppResponse `json:"notices"` -} - -// NewsAppResponse ... -type NewsAppResponse struct { - ID string `json:"_id"` - Title string `json:"title,omitempty"` - Target *TargetNewDoc `json:"target,omitempty"` - ActionType *ActionType `json:"action"` - ShortDesc string `json:"shortDesc,omitempty"` - Type string `json:"type"` - ShortTitle string `json:"shortTitle,omitempty"` - Color string `json:"color"` - Options *NewsOptions `json:"options,omitempty"` - DisplayStyle string `json:"displayStyle"` -} - -// NewsOptions ... -type NewsOptions struct { - Category string `json:"category"` -} - -// TargetNewDoc ... -type TargetNewDoc struct { - Type string `json:"type,omitempty"` - Value string `json:"value,omitempty"` -} - -// ActionType ... -type ActionType struct { - Type string `json:"type"` - Value string `json:"value"` - Text string `json:"text,omitempty"` -} diff --git a/model/seller_request.go b/model/seller_request.go index 29732b9..a54996c 100644 --- a/model/seller_request.go +++ b/model/seller_request.go @@ -11,3 +11,8 @@ type GetSellerByIDRequest struct { type GetListSellerByIDsRequest struct { SellerIDs []primitive.ObjectID `json:"sellerIds"` } + +// GetListSellerSupportChatByIDsRequest ... +type GetListSellerSupportChatByIDsRequest struct { + SellerIDs []primitive.ObjectID `json:"sellerIds"` +} diff --git a/model/seller_response.go b/model/seller_response.go index 21f2693..aec57b9 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -1,5 +1,7 @@ package model +import "time" + // ResponseSellerInfo ... type ResponseSellerInfo struct { ID string `json:"_id"` @@ -11,3 +13,69 @@ type ResponseSellerInfo struct { type ResponseListSellerInfo struct { Sellers []ResponseSellerInfo `json:"sellers"` } + +// ResponseListSellerInfoSupportChat ... +type ResponseListSellerInfoSupportChat struct { + Sellers []ResponseSellerInfoSupportChat `json:"sellers"` +} + +// ResponseSellerInfoSupportChat ... +type ResponseSellerInfoSupportChat struct { + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + Membership SellerMembershipInfo `json:"membership"` + Info SellerContactInfo `json:"info"` + Team *TeamInfo `json:"team,omitempty"` + Statistic SellerStatistic `json:"statistic"` + TrackingTime *SellerTrackingTime `json:"trackingTime"` + Invitee *InviteeInfo `json:"invitee"` + CreatedAt time.Time `json:"createdAt"` +} + +// SellerTrackingTime ... +type SellerTrackingTime struct { + FirstOrderDeliveredAt time.Time `json:"firstOrderDeliveredAt,omitempty"` + ThirdOrderDeliveredAt time.Time `json:"thirdOrderDeliveredAt,omitempty"` +} + +// SellerStatistic ... +type SellerStatistic struct { + ThisMonthSale float64 `bson:"thisMonthSale" json:"thisMonthSale"` + LastMonthSale float64 `bson:"lastMonthSale" json:"lastMonthSale"` + Sale float64 `bson:"sale" json:"sale"` + TransactionTotal int `json:"transactionTotal"` + TransactionPaymentProcessing int `json:"transactionPaymentProcessing"` + TransactionWaitingApprove int `json:"transactionWaitingApprove"` + TransactionPending int `json:"transactionPending"` + TransactionSuccess int `json:"transactionSuccess"` + TransactionRejected int `json:"transactionRejected"` + TransactionDelivering int `json:"transactionDelivering"` + TransactionDelivered int `json:"transactionDelivered"` +} + +// TeamInfo ... +type TeamInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Role string `json:"role"` +} + +// InviteeInfo ... +type InviteeInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} + +// SellerContactInfo ... +type SellerContactInfo struct { + City int `json:"cityCode"` + CityName string `json:"cityName"` + Gender string `json:"gender"` +} + +// SellerMembershipInfo ... +type SellerMembershipInfo struct { + Level int `json:"level"` + Name string `json:"name"` +} diff --git a/model/supplier_request.go b/model/supplier_request.go index 5a19924..04d15d5 100644 --- a/model/supplier_request.go +++ b/model/supplier_request.go @@ -22,19 +22,3 @@ type SupplierRequestPayload struct { PIC string ContractStatus string } - -type CreateSupplierWarehousePayload struct { - Supplier string `json:"supplier"` - Warehouse string `json:"warehouse"` - ProvinceCode int `json:"provinceCode"` - DistrictCode int `json:"districtCode"` - WardCode int `json:"wardCode"` -} - -type UpdateSupplierWarehousePayload struct { - Supplier string `json:"supplier"` - Warehouse string `json:"warehouse"` - ProvinceCode int `json:"provinceCode"` - DistrictCode int `json:"districtCode"` - WardCode int `json:"wardCode"` -} diff --git a/model/supplier_response.go b/model/supplier_response.go index 975a8de..a87a29e 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -2,9 +2,8 @@ package model // ResponseSupplierInfo ... type ResponseSupplierInfo struct { - ID string `json:"id"` - Name string `json:"name"` - BusinessType string `json:"businessType"` + ID string `json:"id"` + Name string `json:"name"` } // ResponseSupplierContract ... @@ -17,12 +16,11 @@ type ResponseSupplierContract struct { // SupplierBrief ... type SupplierBrief struct { - ID string `json:"_id"` - Name string `json:"name"` - Status string `json:"status"` - BusinessType string `json:"businessType"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` + ID string `json:"_id"` + Name string `json:"name"` + Status string `json:"status"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` } type SupplierAll struct { diff --git a/model/warehouse_request.go b/model/warehouse_request.go index 663cfaa..543fc68 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -29,11 +29,9 @@ type InsuranceOpts struct { // OutboundRequestItem ... type OutboundRequestItem struct { - SupplierSKU string `json:"supplierSKU"` - Quantity int64 `json:"quantity"` - UnitCode string `json:"unitCode"` - Price float64 `json:"price"` - Name string `json:"name"` + SupplierSKU string `json:"supplierSKU"` + Quantity int64 `json:"quantity"` + UnitCode string `json:"unitCode"` } // CustomerInfo ... @@ -58,7 +56,6 @@ type UpdateOutboundRequestLogisticInfoPayload struct { ShippingLabel string `json:"shippingLabel"` TrackingCode string `json:"trackingCode"` ORCode string `json:"orCode"` - TPLCode string `json:"tplCode"` } // CancelOutboundRequest ... @@ -72,14 +69,3 @@ type SyncORStatusRequest struct { ORCode string `json:"orCode"` OrderCode string `json:"orderCode"` } - -// UpdateSupplierIsClosedRequest ... -type UpdateSupplierIsClosedRequest struct { - Suppliers []SupplierIsClosed `json:"suppliers"` -} - -// SupplierIsClosed ... -type SupplierIsClosed struct { - Supplier string `json:"supplier"` - IsClosed bool `json:"isClosed"` -} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index f2d60a9..2429743 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -25,20 +25,6 @@ type WarehouseConfiguration struct { Partner WarehousePartner `json:"partner"` Delivery WarehouseDelivery `json:"delivery"` Other WarehouseOther `json:"other"` - Food WarehouseFood `json:"food"` -} - -// WarehouseFood ... -type WarehouseFood struct { - ForceClosed bool `json:"forceClosed"` - IsClosed bool `json:"isClosed"` - TimeRange []TimeRange `json:"timeRange"` -} - -// TimeRange ... -type TimeRange struct { - From int64 `json:"from"` - To int64 `json:"to"` } // WarehouseOther ... @@ -123,7 +109,6 @@ type ResponseLatLng struct { 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"` diff --git a/subject/bank.go b/subject/bank.go deleted file mode 100644 index a991d5d..0000000 --- a/subject/bank.go +++ /dev/null @@ -1,15 +0,0 @@ -package subject - -import "fmt" - -func getBankValue(val string) string { - return fmt.Sprintf("%s.%s", prefixes.Bank, val) -} - -var Bank = struct { - GetBankById string - GetBankBranchById string -}{ - GetBankById: getBankValue("get_bank_by_id"), - GetBankBranchById: getBankValue("get_bank_branch_by_id"), -} diff --git a/subject/config.go b/subject/config.go index 4a2f9f3..cb215bc 100644 --- a/subject/config.go +++ b/subject/config.go @@ -3,19 +3,15 @@ package subject var prefixes = struct { Communication string Order string - News string Warehouse string Location string - Bank string Supplier string Seller string }{ Communication: "communication", Order: "order", - News: "news", Warehouse: "warehouse", Location: "location", Supplier: "supplier", - Bank: "bank", Seller: "seller", } diff --git a/subject/news.go b/subject/news.go deleted file mode 100644 index bfec6cf..0000000 --- a/subject/news.go +++ /dev/null @@ -1,13 +0,0 @@ -package subject - -import "fmt" - -func getNewsValue(val string) string { - return fmt.Sprintf("%s.%s", prefixes.News, val) -} - -var News = struct { - GetProductNoticesByInventory string -}{ - GetProductNoticesByInventory: getNewsValue("get_product_notices_by_inventory"), -} diff --git a/subject/seller.go b/subject/seller.go index ab3ac20..6ef730e 100644 --- a/subject/seller.go +++ b/subject/seller.go @@ -8,9 +8,11 @@ func getSellerValue(val string) string { // Seller ... var Seller = struct { - GetSellerInfoByID string - GetListSellerInfoByIDs string + GetSellerInfoByID string + GetListSellerInfoByIDs string + GetListSellerInfoSupportChatByIDs string }{ - GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), - GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"), + GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), + GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"), + GetListSellerInfoSupportChatByIDs: getSellerValue("get_list_seller_info_support_chat_by_ids"), } diff --git a/subject/warehouse.go b/subject/warehouse.go index cbebba0..5d0a81c 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -14,16 +14,12 @@ var Warehouse = struct { SyncORStatus string WebhookTNC string WebhookGlobalCare string - WebhookOnPoint string FindOne string FindByCondition string Distinct string Count string AfterUpdateWarehouse string AfterCreateWarehouse string - UpdateIsClosedSupplier string - CreateWarehouseIntoServiceSupplier string - UpdateWarehouseIntoServiceSupplier string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -34,12 +30,8 @@ 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"), Count: getWarehouseValue("count"), - UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), - CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), - UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), }