From cc48a083f2f9f4c1b063c74ae755a940b7865cba Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 13 Sep 2022 11:47:46 +0700 Subject: [PATCH 01/27] [Update] Response warehouse --- model/warehouse_response.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/model/warehouse_response.go b/model/warehouse_response.go index 2429743..f2d60a9 100644 --- a/model/warehouse_response.go +++ b/model/warehouse_response.go @@ -25,6 +25,20 @@ 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 ... @@ -109,6 +123,7 @@ 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"` From 9f1f2faf9e1066b7fcf9fd76eb667e352493a5a5 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Wed, 14 Sep 2022 14:39:16 +0700 Subject: [PATCH 02/27] [Update] Response supplier --- model/supplier_response.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/model/supplier_response.go b/model/supplier_response.go index a87a29e..975a8de 100644 --- a/model/supplier_response.go +++ b/model/supplier_response.go @@ -2,8 +2,9 @@ package model // ResponseSupplierInfo ... type ResponseSupplierInfo struct { - ID string `json:"id"` - Name string `json:"name"` + ID string `json:"id"` + Name string `json:"name"` + BusinessType string `json:"businessType"` } // ResponseSupplierContract ... @@ -16,11 +17,12 @@ type ResponseSupplierContract struct { // SupplierBrief ... type SupplierBrief struct { - ID string `json:"_id"` - Name string `json:"name"` - Status string `json:"status"` - CreatedAt string `json:"createdAt"` - UpdatedAt string `json:"updatedAt"` + ID string `json:"_id"` + Name string `json:"name"` + Status string `json:"status"` + BusinessType string `json:"businessType"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` } type SupplierAll struct { From 40533e180544950fcb43b0d72c6f570ee821d455 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 15 Sep 2022 14:09:54 +0700 Subject: [PATCH 03/27] seller by id --- client/seller.go | 40 ++++++++++++++++++++++++++++++++++++++++ model/seller_request.go | 8 ++++++++ model/seller_response.go | 8 ++++++++ subject/config.go | 2 ++ subject/seller.go | 14 ++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 client/seller.go create mode 100644 model/seller_request.go create mode 100644 model/seller_response.go create mode 100644 subject/seller.go diff --git a/client/seller.go b/client/seller.go new file mode 100644 index 0000000..ec3ab83 --- /dev/null +++ b/client/seller.go @@ -0,0 +1,40 @@ +package client + +import ( + "encoding/json" + "errors" + "github.com/Selly-Modules/natsio" + "github.com/Selly-Modules/natsio/model" + "github.com/Selly-Modules/natsio/subject" +) + +// Seller ... +type Seller struct{} + +// GetSeller ... +func GetSeller() Seller { + return Seller{} +} + +// GetSellerInfoByID ... +func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.ResponseSellerInfo, error) { + msg, err := natsio.GetServer().Request(subject.Seller.GetSellerInfoByID, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseSellerInfo `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 new file mode 100644 index 0000000..997cd97 --- /dev/null +++ b/model/seller_request.go @@ -0,0 +1,8 @@ +package model + +import "go.mongodb.org/mongo-driver/bson/primitive" + +// GetSellerByIDRequest ... +type GetSellerByIDRequest struct { + SellerID primitive.ObjectID `json:"sellerId"` +} diff --git a/model/seller_response.go b/model/seller_response.go new file mode 100644 index 0000000..6b7d698 --- /dev/null +++ b/model/seller_response.go @@ -0,0 +1,8 @@ +package model + +// ResponseSellerInfo ... +type ResponseSellerInfo struct { + ID string `json:"id"` + Name string `json:"name"` + Code string `json:"code"` +} diff --git a/subject/config.go b/subject/config.go index dfeea56..cb215bc 100644 --- a/subject/config.go +++ b/subject/config.go @@ -6,10 +6,12 @@ var prefixes = struct { Warehouse string Location string Supplier string + Seller string }{ Communication: "communication", Order: "order", Warehouse: "warehouse", Location: "location", Supplier: "supplier", + Seller: "seller", } diff --git a/subject/seller.go b/subject/seller.go new file mode 100644 index 0000000..033f993 --- /dev/null +++ b/subject/seller.go @@ -0,0 +1,14 @@ +package subject + +import "fmt" + +func getSellerValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Seller, val) +} + +// Seller ... +var Seller = struct { + GetSellerInfoByID string +}{ + GetSellerInfoByID: getSellerValue("get_seller_info_by_id"), +} From fb8a8bd471bab82311c8356d2be2fab685d2afa1 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Fri, 16 Sep 2022 14:49:53 +0700 Subject: [PATCH 04/27] [Update] Add request updateIsClosedSupplier --- client/warehouse.go | 18 ++++++++++++++++++ model/warehouse_request.go | 11 +++++++++++ subject/warehouse.go | 2 ++ 3 files changed, 31 insertions(+) diff --git a/client/warehouse.go b/client/warehouse.go index 6c04925..43b3168 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -17,6 +17,24 @@ func GetWarehouse() Warehouse { return Warehouse{} } +// UpdateIsClosedSupplier ... +func (w Warehouse) UpdateIsClosedSupplier(p model.WarehouseNatsResponse) 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/warehouse_request.go b/model/warehouse_request.go index 543fc68..b546725 100644 --- a/model/warehouse_request.go +++ b/model/warehouse_request.go @@ -69,3 +69,14 @@ 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/subject/warehouse.go b/subject/warehouse.go index 5d0a81c..a0480ae 100644 --- a/subject/warehouse.go +++ b/subject/warehouse.go @@ -20,6 +20,7 @@ var Warehouse = struct { Count string AfterUpdateWarehouse string AfterCreateWarehouse string + UpdateIsClosedSupplier string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -34,4 +35,5 @@ var Warehouse = struct { FindByCondition: getWarehouseValue("find_all_by_condition"), Distinct: getWarehouseValue("distinct"), Count: getWarehouseValue("count"), + UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), } From 92040d0b9f453256437f88a03956e31c0835b1cd Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Fri, 16 Sep 2022 15:36:32 +0700 Subject: [PATCH 05/27] [Update] Payload --- client/warehouse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/warehouse.go b/client/warehouse.go index 43b3168..fdb70b8 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -18,7 +18,7 @@ func GetWarehouse() Warehouse { } // UpdateIsClosedSupplier ... -func (w Warehouse) UpdateIsClosedSupplier(p model.WarehouseNatsResponse) error { +func (w Warehouse) UpdateIsClosedSupplier(p model.UpdateSupplierIsClosedRequest) error { msg, err := natsio.GetServer().Request(subject.Warehouse.UpdateIsClosedSupplier, toBytes(p)) if err != nil { return err From 89967955ea2af42c918b213a4183f2d3a471db93 Mon Sep 17 00:00:00 2001 From: phuanbui Date: Mon, 19 Sep 2022 11:48:30 +0700 Subject: [PATCH 06/27] 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 35a811886b1113bda8683c1063da558766ae49ac Mon Sep 17 00:00:00 2001 From: phuanbui Date: Mon, 19 Sep 2022 14:52:26 +0700 Subject: [PATCH 07/27] 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 1d58e55af736b32c7526d711161ef9509d6bb83f Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 10:28:35 +0700 Subject: [PATCH 08/27] [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 34c61ccfcc7d2ab95cd27969f54ed0a0eb460190 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Tue, 20 Sep 2022 10:56:45 +0700 Subject: [PATCH 09/27] [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 10/27] [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 11/27] 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 12/27] 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 4ac7ec3b0ceb1a29519d680da717ec5547c4652f Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 22 Sep 2022 13:49:11 +0700 Subject: [PATCH 13/27] 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 b718162cd439fd67487b695f48d4a9f7f90a4469 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Fri, 23 Sep 2022 10:13:14 +0700 Subject: [PATCH 14/27] 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 15/27] 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 16/27] 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 17/27] 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 18/27] 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 19/27] 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 20/27] 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 21/27] 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 22/27] 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 23/27] 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 0a82f40a252b79f9dfaa3d24d73b76973a1aa2b5 Mon Sep 17 00:00:00 2001 From: namhq Date: Mon, 10 Oct 2022 04:05:49 +0000 Subject: [PATCH 24/27] Update 'go.mod' --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ac44201..bd87680 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Selly-Modules/natsio +module git.selly.red/Selly-Modules/natsio go 1.16 From c11419a3ad3353b5c32da1d47c29ae3f8a0a5e45 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Mon, 10 Oct 2022 11:11:39 +0700 Subject: [PATCH 25/27] [Update] Package --- client/communication.go | 6 +++--- client/location.go | 6 +++--- client/news.go | 6 +++--- client/order.go | 6 +++--- client/seller.go | 6 +++--- client/supplier.go | 6 +++--- client/warehouse.go | 6 +++--- client/warehouse_dao.go | 6 +++--- go.sum | 13 +++++++++++-- 9 files changed, 35 insertions(+), 26 deletions(-) diff --git a/client/communication.go b/client/communication.go index 6dd94cb..1d8254d 100644 --- a/client/communication.go +++ b/client/communication.go @@ -3,9 +3,9 @@ package client import ( "encoding/json" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Communication ... diff --git a/client/location.go b/client/location.go index 2e8d30e..18be423 100644 --- a/client/location.go +++ b/client/location.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Location ... diff --git a/client/news.go b/client/news.go index 6bacf54..d33787a 100644 --- a/client/news.go +++ b/client/news.go @@ -3,9 +3,9 @@ package client import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // News ... diff --git a/client/order.go b/client/order.go index 7d23cee..2e7f0a3 100644 --- a/client/order.go +++ b/client/order.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Order ... diff --git a/client/seller.go b/client/seller.go index 1d06208..30987bd 100644 --- a/client/seller.go +++ b/client/seller.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Seller ... diff --git a/client/supplier.go b/client/supplier.go index 700d714..8de78fb 100644 --- a/client/supplier.go +++ b/client/supplier.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Supplier ... diff --git a/client/warehouse.go b/client/warehouse.go index 5ae07db..944c2cb 100644 --- a/client/warehouse.go +++ b/client/warehouse.go @@ -4,9 +4,9 @@ import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // Warehouse ... diff --git a/client/warehouse_dao.go b/client/warehouse_dao.go index 69c2245..56c046f 100644 --- a/client/warehouse_dao.go +++ b/client/warehouse_dao.go @@ -3,9 +3,9 @@ package client import ( "encoding/json" "errors" - "github.com/Selly-Modules/natsio" - "github.com/Selly-Modules/natsio/model" - "github.com/Selly-Modules/natsio/subject" + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" ) // DistinctWithField ... diff --git a/go.sum b/go.sum index f3e58d6..85b108e 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,7 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -24,10 +25,9 @@ github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47e github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= -github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/nats-io/jwt v1.2.2 h1:w3GMTO969dFg+UOKTmmyuu7IGdusK+7Ytlt//OYH/uU= github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= @@ -43,6 +43,7 @@ github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8= github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -52,10 +53,15 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= +github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4= go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= @@ -68,6 +74,7 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -80,10 +87,12 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= From 1c10210bb96d4e1b2c4688ef55c5e74c8bcd0fe9 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 11 Oct 2022 14:13:15 +0700 Subject: [PATCH 26/27] rebuild --- client/bank.go | 55 ++++++++++++++++++++++++++++++++++++ client/bank_branch.go | 39 +++++++++++++++++++++++++ model/bank_branch_reponse.go | 11 ++++++++ model/bank_branch_request.go | 6 ++++ model/bank_response.go | 21 ++++++++++++++ subject/bank.go | 17 +++++++++++ 6 files changed, 149 insertions(+) create mode 100644 client/bank.go create mode 100644 client/bank_branch.go create mode 100644 model/bank_branch_reponse.go create mode 100644 model/bank_branch_request.go create mode 100644 model/bank_response.go create mode 100644 subject/bank.go diff --git a/client/bank.go b/client/bank.go new file mode 100644 index 0000000..3391911 --- /dev/null +++ b/client/bank.go @@ -0,0 +1,55 @@ +package client + +import ( + "encoding/json" + "errors" + + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// 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 +} + +func (s Bank) CheckBankAndBranchByID(p model.BankBranchRequest) bool { + msg, err := natsio.GetServer().Request(subject.Bank.CheckBankAndBranchByID, toBytes(p)) + if err != nil { + return false + } + + var r struct { + Error string `json:"error"` + } + + if err = json.Unmarshal(msg.Data, &r); err != nil { + return false + } + return r.Error == "" +} diff --git a/client/bank_branch.go b/client/bank_branch.go new file mode 100644 index 0000000..5890e75 --- /dev/null +++ b/client/bank_branch.go @@ -0,0 +1,39 @@ +package client + +import ( + "encoding/json" + "errors" + + "git.selly.red/Selly-Modules/natsio" + "git.selly.red/Selly-Modules/natsio/model" + "git.selly.red/Selly-Modules/natsio/subject" +) + +// 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/model/bank_branch_reponse.go b/model/bank_branch_reponse.go new file mode 100644 index 0000000..1fa1432 --- /dev/null +++ b/model/bank_branch_reponse.go @@ -0,0 +1,11 @@ +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_branch_request.go b/model/bank_branch_request.go new file mode 100644 index 0000000..6de1216 --- /dev/null +++ b/model/bank_branch_request.go @@ -0,0 +1,6 @@ +package model + +type BankBranchRequest struct { + BankID string `json:"bankId"` + BranchID string `json:"branchId"` +} diff --git a/model/bank_response.go b/model/bank_response.go new file mode 100644 index 0000000..74fc10e --- /dev/null +++ b/model/bank_response.go @@ -0,0 +1,21 @@ +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/subject/bank.go b/subject/bank.go new file mode 100644 index 0000000..9f7f8bb --- /dev/null +++ b/subject/bank.go @@ -0,0 +1,17 @@ +package subject + +import "fmt" + +func getBankValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Bank, val) +} + +var Bank = struct { + GetBankById string + GetBankBranchById string + CheckBankAndBranchByID string +}{ + GetBankById: getBankValue("get_bank_by_id"), + GetBankBranchById: getBankValue("get_bank_branch_by_id"), + CheckBankAndBranchByID: getBankValue("check_bank_and_brach_by_id"), +} From cb7f37dea9a235edf09374a455e427493962b628 Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 11 Oct 2022 14:17:07 +0700 Subject: [PATCH 27/27] rebuild --- subject/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subject/config.go b/subject/config.go index 7a69414..4a2f9f3 100644 --- a/subject/config.go +++ b/subject/config.go @@ -6,6 +6,7 @@ var prefixes = struct { News string Warehouse string Location string + Bank string Supplier string Seller string }{ @@ -15,5 +16,6 @@ var prefixes = struct { Warehouse: "warehouse", Location: "location", Supplier: "supplier", + Bank: "bank", Seller: "seller", }