diff --git a/client/location.go b/client/location.go index 2e8d30e..d8b3380 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,211 @@ 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.ProvinceRequestCondition) ([]*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.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.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 +} + +// GetDistrictsByCondition ... +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 + } + + 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.WardRequestCondition) (*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.WardRequestCondition) ([]*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.ProvinceRequestCondition) (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.DistrictRequestCondition) (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.WardRequestCondition) (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 +} + +// 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/client/news.go b/client/news.go new file mode 100644 index 0000000..6bacf54 --- /dev/null +++ b/client/news.go @@ -0,0 +1,36 @@ +package client + +import ( + "encoding/json" + "errors" + "github.com/Selly-Modules/natsio" + "github.com/Selly-Modules/natsio/model" + "github.com/Selly-Modules/natsio/subject" +) + +// News ... +type News struct{} + +// GetNews ... +func GetNews() News { + return News{} +} + +// GetProductNoticesByInventory ... +func (n News) GetProductNoticesByInventory(p model.GetProductNoticesByInventoryRequest) (*model.GetProductNoticesByInventoryResponse, error) { + msg, err := natsio.GetServer().Request(subject.News.GetProductNoticesByInventory, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.GetProductNoticesByInventoryResponse `json:"data"` + Error string `json:"error"` + } + if err = json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + if r.Error != "" { + return nil, errors.New(r.Error) + } + return r.Data, nil +} diff --git a/client/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/client/seller.go b/client/seller.go index ec3ab83..1d06208 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,50 @@ 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 +} + +// GetListSellerInfoSupportChatByIDs ... +func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportChatByIDsRequest) (*model.ResponseListSellerInfoSupportChat, error) { + msg, err := natsio.GetServer().Request(subject.SupportChat.GetListSellerInfoSupportChatByIDs, toBytes(p)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseListSellerInfoSupportChat `json:"data"` + Error string `json:"error"` + } + + if err := json.Unmarshal(msg.Data, &r); err != nil { + return nil, err + } + + if r.Error != "" { + return nil, errors.New(r.Error) + + } + return r.Data, nil +} diff --git a/client/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/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/consumer/selly.go b/js/consumer/selly.go new file mode 100644 index 0000000..975cb5b --- /dev/null +++ b/js/consumer/selly.go @@ -0,0 +1,12 @@ +package jsconsumer + +// Selly ... +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 new file mode 100644 index 0000000..a8e0a60 --- /dev/null +++ b/js/model/selly.go @@ -0,0 +1,60 @@ +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 NotificationOptions `json:"options"` +} + +// NotificationOptions ... +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"` + CommissionTransactionPending float64 `json:"commissionTransactionPending"` + 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/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..2f665bb --- /dev/null +++ b/js/subject/selly.go @@ -0,0 +1,21 @@ +package jssubject + +import ( + "fmt" +) + +// getSellyValue ... +func getSellyValue(val string) string { + return fmt.Sprintf("%s.%s.%s", root, prefixes.Selly, val) +} + +// Selly ... +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"), +} diff --git a/model/location_request.go b/model/location_request.go index 4533db7..69245aa 100644 --- a/model/location_request.go +++ b/model/location_request.go @@ -1,23 +1,64 @@ 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"` + Slug string `json:"slug"` + Slugs []string `json:"slugs"` + Keyword string `json:"keyword"` + Region string `json:"region"` + } -// 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"` + Slug string `json:"slug"` + ProvinceSlug string `json:"provinceSlug"` + Keyword string `json:"keyword"` + } + + // 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"` + 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/model/location_response.go b/model/location_response.go index 484d89e..1595908 100644 --- a/model/location_response.go +++ b/model/location_response.go @@ -1,43 +1,96 @@ 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"` + OldSlug string `json:"oldSlug"` + 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"` + OldSlug string `json:"oldSlug"` + 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"` + OldSlugs []string `json:"oldSlugs"` + 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/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/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..c08f87a --- /dev/null +++ b/model/order_response.go @@ -0,0 +1,35 @@ +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"` + WarehouseStatus string `json:"warehouseStatus"` + 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/model/seller_request.go b/model/seller_request.go index 997cd97..a54996c 100644 --- a/model/seller_request.go +++ b/model/seller_request.go @@ -6,3 +6,13 @@ 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"` +} + +// GetListSellerSupportChatByIDsRequest ... +type GetListSellerSupportChatByIDsRequest struct { + SellerIDs []primitive.ObjectID `json:"sellerIds"` +} diff --git a/model/seller_response.go b/model/seller_response.go index 6b7d698..01c80e5 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -1,8 +1,90 @@ package model +import "time" + // ResponseSellerInfo ... type ResponseSellerInfo struct { - ID string `json:"id"` + ID string `json:"_id"` Name string `json:"name"` Code string `json:"code"` } + +// ResponseListSellerInfo ... +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"` + 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 ... +type SellerTrackingTime struct { + FirstOrderDeliveredAt time.Time `json:"firstOrderDeliveredAt,omitempty"` + ThirdOrderDeliveredAt time.Time `json:"thirdOrderDeliveredAt,omitempty"` +} + +// SellerStatistic ... +type SellerStatistic struct { + ThisMonthSale float64 `bson:"thisMonthSale" json:"thisMonthSale"` + LastMonthSale float64 `bson:"lastMonthSale" json:"lastMonthSale"` + Sale float64 `bson:"sale" json:"sale"` + TransactionTotal int `json:"transactionTotal"` + TransactionPaymentProcessing int `json:"transactionPaymentProcessing"` + TransactionWaitingApprove int `json:"transactionWaitingApprove"` + TransactionPending int `json:"transactionPending"` + TransactionSuccess int `json:"transactionSuccess"` + TransactionRejected int `json:"transactionRejected"` + TransactionDelivering int `json:"transactionDelivering"` + TransactionDelivered int `json:"transactionDelivered"` +} + +// TeamInfo ... +type TeamInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Role string `json:"role"` +} + +// InviteeInfo ... +type InviteeInfo struct { + ID string `json:"_id"` + Name string `json:"name"` +} + +// SellerContactInfo ... +type SellerContactInfo struct { + City int `json:"cityCode"` + CityName string `json:"cityName"` + Gender string `json:"gender"` +} + +// SellerMembershipInfo ... +type SellerMembershipInfo struct { + Level int `json:"level"` + Name string `json:"name"` +} diff --git a/model/warehouse_request.go b/model/warehouse_request.go index b546725..5563ef4 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,13 +26,21 @@ 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 ... 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 ... @@ -56,6 +65,7 @@ type UpdateOutboundRequestLogisticInfoPayload struct { ShippingLabel string `json:"shippingLabel"` TrackingCode string `json:"trackingCode"` ORCode string `json:"orCode"` + TPLCode string `json:"tplCode"` } // CancelOutboundRequest ... @@ -80,3 +90,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/config.go b/subject/config.go index 5483c71..4a2f9f3 100644 --- a/subject/config.go +++ b/subject/config.go @@ -3,6 +3,7 @@ package subject var prefixes = struct { Communication string Order string + News string Warehouse string Location string Bank string @@ -11,6 +12,7 @@ var prefixes = struct { }{ Communication: "communication", Order: "order", + News: "news", Warehouse: "warehouse", Location: "location", Supplier: "supplier", diff --git a/subject/location.go b/subject/location.go index b19a59b..c625ca4 100644 --- a/subject/location.go +++ b/subject/location.go @@ -7,13 +7,33 @@ func getLocationValue(val string) string { } var Location = struct { - GetLocationByCode string - GetProvincesByCodes string - GetDistrictsByCodes string - GetWardsByCodes 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"), + 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"), } diff --git a/subject/news.go b/subject/news.go new file mode 100644 index 0000000..bfec6cf --- /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.News, val) +} + +var News = struct { + GetProductNoticesByInventory string +}{ + GetProductNoticesByInventory: getNewsValue("get_product_notices_by_inventory"), +} 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"), } diff --git a/subject/seller.go b/subject/seller.go index 033f993..eba9131 100644 --- a/subject/seller.go +++ b/subject/seller.go @@ -8,7 +8,16 @@ 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"), +} + +// SupportChat ... +var SupportChat = struct { + GetListSellerInfoSupportChatByIDs string +}{ + GetListSellerInfoSupportChatByIDs: "SELLY_CHAT.REQUEST.SELLER_INFO", } diff --git a/subject/warehouse.go b/subject/warehouse.go index ed29f21..8c149b9 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 @@ -23,6 +24,7 @@ var Warehouse = struct { UpdateIsClosedSupplier string CreateWarehouseIntoServiceSupplier string UpdateWarehouseIntoServiceSupplier string + GetWarehouses string }{ AfterCreateWarehouse: getWarehouseValue("after_create_warehouse"), AfterUpdateWarehouse: getWarehouseValue("after_update_warehouse"), @@ -33,6 +35,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"), @@ -40,4 +43,5 @@ var Warehouse = struct { UpdateIsClosedSupplier: getWarehouseValue("update_is_closed_supplier"), CreateWarehouseIntoServiceSupplier: getWarehouseValue("create_warehouse_into_service_supplier"), UpdateWarehouseIntoServiceSupplier: getWarehouseValue("update_warehouse_into_service_supplier"), + GetWarehouses: getWarehouseValue("get_warehouses"), }