From 583f2abda5476a5b6f8c92f7b9e678eb663242e6 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Wed, 21 Sep 2022 10:19:17 +0700 Subject: [PATCH] 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"), }