diff --git a/client/campaign.go b/client/campaign.go index 82649d3..8368230 100644 --- a/client/campaign.go +++ b/client/campaign.go @@ -34,3 +34,25 @@ func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) } return r.Data, nil } + +// GetCampaignSellerStatistic .... +func (c Campaign) GetCampaignSellerStatistic(req model.GetCampaignSellerStatisticBySellerIDs) (*model.ResponseCampaignSellerStatisticList, error) { + msg, err := natsio.GetServer().Request(subject.Campaign.GetCampaignSellerStatisticBySellerIDs, toBytes(req)) + if err != nil { + return nil, err + } + + var r struct { + Data *model.ResponseCampaignSellerStatisticList `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/campaign_request.go b/model/campaign_request.go index 71227e4..8033196 100644 --- a/model/campaign_request.go +++ b/model/campaign_request.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "go.mongodb.org/mongo-driver/bson/primitive" + "time" +) // GetCampaignTransactionsRequest ... type GetCampaignTransactionsRequest struct { @@ -12,3 +15,8 @@ type GetCampaignTransactionsRequest struct { Page int64 `json:"page"` Limit int64 `json:"limit"` } + +// GetCampaignSellerStatisticBySellerIDs ... +type GetCampaignSellerStatisticBySellerIDs struct { + SellerIDs []primitive.ObjectID +} diff --git a/model/campaign_response.go b/model/campaign_response.go index 9619035..65199e9 100644 --- a/model/campaign_response.go +++ b/model/campaign_response.go @@ -57,3 +57,32 @@ type ResponseCampaignTransactionOptions struct { type ResponseCampaignTransactionAdminConfirmData struct { FriendPublicTotal int64 `json:"friendPublicTotal"` } + +// ResponseCampaignSellerStatisticList ... +type ResponseCampaignSellerStatisticList struct { + List []ResponseCampaignSellerStatistic `json:"list"` +} + +// ResponseCampaignSellerStatistic ... +type ResponseCampaignSellerStatistic struct { + SellerID primitive.ObjectID `json:"sellerId"` + Statistic CampaignSellerStatistic `json:"Statistic"` +} + +// CampaignSellerStatistic ... +type CampaignSellerStatistic struct { + TotalNotRejected int64 `bson:"totalNotRejected" json:"totalNotRejected"` + CashTotalNotRejected float64 `bson:"cashTotalNotRejected" json:"cashTotalNotRejected"` + + TotalCompleted int64 `bson:"totalCompleted" json:"totalCompleted"` + CashTotalCompleted float64 `bson:"cashTotalCompleted" json:"cashTotalCompleted"` + + TotalPending int64 `bson:"totalPending" json:"totalPending"` + CashTotalPending float64 `bson:"cashTotalPending" json:"cashTotalPending"` + + TotalApproved int64 `bson:"totalApproved" json:"totalApproved"` + CashTotalApproved float64 `bson:"cashTotalApproved" json:"cashTotalApproved"` + + TotalRejected int64 `bson:"totalRejected" json:"totalRejected"` + CashTotalRejected float64 `bson:"cashTotalRejected" json:"cashTotalRejected"` +} diff --git a/subject/campaign.go b/subject/campaign.go index 8c7ddac..a986f69 100644 --- a/subject/campaign.go +++ b/subject/campaign.go @@ -10,6 +10,8 @@ func getCampaignValue(val string) string { // Campaign ... var Campaign = struct { GetListCampaignTransactionAdminInfoByIDs string + GetCampaignSellerStatisticBySellerIDs string }{ GetListCampaignTransactionAdminInfoByIDs: getCampaignValue("get_list_campaign_transaction_admin_info_by_ids"), + GetCampaignSellerStatisticBySellerIDs: getCampaignValue("get_campaign_seller_statistic_by_seller_ids"), }