setup-holiday-warehouse-admin #105
			
				
			
		
		
		
	| 
						 | 
					@ -0,0 +1,36 @@
 | 
				
			||||||
 | 
					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"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Affiliate ...
 | 
				
			||||||
 | 
					type Affiliate struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetAffiliate ...
 | 
				
			||||||
 | 
					func GetAffiliate() Affiliate {
 | 
				
			||||||
 | 
						return Affiliate{}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetTransactions ...
 | 
				
			||||||
 | 
					func (w Affiliate) GetTransactions(p model.GetTransactionsRequest) (*model.GetTransactionsResponse, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Affiliate.GetTransactions, toBytes(p))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.GetTransactionsResponse `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,16 @@
 | 
				
			||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetTransactionsRequest ...
 | 
				
			||||||
 | 
					type GetTransactionsRequest struct {
 | 
				
			||||||
 | 
						Page     int64     `json:"page"`
 | 
				
			||||||
 | 
						Limit    int64     `json:"limit"`
 | 
				
			||||||
 | 
						Keyword  string    `json:"keyword"`
 | 
				
			||||||
 | 
						Status   string    `json:"status"`
 | 
				
			||||||
 | 
						Source   string    `json:"source"`
 | 
				
			||||||
 | 
						Campaign string    `json:"campaign"`
 | 
				
			||||||
 | 
						Seller   string    `json:"seller"`
 | 
				
			||||||
 | 
						FromAt   time.Time `json:"fromAt"`
 | 
				
			||||||
 | 
						ToAt     time.Time `json:"toAt"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetTransactionsResponse ...
 | 
				
			||||||
 | 
					type GetTransactionsResponse struct {
 | 
				
			||||||
 | 
						Total int64             `json:"total"`
 | 
				
			||||||
 | 
						Limit int64             `json:"limit"`
 | 
				
			||||||
 | 
						List  []TransactionInfo `json:"list"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TransactionInfo ...
 | 
				
			||||||
 | 
					type TransactionInfo struct {
 | 
				
			||||||
 | 
						ID                       string                     `json:"_id"`
 | 
				
			||||||
 | 
						Code                     string                     `json:"code"`
 | 
				
			||||||
 | 
						Campaign                 ResponseCampaignShort      `json:"campaign"`
 | 
				
			||||||
 | 
						Seller                   ResponseSellerInfo         `json:"seller"`
 | 
				
			||||||
 | 
						Source                   string                     `json:"source"`
 | 
				
			||||||
 | 
						Commission               ResponseCampaignCommission `json:"commission"`
 | 
				
			||||||
 | 
						EstimateSellerCommission float64                    `json:"estimateSellerCommission"`
 | 
				
			||||||
 | 
						TransactionTime          string                     `json:"transactionTime"`
 | 
				
			||||||
 | 
						Status                   string                     `json:"status"`
 | 
				
			||||||
 | 
						RejectedReason           string                     `json:"rejectedReason"`
 | 
				
			||||||
 | 
						EstimateCashbackAt       string                     `json:"estimateCashbackAt"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ResponseCampaignCommission ...
 | 
				
			||||||
 | 
					type ResponseCampaignCommission struct {
 | 
				
			||||||
 | 
						Real          float64 `json:"real"`
 | 
				
			||||||
 | 
						SellerPercent float64 `json:"sellerPercent"`
 | 
				
			||||||
 | 
						Selly         float64 `json:"selly"`
 | 
				
			||||||
 | 
						Seller        float64 `json:"seller"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ResponseCampaignShort ...
 | 
				
			||||||
 | 
					type ResponseCampaignShort struct {
 | 
				
			||||||
 | 
						ID   string     `json:"_id"`
 | 
				
			||||||
 | 
						Name string     `json:"name"`
 | 
				
			||||||
 | 
						Logo *FilePhoto `json:"logo"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					package subject
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func getAffiliateValue(val string) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s.%s", prefixes.Affiliate, val)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var Affiliate = struct {
 | 
				
			||||||
 | 
						GetTransactions string
 | 
				
			||||||
 | 
					}{
 | 
				
			||||||
 | 
						GetTransactions: getAffiliateValue("get_transactions"),
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@ var prefixes = struct {
 | 
				
			||||||
	Staff         string
 | 
						Staff         string
 | 
				
			||||||
	Segment       string
 | 
						Segment       string
 | 
				
			||||||
	Campaign      string
 | 
						Campaign      string
 | 
				
			||||||
 | 
						Affiliate     string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	Communication: "communication",
 | 
						Communication: "communication",
 | 
				
			||||||
	Order:         "order",
 | 
						Order:         "order",
 | 
				
			||||||
| 
						 | 
					@ -30,4 +31,5 @@ var prefixes = struct {
 | 
				
			||||||
	Staff:         "staff",
 | 
						Staff:         "staff",
 | 
				
			||||||
	Segment:       "segment",
 | 
						Segment:       "segment",
 | 
				
			||||||
	Campaign:      "campaign",
 | 
						Campaign:      "campaign",
 | 
				
			||||||
 | 
						Affiliate:     "affiliate",
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue