From 48e585dc163b66da7b1a279b0974c1515687c4a3 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 11:10:23 +0700 Subject: [PATCH 01/34] 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 89967955ea2af42c918b213a4183f2d3a471db93 Mon Sep 17 00:00:00 2001 From: phuanbui Date: Mon, 19 Sep 2022 11:48:30 +0700 Subject: [PATCH 02/34] get list seller by ids --- client/seller.go | 25 +++++++++++++++++++++++++ model/seller_request.go | 5 +++++ model/seller_response.go | 5 +++++ subject/seller.go | 6 ++++-- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/client/seller.go b/client/seller.go index ec3ab83..5944bdb 100644 --- a/client/seller.go +++ b/client/seller.go @@ -3,6 +3,7 @@ package client import ( "encoding/json" "errors" + "github.com/Selly-Modules/natsio" "github.com/Selly-Modules/natsio/model" "github.com/Selly-Modules/natsio/subject" @@ -38,3 +39,27 @@ func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.Response return r.Data, nil } + +// GetListSellerInfoByIDs ... +func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*model.ResponseListSellerInfo, error) { + msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoByIDs, toBytes(p)) + + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSellerInfo `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/seller_request.go b/model/seller_request.go index 997cd97..29732b9 100644 --- a/model/seller_request.go +++ b/model/seller_request.go @@ -6,3 +6,8 @@ import "go.mongodb.org/mongo-driver/bson/primitive" type GetSellerByIDRequest struct { SellerID primitive.ObjectID `json:"sellerId"` } + +// GetListSellerByIDsRequest ... +type GetListSellerByIDsRequest struct { + SellerIDs []primitive.ObjectID `json:"sellerIds"` +} diff --git a/model/seller_response.go b/model/seller_response.go index 6b7d698..5dd5271 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -6,3 +6,8 @@ type ResponseSellerInfo struct { Name string `json:"name"` Code string `json:"code"` } + +// ResponseListSellerInfo ... +type ResponseListSellerInfo struct { + Sellers []ResponseSellerInfo `json:"sellers"` +} diff --git a/subject/seller.go b/subject/seller.go index 033f993..ab3ac20 100644 --- a/subject/seller.go +++ b/subject/seller.go @@ -8,7 +8,9 @@ func getSellerValue(val string) string { // Seller ... var Seller = struct { - GetSellerInfoByID string + GetSellerInfoByID string + GetListSellerInfoByIDs string }{ - GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), + GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), + GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"), } From b5ba7c7bf1866b83b1062cc7545a43a37fe0e691 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 14:18:51 +0700 Subject: [PATCH 03/34] 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 35a811886b1113bda8683c1063da558766ae49ac Mon Sep 17 00:00:00 2001 From: phuanbui Date: Mon, 19 Sep 2022 14:52:26 +0700 Subject: [PATCH 04/34] edit type id --- model/seller_response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/seller_response.go b/model/seller_response.go index 5dd5271..21f2693 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -2,7 +2,7 @@ package model // ResponseSellerInfo ... type ResponseSellerInfo struct { - ID string `json:"id"` + ID string `json:"_id"` Name string `json:"name"` Code string `json:"code"` } From 9e4e6868a495e446c59d3ac82d033fafb256d340 Mon Sep 17 00:00:00 2001 From: Sinh Date: Mon, 19 Sep 2022 15:01:54 +0700 Subject: [PATCH 05/34] 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 1d58e55af736b32c7526d711161ef9509d6bb83f Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 10:28:35 +0700 Subject: [PATCH 06/34] [Update] Request news --- client/news.go | 28 ++++++++++++++++++++++++++++ model/news_request.go | 6 ++++++ model/news_response.go | 38 ++++++++++++++++++++++++++++++++++++++ subject/config.go | 2 ++ subject/news.go | 13 +++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 client/news.go create mode 100644 model/news_request.go create mode 100644 model/news_response.go create mode 100644 subject/news.go diff --git a/client/news.go b/client/news.go new file mode 100644 index 0000000..162162d --- /dev/null +++ b/client/news.go @@ -0,0 +1,28 @@ +package client + +import ( + "encoding/json" + "errors" + "github.com/Selly-Modules/natsio" + "github.com/Selly-Modules/natsio/model" + "github.com/Selly-Modules/natsio/subject" +) + +// GetProductNoticesByInventory ... +func (w Warehouse) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { + msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, bsonToBytes(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/model/news_request.go b/model/news_request.go new file mode 100644 index 0000000..fb886e3 --- /dev/null +++ b/model/news_request.go @@ -0,0 +1,6 @@ +package model + +// GetProductNoticesByInventoryRequest .... +type GetProductNoticesByInventoryRequest struct { + InventoryIds []string `json:"inventoryIds"` +} diff --git a/model/news_response.go b/model/news_response.go new file mode 100644 index 0000000..4b496c4 --- /dev/null +++ b/model/news_response.go @@ -0,0 +1,38 @@ +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/subject/config.go b/subject/config.go index dfeea56..259e7ba 100644 --- a/subject/config.go +++ b/subject/config.go @@ -3,12 +3,14 @@ package subject var prefixes = struct { Communication string Order string + News string Warehouse string Location string Supplier string }{ Communication: "communication", Order: "order", + News: "news", Warehouse: "warehouse", Location: "location", Supplier: "supplier", diff --git a/subject/news.go b/subject/news.go new file mode 100644 index 0000000..3e96d25 --- /dev/null +++ b/subject/news.go @@ -0,0 +1,13 @@ +package subject + +import "fmt" + +func getNewsValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Order, val) +} + +var News = struct { + GetProductNoticesByInventory string +}{ + GetProductNoticesByInventory: getNewsValue("get_product_notices_by_inventory"), +} From 3c5c95b103193e5866d396f116c035273c56c450 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 10:56:45 +0700 Subject: [PATCH 07/34] [Update] --- client/news.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/news.go b/client/news.go index 162162d..4167c0a 100644 --- a/client/news.go +++ b/client/news.go @@ -8,8 +8,16 @@ import ( "github.com/Selly-Modules/natsio/subject" ) +// News ... +type News struct{} + +// GetNews ... +func GetNews() News { + return News{} +} + // GetProductNoticesByInventory ... -func (w Warehouse) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { +func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, bsonToBytes(p)) if err != nil { return nil, err From 34c61ccfcc7d2ab95cd27969f54ed0a0eb460190 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 10:56:45 +0700 Subject: [PATCH 08/34] [Update] --- client/news.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/news.go b/client/news.go index 162162d..4167c0a 100644 --- a/client/news.go +++ b/client/news.go @@ -8,8 +8,16 @@ import ( "github.com/Selly-Modules/natsio/subject" ) +// News ... +type News struct{} + +// GetNews ... +func GetNews() News { + return News{} +} + // GetProductNoticesByInventory ... -func (w Warehouse) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { +func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, bsonToBytes(p)) if err != nil { return nil, err From 4452be147432ae722cf941b3b7b223ee0af0d7c0 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 13:49:58 +0700 Subject: [PATCH 09/34] [Update] Add subjects --- subject/news.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subject/news.go b/subject/news.go index 3e96d25..bfec6cf 100644 --- a/subject/news.go +++ b/subject/news.go @@ -3,7 +3,7 @@ package subject import "fmt" func getNewsValue(val string) string { - return fmt.Sprintf("%s.%s", prefixes.Order, val) + return fmt.Sprintf("%s.%s", prefixes.News, val) } var News = struct { From 952c09ccba634573b47c9ed6faca0004b400426d Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 14:46:29 +0700 Subject: [PATCH 10/34] fix news to bytes --- client/news.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/news.go b/client/news.go index 4167c0a..6bacf54 100644 --- a/client/news.go +++ b/client/news.go @@ -18,7 +18,7 @@ func GetNews() News { // GetProductNoticesByInventory ... func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { - msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, bsonToBytes(p)) + msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, toBytes(p)) if err != nil { return nil, err } From 583f2abda5476a5b6f8c92f7b9e678eb663242e6 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Wed, 21 Sep 2022 10:19:17 +0700 Subject: [PATCH 11/34] get seller info support chat --- client/seller.go | 23 ++++++++++++++ model/seller_request.go | 5 +++ model/seller_response.go | 68 ++++++++++++++++++++++++++++++++++++++++ subject/seller.go | 10 +++--- 4 files changed, 102 insertions(+), 4 deletions(-) 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/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/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"), } From 73181bc5836149a8c1cc07f0ae7c4af08476b162 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 21 Sep 2022 17:40:49 +0700 Subject: [PATCH 12/34] 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 13/34] 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 4ac7ec3b0ceb1a29519d680da717ec5547c4652f Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 22 Sep 2022 13:49:11 +0700 Subject: [PATCH 14/34] support chat get seller info --- client/seller.go | 2 +- subject/seller.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/client/seller.go b/client/seller.go index 56a9d7c..1d06208 100644 --- a/client/seller.go +++ b/client/seller.go @@ -66,7 +66,7 @@ func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*mode // GetListSellerInfoSupportChatByIDs ... func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportChatByIDsRequest) (*model.ResponseListSellerInfoSupportChat, error) { - msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoSupportChatByIDs, toBytes(p)) + msg, err := natsio.GetServer().Request(subject.SupportChat.GetListSellerInfoSupportChatByIDs, toBytes(p)) if err != nil { return nil, err } diff --git a/subject/seller.go b/subject/seller.go index 6ef730e..eba9131 100644 --- a/subject/seller.go +++ b/subject/seller.go @@ -8,11 +8,16 @@ func getSellerValue(val string) string { // Seller ... var Seller = struct { - GetSellerInfoByID string - GetListSellerInfoByIDs string + GetSellerInfoByID string + GetListSellerInfoByIDs string +}{ + GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), + GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"), +} + +// SupportChat ... +var SupportChat = struct { GetListSellerInfoSupportChatByIDs string }{ - 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"), + GetListSellerInfoSupportChatByIDs: "SELLY_CHAT.REQUEST.SELLER_INFO", } From 021df099ccfc55b15d0bbc52b6f391b8d6d85197 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 22 Sep 2022 14:56:31 +0700 Subject: [PATCH 15/34] update location --- client/location_dao.go | 180 +++++++++++++++++++++++++++++++++++++ model/location_response.go | 120 +++++++++++++++++-------- subject/location.go | 34 +++++-- 3 files changed, 291 insertions(+), 43 deletions(-) create mode 100644 client/location_dao.go diff --git a/client/location_dao.go b/client/location_dao.go new file mode 100644 index 0000000..3c09c55 --- /dev/null +++ b/client/location_dao.go @@ -0,0 +1,180 @@ +package client + +import ( + "encoding/json" + "errors" + "github.com/Selly-Modules/natsio" + "github.com/Selly-Modules/natsio/model" + "github.com/Selly-Modules/natsio/subject" +) + +// FindOneProvinceByCondition ... +func (l Location) FindOneProvinceByCondition(p model.FindOneCondition) (*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindOneProvinceByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.LocationProvinceDetailResponse `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 +} + +// FindOneDistrictByCondition ... +func (l Location) FindOneDistrictByCondition(p model.FindOneCondition) (*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindOneDistrictByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.LocationDistrictDetailResponse `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 +} + +// FindOneWardByCondition ... +func (l Location) FindOneWardByCondition(p model.FindOneCondition) (*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindOneWardByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.LocationWardDetailResponse `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 +} + +// FindProvinceByCondition ... +func (l Location) FindProvinceByCondition(p model.FindWithCondition) ([]*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindProvinceByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.LocationProvinceDetailResponse `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 +} + +// FindDistrictByCondition ... +func (l Location) FindDistrictByCondition(p model.FindWithCondition) ([]*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindDistrictByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.LocationDistrictDetailResponse `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 +} + +// FindWardByCondition ... +func (l Location) FindWardByCondition(p model.FindWithCondition) ([]*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.FindWardByCondition, bsonToBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []*model.LocationWardDetailResponse `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 +} + +// CountProvinceByCondition ... +func (l Location) CountProvinceByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, bsonToBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountDistrictByCondition ... +func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, bsonToBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountWardByCondition ... +func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, bsonToBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} diff --git a/model/location_response.go b/model/location_response.go index 484d89e..2674041 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,43 +1,93 @@ package model -type ResponseLocationAddress struct { - Province LocationProvince `json:"province"` - District LocationDistrict `json:"district"` - Ward LocationWard `json:"ward"` -} +import "time" -// LocationProvince ... -type LocationProvince struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} +type ( + // ResponseLocationAddress ... + ResponseLocationAddress struct { + Province LocationProvince `json:"province"` + District LocationDistrict `json:"district"` + Ward LocationWard `json:"ward"` + } -// LocationDistrict ... -type LocationDistrict struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} + // LocationProvince ... + LocationProvince struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + RegionCode string `json:"regionCode"` + MainRegionCode string `json:"mainRegionCode"` + } -// LocationWard ... -type LocationWard struct { - ID string `json:"id"` - Name string `json:"name"` - Code int `json:"code"` -} + // LocationDistrict ... + LocationDistrict struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + } -// LocationProvinceResponse ... -type LocationProvinceResponse struct { - Provinces []LocationProvince `json:"provinces"` -} + // LocationWard ... + LocationWard struct { + ID string `json:"id"` + Name string `json:"name"` + Code int `json:"code"` + } -// LocationDistrictResponse ... -type LocationDistrictResponse struct { - Districts []LocationDistrict `json:"districts"` -} + // LocationProvinceResponse ... + LocationProvinceResponse struct { + Provinces []LocationProvince `json:"provinces"` + } -// LocationWardResponse ... -type LocationWardResponse struct { - Wards []LocationWard `json:"wards"` -} + // LocationDistrictResponse ... + LocationDistrictResponse struct { + Districts []LocationDistrict `json:"districts"` + } + + // LocationWardResponse ... + LocationWardResponse struct { + Wards []LocationWard `json:"wards"` + } + + // LocationProvinceDetailResponse ... + LocationProvinceDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + Code int `json:"code"` + CountryCode string `json:"countryCode"` + RegionCode string `json:"regionCode"` + MainRegionCode string `json:"mainRegionCode"` + TotalDistricts int `json:"totalDistricts"` + TotalWards int `json:"totalWards"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } + + // LocationDistrictDetailResponse ... + LocationDistrictDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + Code int `json:"code"` + ProvinceCode int `json:"provinceCode"` + Area int `json:"area"` + TotalWards int `json:"totalWards"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } + + // LocationWardDetailResponse ... + LocationWardDetailResponse struct { + ID string `json:"_id"` + Name string `json:"name"` + SearchString string `json:"searchString"` + Slug string `json:"slug"` + Code int `json:"code"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + } +) diff --git a/subject/location.go b/subject/location.go index b19a59b..7525c25 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,13 +7,31 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string + GetLocationByCode string + GetProvincesByCodes string + GetDistrictsByCodes string + GetWardsByCodes string + FindOneProvinceByCondition string + FindOneDistrictByCondition string + FindOneWardByCondition string + FindProvinceByCondition string + FindDistrictByCondition string + FindWardByCondition string + CountProvinceByCondition string + CountDistrictByCondition string + CountWardByCondition string }{ - GetLocationByCode: getLocationValue("get_location_warehouse"), - GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), - GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), - GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetLocationByCode: getLocationValue("get_location_warehouse"), + GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetWardsByCodes: getLocationValue("get_wards_by_codes"), + FindOneProvinceByCondition: getLocationValue("find_one_province_by_condition"), + FindOneDistrictByCondition: getLocationValue("find_one_district_by_condition"), + FindOneWardByCondition: getLocationValue("find_one_ward_by_condition"), + FindProvinceByCondition: getLocationValue("find_province_by_condition"), + FindDistrictByCondition: getLocationValue("find_district_by_condition"), + FindWardByCondition: getLocationValue("find_ward_by_condition"), + CountProvinceByCondition: getLocationValue("count_province_by_condition"), + CountDistrictByCondition: getLocationValue("count_district_by_condition"), + CountWardByCondition: getLocationValue("count_ward_by_condition"), } From b718162cd439fd67487b695f48d4a9f7f90a4469 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 10:13:14 +0700 Subject: [PATCH 16/34] jestream-push-notification --- jestream/config.go | 8 ++++++++ jestream/notification.go | 8 ++++++++ model/notification_request.go | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 jestream/config.go create mode 100644 jestream/notification.go create mode 100644 model/notification_request.go diff --git a/jestream/config.go b/jestream/config.go new file mode 100644 index 0000000..41d28bb --- /dev/null +++ b/jestream/config.go @@ -0,0 +1,8 @@ +package jestream + +// StreamConfig ... +var StreamConfig = struct { + Notification string +}{ + Notification: "Service_Notification", +} diff --git a/jestream/notification.go b/jestream/notification.go new file mode 100644 index 0000000..fe48a8b --- /dev/null +++ b/jestream/notification.go @@ -0,0 +1,8 @@ +package jestream + +// SubjectNotification ... +var SubjectNotification = struct { + PushNotifications string +}{ + PushNotifications: "selly.pull.notification.push_notifications", +} diff --git a/model/notification_request.go b/model/notification_request.go new file mode 100644 index 0000000..ed2c36c --- /dev/null +++ b/model/notification_request.go @@ -0,0 +1,14 @@ +package model + +// PayloadPushNotification ... +type PayloadPushNotification struct { + User string `json:"user"` + Type string `json:"type"` + TargetId string `json:"targetId"` + IsFromAdmin bool `json:"isFromAdmin"` + Category string `json:"category"` + Options struct { + Title string `json:"title"` + Content string `json:"content"` + } `json:"options"` +} From f80f89e79396a477b721814ac8be0e19922d4928 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 11:17:03 +0700 Subject: [PATCH 17/34] jestream --- jestream/config.go | 8 -------- jestream/notification.go | 8 -------- .../model/selly.go | 8 ++++---- js/subject/config.go | 10 ++++++++++ js/subject/selly.go | 19 +++++++++++++++++++ 5 files changed, 33 insertions(+), 20 deletions(-) delete mode 100644 jestream/config.go delete mode 100644 jestream/notification.go rename model/notification_request.go => js/model/selly.go (68%) create mode 100644 js/subject/config.go create mode 100644 js/subject/selly.go diff --git a/jestream/config.go b/jestream/config.go deleted file mode 100644 index 41d28bb..0000000 --- a/jestream/config.go +++ /dev/null @@ -1,8 +0,0 @@ -package jestream - -// StreamConfig ... -var StreamConfig = struct { - Notification string -}{ - Notification: "Service_Notification", -} diff --git a/jestream/notification.go b/jestream/notification.go deleted file mode 100644 index fe48a8b..0000000 --- a/jestream/notification.go +++ /dev/null @@ -1,8 +0,0 @@ -package jestream - -// SubjectNotification ... -var SubjectNotification = struct { - PushNotifications string -}{ - PushNotifications: "selly.pull.notification.push_notifications", -} diff --git a/model/notification_request.go b/js/model/selly.go similarity index 68% rename from model/notification_request.go rename to js/model/selly.go index ed2c36c..053a3be 100644 --- a/model/notification_request.go +++ b/js/model/selly.go @@ -1,10 +1,10 @@ -package model +package jsmodel -// PayloadPushNotification ... -type PayloadPushNotification struct { +// PushNotification ... +type PushNotification struct { User string `json:"user"` Type string `json:"type"` - TargetId string `json:"targetId"` + TargetID string `json:"targetId"` IsFromAdmin bool `json:"isFromAdmin"` Category string `json:"category"` Options struct { diff --git a/js/subject/config.go b/js/subject/config.go new file mode 100644 index 0000000..3f77205 --- /dev/null +++ b/js/subject/config.go @@ -0,0 +1,10 @@ +package jssubject + +var root = "js" + +// prefixes ... +var prefixes = struct { + Selly string +}{ + Selly: "selly", +} diff --git a/js/subject/selly.go b/js/subject/selly.go new file mode 100644 index 0000000..e6a344b --- /dev/null +++ b/js/subject/selly.go @@ -0,0 +1,19 @@ +package jssubject + +import ( + "fmt" +) + +// getSellyValue ... +func getSellyValue(val string) string { + return fmt.Sprintf("%s.%s.%s", root, prefixes.Selly, val) +} + +// Selly ... +var Selly = struct { + Stream string + PushNotification string +}{ + Stream: prefixes.Selly, + PushNotification: getSellyValue("push_notifications"), +} From 047037f12303c601b49fa7431eb311901c48c176 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 11:57:19 +0700 Subject: [PATCH 18/34] stream name --- jestream_name.go | 4 ++++ js/subject/selly.go | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 jestream_name.go diff --git a/jestream_name.go b/jestream_name.go new file mode 100644 index 0000000..1f2ea4d --- /dev/null +++ b/jestream_name.go @@ -0,0 +1,4 @@ +package natsio + +// StreamNameSelly ... +const StreamNameSelly = "selly" diff --git a/js/subject/selly.go b/js/subject/selly.go index e6a344b..bdd4ce8 100644 --- a/js/subject/selly.go +++ b/js/subject/selly.go @@ -11,9 +11,7 @@ func getSellyValue(val string) string { // Selly ... var Selly = struct { - Stream string PushNotification string }{ - Stream: prefixes.Selly, PushNotification: getSellyValue("push_notifications"), } From 547b3b8dd911df5bb2664e8374d4a96b6874ef7b Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 14:47:00 +0700 Subject: [PATCH 19/34] update js stream --- js/consumer/selly.go | 8 ++++++++ js/model/selly.go | 21 ++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 js/consumer/selly.go diff --git a/js/consumer/selly.go b/js/consumer/selly.go new file mode 100644 index 0000000..380927c --- /dev/null +++ b/js/consumer/selly.go @@ -0,0 +1,8 @@ +package jsconsumer + +// Selly ... +var Selly = struct { + PushNotification string +}{ + PushNotification: "PULL_PUSH_NOTIFICATION", +} diff --git a/js/model/selly.go b/js/model/selly.go index 053a3be..ab8d021 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -2,13 +2,16 @@ package jsmodel // PushNotification ... type PushNotification struct { - User string `json:"user"` - Type string `json:"type"` - TargetID string `json:"targetId"` - IsFromAdmin bool `json:"isFromAdmin"` - Category string `json:"category"` - Options struct { - Title string `json:"title"` - Content string `json:"content"` - } `json:"options"` + User string `json:"user"` + Type string `json:"type"` + TargetID string `json:"targetId"` + IsFromAdmin bool `json:"isFromAdmin"` + Category string `json:"category"` + Options NotificationOptions `json:"options"` +} + +// NotificationOptions ... +type NotificationOptions struct { + Title string `json:"title"` + Content string `json:"content"` } From d9763edd75d48c0d20b7ce5aff940b47fb44eb67 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 22:11:24 +0700 Subject: [PATCH 20/34] pull js seller affiliate statistic --- js/consumer/selly.go | 6 ++++-- js/model/selly.go | 19 +++++++++++++++++++ js/subject/selly.go | 6 ++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/js/consumer/selly.go b/js/consumer/selly.go index 380927c..b13c5f6 100644 --- a/js/consumer/selly.go +++ b/js/consumer/selly.go @@ -2,7 +2,9 @@ package jsconsumer // Selly ... var Selly = struct { - PushNotification string + PushNotification string + UpdateSellerStatistic string }{ - PushNotification: "PULL_PUSH_NOTIFICATION", + PushNotification: "PULL_PUSH_NOTIFICATION", + UpdateSellerStatistic: "PULL_UPDATE_SELLER_STATISTIC", } diff --git a/js/model/selly.go b/js/model/selly.go index ab8d021..412e62d 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -15,3 +15,22 @@ type NotificationOptions struct { Title string `json:"title"` Content string `json:"content"` } + +// PayloadUpdateSellerAffiliateStatistic ... +type PayloadUpdateSellerAffiliateStatistic struct { + SellerID string `json:"sellerId"` + Statistic SellerAffiliateStatistic `json:"statistic"` +} + +// SellerAffiliateStatistic ... +type SellerAffiliateStatistic struct { + TransactionTotal int `json:"transactionTotal"` + TransactionCashback int `json:"transactionCashback"` + TransactionPending int `json:"transactionPending"` + TransactionApproved int `json:"transactionApproved"` + TransactionRejected int `json:"transactionRejected"` + CommissionTransactionTotal float64 `json:"commissionTransactionTotal"` + CommissionTransactionCashback float64 `json:"commissionTransactionCashback"` + CommissionTransactionApproved float64 `json:"commissionTransactionApproved"` + CommissionTransactionRejected float64 `json:"commissionTransactionRejected"` +} diff --git a/js/subject/selly.go b/js/subject/selly.go index bdd4ce8..204e781 100644 --- a/js/subject/selly.go +++ b/js/subject/selly.go @@ -11,7 +11,9 @@ func getSellyValue(val string) string { // Selly ... var Selly = struct { - PushNotification string + PushNotification string + UpdateSellerStatistic string }{ - PushNotification: getSellyValue("push_notifications"), + PushNotification: getSellyValue("push_notifications"), + UpdateSellerStatistic: getSellyValue("update_seller_statistic"), } From 68b9cab1e2f9733947cf3709f54ee0ae53289f04 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 22:11:28 +0700 Subject: [PATCH 21/34] pull js seller affiliate statistic --- js/consumer/selly.go | 8 ++++---- js/subject/selly.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/js/consumer/selly.go b/js/consumer/selly.go index b13c5f6..0305c7c 100644 --- a/js/consumer/selly.go +++ b/js/consumer/selly.go @@ -2,9 +2,9 @@ package jsconsumer // Selly ... var Selly = struct { - PushNotification string - UpdateSellerStatistic string + PushNotification string + UpdateSellerAffiliateStatistic string }{ - PushNotification: "PULL_PUSH_NOTIFICATION", - UpdateSellerStatistic: "PULL_UPDATE_SELLER_STATISTIC", + PushNotification: "PULL_PUSH_NOTIFICATION", + UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", } diff --git a/js/subject/selly.go b/js/subject/selly.go index 204e781..71ca355 100644 --- a/js/subject/selly.go +++ b/js/subject/selly.go @@ -11,9 +11,9 @@ func getSellyValue(val string) string { // Selly ... var Selly = struct { - PushNotification string - UpdateSellerStatistic string + PushNotification string + UpdateSellerAffiliateStatistic string }{ - PushNotification: getSellyValue("push_notifications"), - UpdateSellerStatistic: getSellyValue("update_seller_statistic"), + PushNotification: getSellyValue("push_notifications"), + UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), } From dcea3798f881cc096b5c6c3e51cad6d186e58ea6 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 23:32:23 +0700 Subject: [PATCH 22/34] js cashflow seller --- js/consumer/selly.go | 2 ++ js/model/selly.go | 23 +++++++++++++++++++++++ js/subject/selly.go | 2 ++ 3 files changed, 27 insertions(+) diff --git a/js/consumer/selly.go b/js/consumer/selly.go index 0305c7c..975cb5b 100644 --- a/js/consumer/selly.go +++ b/js/consumer/selly.go @@ -4,7 +4,9 @@ package jsconsumer var Selly = struct { PushNotification string UpdateSellerAffiliateStatistic string + CheckAnDInsertCashflowBySeller string }{ PushNotification: "PULL_PUSH_NOTIFICATION", UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", + CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", } diff --git a/js/model/selly.go b/js/model/selly.go index 412e62d..c521660 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -34,3 +34,26 @@ type SellerAffiliateStatistic struct { CommissionTransactionApproved float64 `json:"commissionTransactionApproved"` CommissionTransactionRejected float64 `json:"commissionTransactionRejected"` } + +// PayloadCashflowsBySeller ... +type PayloadCashflowsBySeller struct { + SellerID string `json:"sellerId"` + List []CashflowSeller `json:"list"` +} + +// CashflowSeller ... +type CashflowSeller struct { + Value float64 `json:"value"` + Action string `json:"action"` + Category string `json:"category"` + TargetID string `json:"targetId"` + TargetType string `json:"targetType"` + Options *CashFlowOptions `json:"options"` +} + +// CashFlowOptions ... +type CashFlowOptions struct { + AffiliateTransactionCode string `json:"affiliateTransactionCode,omitempty"` + AffiliateCampaignID string `json:"affiliateCampaignId,omitempty"` + AffiliateCampaignName string `json:"affiliateCampaignName,omitempty"` +} diff --git a/js/subject/selly.go b/js/subject/selly.go index 71ca355..2f665bb 100644 --- a/js/subject/selly.go +++ b/js/subject/selly.go @@ -13,7 +13,9 @@ func getSellyValue(val string) string { var Selly = struct { PushNotification string UpdateSellerAffiliateStatistic string + CheckAnDInsertCashflowBySeller string }{ PushNotification: getSellyValue("push_notifications"), UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), + CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"), } From 57d6cb18a9daf626b4e23200d62d6ec14bec4c45 Mon Sep 17 00:00:00 2001 From: Sinh Date: Wed, 28 Sep 2022 08:59:18 +0700 Subject: [PATCH 23/34] update global care - integrate car insurance --- model/warehouse_request.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/model/warehouse_request.go b/model/warehouse_request.go index b546725..5990487 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -17,6 +17,7 @@ type OutboundRequestPayload struct { // InsuranceOpts ... type InsuranceOpts struct { + InsuranceType string `json:"insuranceType"` VehicleTypeID string `json:"vehicleTypeId"` VehicleTypeName string `json:"vehicleTypeName"` InsuranceTypeID string `json:"insuranceTypeId"` @@ -25,6 +26,12 @@ type InsuranceOpts struct { Chassis string `json:"chassis"` Engine string `json:"engine"` BeginDate string `json:"beginDate"` + + // For car insurance + NumberOfSeatsCarOccupantAccidentInsurance int `json:"numberOfSeatsCarOccupantAccidentInsurance"` + NumberOfSeats int `json:"numberOfSeats"` + NumberOfSeatsOrTonnageId string `json:"numberOfSeatsOrTonnageId"` + NumberOfSeatsOrTonnageName string `json:"numberOfSeatsOrTonnageName"` } // OutboundRequestItem ... From e6b620ca6c97a067ca94f48d6187a50b0ccb52fc Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Fri, 30 Sep 2022 10:29:14 +0700 Subject: [PATCH 24/34] CommissionTransactionPending --- js/model/selly.go | 1 + 1 file changed, 1 insertion(+) diff --git a/js/model/selly.go b/js/model/selly.go index c521660..a8e0a60 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -32,6 +32,7 @@ type SellerAffiliateStatistic struct { CommissionTransactionTotal float64 `json:"commissionTransactionTotal"` CommissionTransactionCashback float64 `json:"commissionTransactionCashback"` CommissionTransactionApproved float64 `json:"commissionTransactionApproved"` + CommissionTransactionPending float64 `json:"commissionTransactionPending"` CommissionTransactionRejected float64 `json:"commissionTransactionRejected"` } From aab1103fc809404f66b571f60802ed78ac6eb82a Mon Sep 17 00:00:00 2001 From: Sinh Date: Fri, 30 Sep 2022 10:32:33 +0700 Subject: [PATCH 25/34] define warehouse method --- client/warehouse.go | 19 +++++++++++++++++++ model/warehouse_request.go | 11 +++++++++++ model/warehouse_response.go | 27 +++++++++++++++++++++++++++ subject/warehouse.go | 2 ++ 4 files changed, 59 insertions(+) diff --git a/client/warehouse.go b/client/warehouse.go index fdb70b8..5ae07db 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -144,3 +144,22 @@ func (w Warehouse) GetConfigByWarehouseID(warehouseID string) (*model.WarehouseC } return r.Data, nil } + +// GetWarehouses ... +func (w Warehouse) GetWarehouses(p model.GetWarehousesRequest) (*model.GetWarehousesResponse, error) { + msg, err := natsio.GetServer().Request(subject.Warehouse.GetWarehouses, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.GetWarehousesResponse `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 b546725..fc52b78 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -80,3 +80,14 @@ type SupplierIsClosed struct { Supplier string `json:"supplier"` IsClosed bool `json:"isClosed"` } + +// GetWarehousesRequest ... +type GetWarehousesRequest struct { + Keyword string `json:"keyword"` + Status string `json:"status"` + Supplier string `json:"supplier"` + BusinessType string `json:"businessType"` + + Page int64 `json:"page"` + Limit int64 `json:"limit"` +} diff --git a/model/warehouse_response.go b/model/warehouse_response.go index f2d60a9..88ba2f1 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -135,3 +135,30 @@ type WarehouseNatsResponse struct { CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` } + +// WarehouseInfo ... +type WarehouseInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + BusinessType string `json:"businessType"` + Status string `json:"status"` + Slug string `json:"slug"` + Supplier WarehouseSupplierInfo `json:"supplier"` + Location ResponseWarehouseLocation `json:"location"` + Contact ResponseWarehouseContact `json:"contact"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` +} + +// WarehouseSupplierInfo ... +type WarehouseSupplierInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} + +// GetWarehousesResponse ... +type GetWarehousesResponse struct { + Total int64 `json:"total"` + Limit int64 `json:"limit"` + List []WarehouseInfo `json:"list"` +} diff --git a/subject/warehouse.go b/subject/warehouse.go index a0480ae..378e1a8 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -21,6 +21,7 @@ var Warehouse = struct { AfterUpdateWarehouse string AfterCreateWarehouse string UpdateIsClosedSupplier string + GetWarehouses string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -36,4 +37,5 @@ var Warehouse = struct { Distinct: getWarehouseValue("distinct"), Count: getWarehouseValue("count"), UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), + GetWarehouses: getWarehouseValue("get_warehouses"), } From 7a3e50ef97b87d5c87ca6b3ecffaf95c10f20e0e Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 17:59:44 +0700 Subject: [PATCH 26/34] update location --- client/location.go | 201 ++++++++++++++++++++++++++++++++++++-- client/location_dao.go | 180 ---------------------------------- model/location_request.go | 57 +++++++---- subject/location.go | 52 +++++----- 4 files changed, 261 insertions(+), 229 deletions(-) delete mode 100644 client/location_dao.go diff --git a/client/location.go b/client/location.go index 2e8d30e..96d235c 100644 --- a/client/location.go +++ b/client/location.go @@ -28,7 +28,7 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode Data *model.ResponseLocationAddress `json:"data"` Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -38,7 +38,7 @@ func (l Location) GetLocationByCode(payload model.LocationRequestPayload) (*mode return r.Data, nil } -// GetProvincesByCodes ... ... +// GetProvincesByCodes ... func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.LocationProvinceResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCodes, toBytes(p)) if err != nil { @@ -46,11 +46,11 @@ func (l Location) GetProvincesByCodes(p model.ProvinceRequestPayload) (*model.Lo } var r struct { - Data *model.LocationProvinceResponse `json:"data"'` + Data *model.LocationProvinceResponse `json:"data"` Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -71,7 +71,7 @@ func (l Location) GetDistrictsByCodes(p model.DistrictRequestPayload) (*model.Lo Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -94,7 +94,7 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa Error string `json:"error"` } - if err := json.Unmarshal(msg.Data, &r); err != nil { + if err = json.Unmarshal(msg.Data, &r); err != nil { return nil, err } @@ -104,3 +104,192 @@ func (l Location) GetWardsByCodes(p model.WardRequestPayload) (*model.LocationWa return r.Data, nil } + +// GetProvinceByCondition ... +func (l Location) GetProvinceByCondition(p model.ProvinceRequestCondition) (*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetProvinceByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationProvinceDetailResponse `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 +} + +// GetProvincesByCondition ... +func (l Location) GetProvincesByCondition(p model.DistrictRequestCondition) ([]*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationProvinceDetailResponse `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 +} + +// GetDistrictByCondition ... +func (l Location) GetDistrictByCondition(p model.ProvinceRequestCondition) (*model.LocationProvinceDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationProvinceDetailResponse `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 +} + +// GetDistrictsByCondition ... +func (l Location) GetDistrictsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationDistrictDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationDistrictDetailResponse `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 +} + +// GetWardByCondition ... +func (l Location) GetWardByCondition(p model.DistrictRequestCondition) (*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetWardByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.LocationWardDetailResponse `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 +} + +// GetWardsByCondition ... +func (l Location) GetWardsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationWardDetailResponse, error) { + msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCondition, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data []*model.LocationWardDetailResponse `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 +} + +// CountProvinceByCondition ... +func (l Location) CountProvinceByCondition(p model.WardRequestCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountDistrictByCondition ... +func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} + +// CountWardByCondition ... +func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { + msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, toBytes(p)) + if err != nil { + return 0, err + } + var r struct { + Data int64 `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return 0, err + } + if r.Error != "" { + return 0, errors.New(r.Error) + } + return r.Data, nil +} diff --git a/client/location_dao.go b/client/location_dao.go deleted file mode 100644 index 3c09c55..0000000 --- a/client/location_dao.go +++ /dev/null @@ -1,180 +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" -) - -// FindOneProvinceByCondition ... -func (l Location) FindOneProvinceByCondition(p model.FindOneCondition) (*model.LocationProvinceDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindOneProvinceByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.LocationProvinceDetailResponse `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 -} - -// FindOneDistrictByCondition ... -func (l Location) FindOneDistrictByCondition(p model.FindOneCondition) (*model.LocationDistrictDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindOneDistrictByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.LocationDistrictDetailResponse `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 -} - -// FindOneWardByCondition ... -func (l Location) FindOneWardByCondition(p model.FindOneCondition) (*model.LocationWardDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindOneWardByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data *model.LocationWardDetailResponse `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 -} - -// FindProvinceByCondition ... -func (l Location) FindProvinceByCondition(p model.FindWithCondition) ([]*model.LocationProvinceDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindProvinceByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data []*model.LocationProvinceDetailResponse `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 -} - -// FindDistrictByCondition ... -func (l Location) FindDistrictByCondition(p model.FindWithCondition) ([]*model.LocationDistrictDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindDistrictByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data []*model.LocationDistrictDetailResponse `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 -} - -// FindWardByCondition ... -func (l Location) FindWardByCondition(p model.FindWithCondition) ([]*model.LocationWardDetailResponse, error) { - msg, err := natsio.GetServer().Request(subject.Location.FindWardByCondition, bsonToBytes(p)) - if err != nil { - return nil, err - } - var r struct { - Data []*model.LocationWardDetailResponse `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 -} - -// CountProvinceByCondition ... -func (l Location) CountProvinceByCondition(p model.FindWithCondition) (int64, error) { - msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, bsonToBytes(p)) - if err != nil { - return 0, err - } - var r struct { - Data int64 `json:"data"` - Error string `json:"error"` - } - if err = json.Unmarshal(msg.Data, &r); err != nil { - return 0, err - } - if r.Error != "" { - return 0, errors.New(r.Error) - } - return r.Data, nil -} - -// CountDistrictByCondition ... -func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { - msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, bsonToBytes(p)) - if err != nil { - return 0, err - } - var r struct { - Data int64 `json:"data"` - Error string `json:"error"` - } - if err = json.Unmarshal(msg.Data, &r); err != nil { - return 0, err - } - if r.Error != "" { - return 0, errors.New(r.Error) - } - return r.Data, nil -} - -// CountWardByCondition ... -func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { - msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, bsonToBytes(p)) - if err != nil { - return 0, err - } - var r struct { - Data int64 `json:"data"` - Error string `json:"error"` - } - if err = json.Unmarshal(msg.Data, &r); err != nil { - return 0, err - } - if r.Error != "" { - return 0, errors.New(r.Error) - } - return r.Data, nil -} diff --git a/model/location_request.go b/model/location_request.go index 4533db7..22bdea7 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -1,23 +1,46 @@ package model // LocationRequestPayload ... -type LocationRequestPayload struct { - Province int `json:"province"` - District int `json:"district"` - Ward int `json:"ward"` -} +type ( + LocationRequestPayload struct { + Province int `json:"province"` + District int `json:"district"` + Ward int `json:"ward"` + } -// ProvinceRequestPayload ... -type ProvinceRequestPayload struct { - Codes []int `json:"codes"` -} + // ProvinceRequestPayload ... + ProvinceRequestPayload struct { + Codes []int `json:"codes"` + } -// DistrictRequestPayload ... -type DistrictRequestPayload struct { - Codes []int `json:"codes"` -} + // ProvinceRequestCondition ... + ProvinceRequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + } -// WardRequestPayload ... -type WardRequestPayload struct { - Codes []int `json:"codes"` -} + // DistrictRequestPayload ... + DistrictRequestPayload struct { + Codes []int `json:"codes"` + } + + // DistrictRequestCondition ... + DistrictRequestCondition struct { + Code int `json:"code"` + Codes int `json:"codes"` + ProvinceCode int `json:"provinceCode"` + } + + // WardRequestPayload ... + WardRequestPayload struct { + Codes []int `json:"codes"` + } + + // WardRequestCondition ... + WardRequestCondition struct { + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + } +) diff --git a/subject/location.go b/subject/location.go index 7525c25..40a21e4 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,31 +7,31 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string - FindOneProvinceByCondition string - FindOneDistrictByCondition string - FindOneWardByCondition string - FindProvinceByCondition string - FindDistrictByCondition string - FindWardByCondition string - CountProvinceByCondition string - CountDistrictByCondition string - CountWardByCondition string + GetLocationByCode string + GetProvincesByCodes string + GetDistrictsByCodes string + GetWardsByCodes string + GetProvinceByCondition string + GetProvincesByCondition string + GetDistrictByCondition string + GetDistrictsByCondition string + GetWardByCondition string + GetWardsByCondition string + CountProvinceByCondition string + CountDistrictByCondition string + CountWardByCondition string }{ - GetLocationByCode: getLocationValue("get_location_warehouse"), - GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), - GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), - GetWardsByCodes: getLocationValue("get_wards_by_codes"), - FindOneProvinceByCondition: getLocationValue("find_one_province_by_condition"), - FindOneDistrictByCondition: getLocationValue("find_one_district_by_condition"), - FindOneWardByCondition: getLocationValue("find_one_ward_by_condition"), - FindProvinceByCondition: getLocationValue("find_province_by_condition"), - FindDistrictByCondition: getLocationValue("find_district_by_condition"), - FindWardByCondition: getLocationValue("find_ward_by_condition"), - CountProvinceByCondition: getLocationValue("count_province_by_condition"), - CountDistrictByCondition: getLocationValue("count_district_by_condition"), - CountWardByCondition: getLocationValue("count_ward_by_condition"), + GetLocationByCode: getLocationValue("get_location_warehouse"), + GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetProvinceByCondition: getLocationValue("get_province_by_condition"), + GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), + GetDistrictByCondition: getLocationValue("get_district_by_condition"), + GetDistrictsByCondition: getLocationValue("get_districts_byCondition"), + GetWardByCondition: getLocationValue("get_ward_by_condition"), + GetWardsByCondition: getLocationValue("get_wards_by_condition"), + CountProvinceByCondition: getLocationValue("count_province_by_condition"), + CountDistrictByCondition: getLocationValue("count_district_by_condition"), + CountWardByCondition: getLocationValue("count_ward_by_condition"), } From 863e924a5e47a001088ec3cd74a7d166ae899a61 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 18:12:42 +0700 Subject: [PATCH 27/34] update location --- client/location.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/location.go b/client/location.go index 96d235c..6e08261 100644 --- a/client/location.go +++ b/client/location.go @@ -128,7 +128,7 @@ func (l Location) GetProvinceByCondition(p model.ProvinceRequestCondition) (*mod } // GetProvincesByCondition ... -func (l Location) GetProvincesByCondition(p model.DistrictRequestCondition) ([]*model.LocationProvinceDetailResponse, error) { +func (l Location) GetProvincesByCondition(p model.ProvinceRequestCondition) ([]*model.LocationProvinceDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetProvincesByCondition, toBytes(p)) if err != nil { return nil, err @@ -150,7 +150,7 @@ func (l Location) GetProvincesByCondition(p model.DistrictRequestCondition) ([]* } // GetDistrictByCondition ... -func (l Location) GetDistrictByCondition(p model.ProvinceRequestCondition) (*model.LocationProvinceDetailResponse, error) { +func (l Location) GetDistrictByCondition(p model.DistrictRequestCondition) (*model.LocationProvinceDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p)) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (l Location) GetDistrictByCondition(p model.ProvinceRequestCondition) (*mod } // GetDistrictsByCondition ... -func (l Location) GetDistrictsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationDistrictDetailResponse, error) { +func (l Location) GetDistrictsByCondition(p model.DistrictRequestCondition) ([]*model.LocationDistrictDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetDistrictsByCondition, toBytes(p)) if err != nil { return nil, err @@ -194,7 +194,7 @@ func (l Location) GetDistrictsByCondition(p model.ProvinceRequestCondition) ([]* } // GetWardByCondition ... -func (l Location) GetWardByCondition(p model.DistrictRequestCondition) (*model.LocationWardDetailResponse, error) { +func (l Location) GetWardByCondition(p model.WardRequestCondition) (*model.LocationWardDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetWardByCondition, toBytes(p)) if err != nil { return nil, err @@ -216,7 +216,7 @@ func (l Location) GetWardByCondition(p model.DistrictRequestCondition) (*model.L } // GetWardsByCondition ... -func (l Location) GetWardsByCondition(p model.ProvinceRequestCondition) ([]*model.LocationWardDetailResponse, error) { +func (l Location) GetWardsByCondition(p model.WardRequestCondition) ([]*model.LocationWardDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetWardsByCondition, toBytes(p)) if err != nil { return nil, err @@ -238,7 +238,7 @@ func (l Location) GetWardsByCondition(p model.ProvinceRequestCondition) ([]*mode } // CountProvinceByCondition ... -func (l Location) CountProvinceByCondition(p model.WardRequestCondition) (int64, error) { +func (l Location) CountProvinceByCondition(p model.ProvinceRequestCondition) (int64, error) { msg, err := natsio.GetServer().Request(subject.Location.CountProvinceByCondition, toBytes(p)) if err != nil { return 0, err @@ -257,7 +257,7 @@ func (l Location) CountProvinceByCondition(p model.WardRequestCondition) (int64, } // CountDistrictByCondition ... -func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, error) { +func (l Location) CountDistrictByCondition(p model.DistrictRequestCondition) (int64, error) { msg, err := natsio.GetServer().Request(subject.Location.CountDistrictByCondition, toBytes(p)) if err != nil { return 0, err @@ -276,7 +276,7 @@ func (l Location) CountDistrictByCondition(p model.FindWithCondition) (int64, er } // CountWardByCondition ... -func (l Location) CountWardByCondition(p model.FindWithCondition) (int64, error) { +func (l Location) CountWardByCondition(p model.WardRequestCondition) (int64, error) { msg, err := natsio.GetServer().Request(subject.Location.CountWardByCondition, toBytes(p)) if err != nil { return 0, err From a86a0978864179eb55f19a99cf60196d67c824a5 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Wed, 5 Oct 2022 18:15:36 +0700 Subject: [PATCH 28/34] update location --- model/location_request.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/location_request.go b/model/location_request.go index 22bdea7..674b8bd 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -26,9 +26,9 @@ type ( // DistrictRequestCondition ... DistrictRequestCondition struct { - Code int `json:"code"` - Codes int `json:"codes"` - ProvinceCode int `json:"provinceCode"` + Code int `json:"code"` + Codes []int `json:"codes"` + ProvinceCode int `json:"provinceCode"` } // WardRequestPayload ... From 29b2b861ff5ba54382305e5b5c4110fd839b16a2 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 09:19:21 +0700 Subject: [PATCH 29/34] update location add find by slug --- model/location_request.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/model/location_request.go b/model/location_request.go index 674b8bd..98096ff 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -15,8 +15,9 @@ type ( // ProvinceRequestCondition ... ProvinceRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` + Code int `json:"code"` + Codes []int `json:"codes"` + Slug string `json:"slug"` } // DistrictRequestPayload ... @@ -26,9 +27,10 @@ type ( // DistrictRequestCondition ... DistrictRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - ProvinceCode int `json:"provinceCode"` + Code int `json:"code"` + Codes []int `json:"codes"` + ProvinceCode int `json:"provinceCode"` + Slug string `json:"slug"` } // WardRequestPayload ... @@ -38,9 +40,10 @@ type ( // WardRequestCondition ... WardRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - DistrictCode int `json:"districtCode"` - ProvinceCode int `json:"provinceCode"` + Code int `json:"code"` + Codes []int `json:"codes"` + DistrictCode int `json:"districtCode"` + ProvinceCode int `json:"provinceCode"` + Slug string `json:"slug"` } ) From b9b55d144e9dcae3a757c068c4728df34a2b91c1 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 10:20:47 +0700 Subject: [PATCH 30/34] update fix GetDistrictByCondition --- client/location.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/location.go b/client/location.go index 6e08261..76f9a3f 100644 --- a/client/location.go +++ b/client/location.go @@ -150,14 +150,14 @@ func (l Location) GetProvincesByCondition(p model.ProvinceRequestCondition) ([]* } // GetDistrictByCondition ... -func (l Location) GetDistrictByCondition(p model.DistrictRequestCondition) (*model.LocationProvinceDetailResponse, error) { +func (l Location) GetDistrictByCondition(p model.DistrictRequestCondition) (*model.LocationDistrictDetailResponse, error) { msg, err := natsio.GetServer().Request(subject.Location.GetDistrictByCondition, toBytes(p)) if err != nil { return nil, err } var r struct { - Data *model.LocationProvinceDetailResponse `json:"data"` + Data *model.LocationDistrictDetailResponse `json:"data"` Error string `json:"error"` } From cebb3214cfcac46f61a7f6c1b90fa816d92f5165 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 10:55:49 +0700 Subject: [PATCH 31/34] update location add slug & DistinctWithField --- client/location.go | 19 ++++++++++++++ model/location_request.go | 18 ++++++++++--- subject/location.go | 54 ++++++++++++++++++++------------------- 3 files changed, 62 insertions(+), 29 deletions(-) diff --git a/client/location.go b/client/location.go index 76f9a3f..d8b3380 100644 --- a/client/location.go +++ b/client/location.go @@ -293,3 +293,22 @@ func (l Location) CountWardByCondition(p model.WardRequestCondition) (int64, err } return r.Data, nil } + +// DistinctWithField ... +func (l Location) DistinctWithField(p model.ProvinceDistinctWithField) ([]interface{}, error) { + msg, err := natsio.GetServer().Request(subject.Location.ProvinceDistinctWithField, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data []interface{} `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/location_request.go b/model/location_request.go index 98096ff..5816b52 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -15,9 +15,10 @@ type ( // ProvinceRequestCondition ... ProvinceRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - Slug string `json:"slug"` + Code int `json:"code"` + Codes []int `json:"codes"` + Slug string `json:"slug"` + Slugs []string `json:"slugs"` } // DistrictRequestPayload ... @@ -31,6 +32,7 @@ type ( Codes []int `json:"codes"` ProvinceCode int `json:"provinceCode"` Slug string `json:"slug"` + ProvinceSlug string `json:"provinceSlug"` } // WardRequestPayload ... @@ -45,5 +47,15 @@ type ( DistrictCode int `json:"districtCode"` ProvinceCode int `json:"provinceCode"` Slug string `json:"slug"` + DistrictSlug string `json:"districtSlug"` + ProvinceSlug string `json:"provinceSlug"` + } + + // ProvinceDistinctWithField ... + ProvinceDistinctWithField struct { + Conditions struct { + Region string `json:"region"` + } `json:"conditions"` + Field string `json:"filed"` } ) diff --git a/subject/location.go b/subject/location.go index 40a21e4..c625ca4 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,31 +7,33 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes string - GetProvinceByCondition string - GetProvincesByCondition string - GetDistrictByCondition string - GetDistrictsByCondition string - GetWardByCondition string - GetWardsByCondition string - CountProvinceByCondition string - CountDistrictByCondition string - CountWardByCondition string + GetLocationByCode string + GetProvincesByCodes string + GetDistrictsByCodes string + GetWardsByCodes string + GetProvinceByCondition string + GetProvincesByCondition string + GetDistrictByCondition string + GetDistrictsByCondition string + GetWardByCondition string + GetWardsByCondition string + CountProvinceByCondition string + CountDistrictByCondition string + CountWardByCondition string + ProvinceDistinctWithField string }{ - GetLocationByCode: getLocationValue("get_location_warehouse"), - GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), - GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), - GetWardsByCodes: getLocationValue("get_wards_by_codes"), - GetProvinceByCondition: getLocationValue("get_province_by_condition"), - GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), - GetDistrictByCondition: getLocationValue("get_district_by_condition"), - GetDistrictsByCondition: getLocationValue("get_districts_byCondition"), - GetWardByCondition: getLocationValue("get_ward_by_condition"), - GetWardsByCondition: getLocationValue("get_wards_by_condition"), - CountProvinceByCondition: getLocationValue("count_province_by_condition"), - CountDistrictByCondition: getLocationValue("count_district_by_condition"), - CountWardByCondition: getLocationValue("count_ward_by_condition"), + GetLocationByCode: getLocationValue("get_location_warehouse"), + GetProvincesByCodes: getLocationValue("get_provinces_by_codes"), + GetDistrictsByCodes: getLocationValue("get_districts_by_codes"), + GetWardsByCodes: getLocationValue("get_wards_by_codes"), + GetProvinceByCondition: getLocationValue("get_province_by_condition"), + GetProvincesByCondition: getLocationValue("get_provinces_by_condition"), + GetDistrictByCondition: getLocationValue("get_district_by_condition"), + GetDistrictsByCondition: getLocationValue("get_districts_byCondition"), + GetWardByCondition: getLocationValue("get_ward_by_condition"), + GetWardsByCondition: getLocationValue("get_wards_by_condition"), + CountProvinceByCondition: getLocationValue("count_province_by_condition"), + CountDistrictByCondition: getLocationValue("count_district_by_condition"), + CountWardByCondition: getLocationValue("count_ward_by_condition"), + ProvinceDistinctWithField: getLocationValue("province_distinct_with_field"), } From 3e13cb55b32ff8f8d73c8a61da534cb137329f35 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Thu, 6 Oct 2022 11:22:10 +0700 Subject: [PATCH 32/34] update location request condition --- model/location_request.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/model/location_request.go b/model/location_request.go index 5816b52..69245aa 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -15,10 +15,12 @@ type ( // ProvinceRequestCondition ... ProvinceRequestCondition struct { - Code int `json:"code"` - Codes []int `json:"codes"` - Slug string `json:"slug"` - Slugs []string `json:"slugs"` + Code int `json:"code"` + Codes []int `json:"codes"` + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + Keyword string `json:"keyword"` + Region string `json:"region"` } // DistrictRequestPayload ... @@ -33,6 +35,7 @@ type ( ProvinceCode int `json:"provinceCode"` Slug string `json:"slug"` ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` } // WardRequestPayload ... From ed0f16623ad22857148aa4a216117292317b0819 Mon Sep 17 00:00:00 2001 From: quang1472001 Date: Fri, 7 Oct 2022 15:23:02 +0700 Subject: [PATCH 33/34] add old slug to location response struct --- model/location_response.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/model/location_response.go b/model/location_response.go index 2674041..1595908 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -54,6 +54,7 @@ type ( Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` Code int `json:"code"` CountryCode string `json:"countryCode"` RegionCode string `json:"regionCode"` @@ -70,6 +71,7 @@ type ( Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` + OldSlug string `json:"oldSlug"` Code int `json:"code"` ProvinceCode int `json:"provinceCode"` Area int `json:"area"` @@ -84,6 +86,7 @@ type ( Name string `json:"name"` SearchString string `json:"searchString"` Slug string `json:"slug"` + OldSlugs []string `json:"oldSlugs"` Code int `json:"code"` DistrictCode int `json:"districtCode"` ProvinceCode int `json:"provinceCode"` From 42874f493736868645f4b47b8dfcb0a1b1854ccc Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Mon, 10 Oct 2022 09:06:20 +0700 Subject: [PATCH 34/34] seller-add-field-planPackage --- model/seller_response.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/model/seller_response.go b/model/seller_response.go index aec57b9..01c80e5 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -21,16 +21,25 @@ type ResponseListSellerInfoSupportChat struct { // 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"` + 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"` + PlanPackage *SellerPlanPackageInfo `json:"planPackage"` +} + +// SellerPlanPackageInfo ... +type SellerPlanPackageInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Level int `json:"level"` + CreatedAt time.Time `json:"createdAt"` } // SellerTrackingTime ...