feature/export-data-campaign-transaction #80

Merged
minhnguyen merged 4 commits from feature/export-data-campaign-transaction into feature/campaign 2022-11-24 02:40:27 +00:00
6 changed files with 102 additions and 1 deletions

31
client/campaign.go Normal file
View File

@ -0,0 +1,31 @@
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"
)
// Campaign ...
type Campaign struct{}
// GetCampaignTransaction ...
func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) (*model.ResponseCampaignTransactionAll, error) {
msg, err := natsio.GetServer().Request(subject.Campaign.GetListCampaignTransactionAdminInfoByIDs, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data *model.ResponseCampaignTransactionAll `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
}

14
model/campaign_request.go Normal file
View File

@ -0,0 +1,14 @@
package model
import "time"
// GetCampaignTransactionsRequest ...
type GetCampaignTransactionsRequest struct {
Campaign string `json:"campaign"`
Keyword string `json:"keyword"`
Status string `json:"status"`
FromAt time.Time `json:"fromAt"`
ToAt time.Time `json:"toAt"`
Page int64 `json:"page"`
Limit int64 `json:"limit"`
}

View File

@ -0,0 +1,39 @@
package model
// ResponseCampaignTransactionAll ...
type ResponseCampaignTransactionAll struct {
List []ResponseNatsCampaignTransaction `json:"list"`
Total int64 `json:"total"`
Limit int64 `json:"limit"`
}
// ResponseNatsCampaignTransaction ...
type ResponseNatsCampaignTransaction struct {
ID string `json:"_id"`
Cash float64 `json:"cash"`
Campaign ResponseCampaignShortInfo `json:"campaign"`
Seller ResponseSellerInfo `json:"seller"`
Type string `json:"type"`
RejectedReason string `json:"rejectedReason"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Item *ResponseCampaignItemShortInfo `json:"item"`
ApprovedBy *ResponseStaffInfo `json:"approvedBy,omitempty"`
RejectedBy *ResponseStaffInfo `json:"rejectedBy,omitempty"`
ApprovedAt string `json:"approvedAt,omitempty"`
RejectedAt string `json:"rejectedAt,omitempty"`
}
// ResponseCampaignShortInfo ...
type ResponseCampaignShortInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
Status string `json:"status"`
}
// ResponseCampaignItemShortInfo ...
type ResponseCampaignItemShortInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
Status string `json:"status"`
}

View File

@ -44,7 +44,7 @@ type SocialPostSellerInfo struct {
ID primitive.ObjectID `json:"_id"`
Name string `json:"name"`
Membership SellerMembershipInfo `json:"membership"`
Logo *FilePhoto `json:"logo"`
Logo *FilePhoto `json:"avatar"`
IsMine bool `json:"isMine"`
}

15
subject/campaign.go Normal file
View File

@ -0,0 +1,15 @@
package subject
import "fmt"
// getCampaignValue ...
func getCampaignValue(val string) string {
return fmt.Sprintf("%s.%s", prefixes.Campaign, val)
}
// Campaign ...
var Campaign = struct {
GetListCampaignTransactionAdminInfoByIDs string
}{
GetListCampaignTransactionAdminInfoByIDs: getCampaignValue("get_list_campaign_transaction_admin_info_by_ids"),
}

View File

@ -13,6 +13,7 @@ var prefixes = struct {
SupplierRole string
SocialPost string
Staff string
Campaign string
}{
Communication: "communication",
Order: "order",
@ -26,4 +27,5 @@ var prefixes = struct {
SupplierRole: "supplier_role",
SocialPost: "social_post",
Staff: "staff",
Campaign: "campaign",
}