Compare commits
	
		
			3 Commits
		
	
	
		
			0400a70a56
			...
			bc370eb7b9
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						bc370eb7b9 | |
| 
							
							
								 | 
						4d7dde29ba | |
| 
							
							
								
									
								
								 | 
						9c48edf1e3 | 
| 
						 | 
					@ -15,3 +15,4 @@
 | 
				
			||||||
# vendor/
 | 
					# vendor/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.idea
 | 
					.idea
 | 
				
			||||||
 | 
					*.DS_Store
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,15 +9,12 @@ import (
 | 
				
			||||||
	"git.selly.red/Selly-Modules/natsio/subject"
 | 
						"git.selly.red/Selly-Modules/natsio/subject"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Seller ...
 | 
					 | 
				
			||||||
type Seller struct{}
 | 
					type Seller struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetSeller ...
 | 
					 | 
				
			||||||
func GetSeller() Seller {
 | 
					func GetSeller() Seller {
 | 
				
			||||||
	return Seller{}
 | 
						return Seller{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetSellerInfoByID ...
 | 
					 | 
				
			||||||
func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.ResponseSellerInfo, error) {
 | 
					func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.ResponseSellerInfo, error) {
 | 
				
			||||||
	msg, err := natsio.GetServer().Request(subject.Seller.GetSellerInfoByID, toBytes(p))
 | 
						msg, err := natsio.GetServer().Request(subject.Seller.GetSellerInfoByID, toBytes(p))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -40,7 +37,6 @@ func (s Seller) GetSellerInfoByID(p model.GetSellerByIDRequest) (*model.Response
 | 
				
			||||||
	return r.Data, nil
 | 
						return r.Data, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetListSellerInfoByIDs ...
 | 
					 | 
				
			||||||
func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*model.ResponseListSellerInfo, error) {
 | 
					func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*model.ResponseListSellerInfo, error) {
 | 
				
			||||||
	msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoByIDs, toBytes(p))
 | 
						msg, err := natsio.GetServer().Request(subject.Seller.GetListSellerInfoByIDs, toBytes(p))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,7 +60,6 @@ func (s Seller) GetListSellerInfoByIDs(p model.GetListSellerByIDsRequest) (*mode
 | 
				
			||||||
	return r.Data, nil
 | 
						return r.Data, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetListSellerInfoSupportChatByIDs ...
 | 
					 | 
				
			||||||
func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportChatByIDsRequest) (*model.ResponseListSellerInfoSupportChat, error) {
 | 
					func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportChatByIDsRequest) (*model.ResponseListSellerInfoSupportChat, error) {
 | 
				
			||||||
	msg, err := natsio.GetServer().Request(subject.SupportChat.GetListSellerInfoSupportChatByIDs, toBytes(p))
 | 
						msg, err := natsio.GetServer().Request(subject.SupportChat.GetListSellerInfoSupportChatByIDs, toBytes(p))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -85,3 +80,69 @@ func (s Seller) GetListSellerInfoSupportChatByIDs(p model.GetListSellerSupportCh
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return r.Data, nil
 | 
						return r.Data, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s Seller) CheckAndInsertCashflows(p model.CheckAndInsertCashflowsRequest) (*model.ResponseCheckAndInsertCashflows, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Seller.CheckAndInsertCashflows, toBytes(p))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.ResponseCheckAndInsertCashflows `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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s Seller) UpdateSellerAffiliateStatistic(p model.UpdateSellerAffiliateStatisticRequest) (*model.ResponseUpdateSellerAffiliateStatistic, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Seller.UpdateSellerAffiliateStatistic, toBytes(p))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.ResponseUpdateSellerAffiliateStatistic `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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (s Seller) UpdateSellerSavingCampaignStatistic(p model.UpdateSellerSavingCampaignStatisticRequest) (*model.ResponseUpdateSellerSavingCampaignStatistic, error) {
 | 
				
			||||||
 | 
						msg, err := natsio.GetServer().Request(subject.Seller.UpdateSellerSavingCampaignStatistic, toBytes(p))
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var r struct {
 | 
				
			||||||
 | 
							Data  *model.ResponseUpdateSellerSavingCampaignStatistic `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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,17 +2,73 @@ package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "go.mongodb.org/mongo-driver/bson/primitive"
 | 
					import "go.mongodb.org/mongo-driver/bson/primitive"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetSellerByIDRequest ...
 | 
					 | 
				
			||||||
type GetSellerByIDRequest struct {
 | 
					type GetSellerByIDRequest struct {
 | 
				
			||||||
	SellerID primitive.ObjectID `json:"sellerId"`
 | 
						SellerID primitive.ObjectID `json:"sellerId"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetListSellerByIDsRequest ...
 | 
					 | 
				
			||||||
type GetListSellerByIDsRequest struct {
 | 
					type GetListSellerByIDsRequest struct {
 | 
				
			||||||
	SellerIDs []primitive.ObjectID `json:"sellerIds"`
 | 
						SellerIDs []primitive.ObjectID `json:"sellerIds"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetListSellerSupportChatByIDsRequest ...
 | 
					 | 
				
			||||||
type GetListSellerSupportChatByIDsRequest struct {
 | 
					type GetListSellerSupportChatByIDsRequest struct {
 | 
				
			||||||
	SellerIDs []primitive.ObjectID `json:"sellerIds"`
 | 
						SellerIDs []primitive.ObjectID `json:"sellerIds"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CheckAndInsertCashflowsRequest struct {
 | 
				
			||||||
 | 
						SellerID string           `json:"sellerId"`
 | 
				
			||||||
 | 
						List     []CashflowSeller `json:"list"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CashflowSeller struct {
 | 
				
			||||||
 | 
						Value      float64          `json:"value"`
 | 
				
			||||||
 | 
						Action     string           `json:"action"`
 | 
				
			||||||
 | 
						Category   string           `json:"category"`
 | 
				
			||||||
 | 
						TargetID   string           `json:"targetId"`
 | 
				
			||||||
 | 
						TargetType string           `json:"targetType"`
 | 
				
			||||||
 | 
						Options    *CashFlowOptions `json:"options"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CashFlowOptions struct {
 | 
				
			||||||
 | 
						AffiliateTransactionCode string `json:"affiliateTransactionCode,omitempty"`
 | 
				
			||||||
 | 
						AffiliateCampaignID      string `json:"affiliateCampaignId,omitempty"`
 | 
				
			||||||
 | 
						AffiliateCampaignName    string `json:"affiliateCampaignName,omitempty"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Campaign
 | 
				
			||||||
 | 
						CampaignID   string `json:"campaignId,omitempty"`
 | 
				
			||||||
 | 
						CampaignName string `json:"campaignName,omitempty"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// SavingCampaign
 | 
				
			||||||
 | 
						SavingCampaignID   string `json:"savingCampaignId,omitempty"`
 | 
				
			||||||
 | 
						SavingCampaignName string `json:"savingCampaignName,omitempty"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SavingCampaignItemID   string `json:"savingCampaignItemId,omitempty"`
 | 
				
			||||||
 | 
						SavingCampaignItemName string `json:"savingCampaignItemName,omitempty"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type UpdateSellerAffiliateStatisticRequest struct {
 | 
				
			||||||
 | 
						SellerID  string                   `json:"sellerId"`
 | 
				
			||||||
 | 
						Statistic SellerAffiliateStatistic `json:"statistic"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SellerAffiliateStatistic struct {
 | 
				
			||||||
 | 
						TransactionTotal              int     `json:"transactionTotal"`
 | 
				
			||||||
 | 
						TransactionCashback           int     `json:"transactionCashback"`
 | 
				
			||||||
 | 
						TransactionPending            int     `json:"transactionPending"`
 | 
				
			||||||
 | 
						TransactionApproved           int     `json:"transactionApproved"`
 | 
				
			||||||
 | 
						TransactionRejected           int     `json:"transactionRejected"`
 | 
				
			||||||
 | 
						CommissionTransactionTotal    float64 `json:"commissionTransactionTotal"`
 | 
				
			||||||
 | 
						CommissionTransactionCashback float64 `json:"commissionTransactionCashback"`
 | 
				
			||||||
 | 
						CommissionTransactionApproved float64 `json:"commissionTransactionApproved"`
 | 
				
			||||||
 | 
						CommissionTransactionPending  float64 `json:"commissionTransactionPending"`
 | 
				
			||||||
 | 
						CommissionTransactionRejected float64 `json:"commissionTransactionRejected"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type UpdateSellerSavingCampaignStatisticRequest struct {
 | 
				
			||||||
 | 
						SellerID  string                        `json:"sellerId"`
 | 
				
			||||||
 | 
						Statistic SellerSavingCampaignStatistic `json:"statistic"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type SellerSavingCampaignStatistic struct {
 | 
				
			||||||
 | 
						SavingCampaignCashPending   float64 `json:"savingCampaignCashPending"`
 | 
				
			||||||
 | 
						SavingCampaignCashCompleted float64 `json:"savingCampaignCashCompleted"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,3 +90,18 @@ type SellerMembershipInfo struct {
 | 
				
			||||||
	Level int    `json:"level"`
 | 
						Level int    `json:"level"`
 | 
				
			||||||
	Name  string `json:"name"`
 | 
						Name  string `json:"name"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ResponseCheckAndInsertCashflows struct {
 | 
				
			||||||
 | 
						Success bool   `json:"success"`
 | 
				
			||||||
 | 
						Error   string `json:"error"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ResponseUpdateSellerAffiliateStatistic struct {
 | 
				
			||||||
 | 
						Success bool   `json:"success"`
 | 
				
			||||||
 | 
						Error   string `json:"error"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type ResponseUpdateSellerSavingCampaignStatistic struct {
 | 
				
			||||||
 | 
						Success bool   `json:"success"`
 | 
				
			||||||
 | 
						Error   string `json:"error"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,7 @@ var prefixes = struct {
 | 
				
			||||||
	Product            string
 | 
						Product            string
 | 
				
			||||||
	Queue              string
 | 
						Queue              string
 | 
				
			||||||
	Socket             string
 | 
						Socket             string
 | 
				
			||||||
 | 
						Promotion          string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	Communication:      "communication",
 | 
						Communication:      "communication",
 | 
				
			||||||
	Order:              "order",
 | 
						Order:              "order",
 | 
				
			||||||
| 
						 | 
					@ -48,4 +49,5 @@ var prefixes = struct {
 | 
				
			||||||
	Product:            "product",
 | 
						Product:            "product",
 | 
				
			||||||
	Queue:              "queue",
 | 
						Queue:              "queue",
 | 
				
			||||||
	Socket:             "socket",
 | 
						Socket:             "socket",
 | 
				
			||||||
 | 
						Promotion:          "promotion",
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					package subject
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func getPromotionValue(val string) string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%s.%s", prefixes.Promotion, val)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var Promotion = struct {
 | 
				
			||||||
 | 
						GenerateVoucherPromotion string
 | 
				
			||||||
 | 
					}{
 | 
				
			||||||
 | 
						GenerateVoucherPromotion: getPromotionValue("generate_voucher_promotion"),
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -8,11 +8,17 @@ func getSellerValue(val string) string {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Seller ...
 | 
					// Seller ...
 | 
				
			||||||
var Seller = struct {
 | 
					var Seller = struct {
 | 
				
			||||||
	GetSellerInfoByID      string
 | 
						GetSellerInfoByID                   string
 | 
				
			||||||
	GetListSellerInfoByIDs string
 | 
						GetListSellerInfoByIDs              string
 | 
				
			||||||
 | 
						CheckAndInsertCashflows             string
 | 
				
			||||||
 | 
						UpdateSellerAffiliateStatistic      string
 | 
				
			||||||
 | 
						UpdateSellerSavingCampaignStatistic string
 | 
				
			||||||
}{
 | 
					}{
 | 
				
			||||||
	GetSellerInfoByID:      getSellerValue("get_seller_info_by_id"),
 | 
						GetSellerInfoByID:                   getSellerValue("get_seller_info_by_id"),
 | 
				
			||||||
	GetListSellerInfoByIDs: getSellerValue("get_list_seller_info_by_ids"),
 | 
						GetListSellerInfoByIDs:              getSellerValue("get_list_seller_info_by_ids"),
 | 
				
			||||||
 | 
						CheckAndInsertCashflows:             getSellerValue("check_and_insert_cashflows"),
 | 
				
			||||||
 | 
						UpdateSellerAffiliateStatistic:      getSellerValue("update_seller_affiliate_statistic"),
 | 
				
			||||||
 | 
						UpdateSellerSavingCampaignStatistic: getSellerValue("update_seller_saving_campaign_statistic"),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SupportChat ...
 | 
					// SupportChat ...
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue