Merge branch 'develop' of git.selly.red:Selly-Modules/natsio into develop
This commit is contained in:
commit
3307ae3abd
|
@ -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
|
||||
}
|
|
@ -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"`
|
||||
}
|
|
@ -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"`
|
||||
}
|
|
@ -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"),
|
||||
}
|
|
@ -19,6 +19,7 @@ var prefixes = struct {
|
|||
Segment string
|
||||
SupplierUser string
|
||||
SupplierRole string
|
||||
Campaign string
|
||||
}{
|
||||
Communication: "communication",
|
||||
Order: "order",
|
||||
|
@ -38,4 +39,5 @@ var prefixes = struct {
|
|||
SocialPost: "social_post",
|
||||
Staff: "staff",
|
||||
Segment: "segment",
|
||||
Campaign: "campaign",
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue