saving campaign #153
			
				
			
		
		
		
	|  | @ -0,0 +1,21 @@ | |||
| package client | ||||
| 
 | ||||
| import ( | ||||
| 	"git.selly.red/Selly-Modules/natsio" | ||||
| 	"git.selly.red/Selly-Modules/natsio/model" | ||||
| 	"git.selly.red/Selly-Modules/natsio/subject" | ||||
| ) | ||||
| 
 | ||||
| // Socket ...
 | ||||
| type Socket struct{} | ||||
| 
 | ||||
| // GetSocket ...
 | ||||
| func GetSocket() Socket { | ||||
| 	return Socket{} | ||||
| } | ||||
| 
 | ||||
| // EmitSocketEventDataReward ...
 | ||||
| func (s Socket) EmitSocketEventDataReward(p model.PayloadEmitSocketEvent) error { | ||||
| 	_, err := natsio.GetServer().Request(subject.Socket.EmitEventReward, toBytes(p)) | ||||
| 	return err | ||||
| } | ||||
|  | @ -2,13 +2,17 @@ package jsconsumer | |||
| 
 | ||||
| // Selly ...
 | ||||
| var Selly = struct { | ||||
| 	PushNotification               string | ||||
| 	UpdateSellerAffiliateStatistic string | ||||
| 	CheckAnDInsertCashflowBySeller string | ||||
| 	SubscriberTopic                string | ||||
| 	PushNotification                    string | ||||
| 	UpdateSellerAffiliateStatistic      string | ||||
| 	CheckAnDInsertCashflowBySeller      string | ||||
| 	SubscriberTopic                     string | ||||
| 	UpdateSellerSavingCampaignStatistic string | ||||
| 	GenerateVoucherPromotion            string | ||||
| }{ | ||||
| 	PushNotification:               "PULL_PUSH_NOTIFICATION", | ||||
| 	UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", | ||||
| 	CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", | ||||
| 	SubscriberTopic:                "PULL_SUBSCRIBER_TOPIC", | ||||
| 	PushNotification:                    "PULL_PUSH_NOTIFICATION", | ||||
| 	UpdateSellerAffiliateStatistic:      "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", | ||||
| 	CheckAnDInsertCashflowBySeller:      "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", | ||||
| 	SubscriberTopic:                     "PULL_SUBSCRIBER_TOPIC", | ||||
| 	UpdateSellerSavingCampaignStatistic: "PULL_UPDATE_SELLER_SAVING_CAMPAIGN_STATISTIC", | ||||
| 	GenerateVoucherPromotion:            "PULL_GENERATE_VOUCHER_PROMOTION", | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,7 @@ | |||
| package jsmodel | ||||
| 
 | ||||
| import "go.mongodb.org/mongo-driver/bson/primitive" | ||||
| 
 | ||||
| // PushNotification ...
 | ||||
| type PushNotification struct { | ||||
| 	User        string              `json:"user"` | ||||
|  | @ -12,9 +14,11 @@ type PushNotification struct { | |||
| 
 | ||||
| // NotificationOptions ...
 | ||||
| type NotificationOptions struct { | ||||
| 	Title      string `json:"title"` | ||||
| 	Content    string `json:"content"` | ||||
| 	CampaignID string `json:"campaignId,omitempty"` | ||||
| 	Title                      string `json:"title"` | ||||
| 	Content                    string `json:"content"` | ||||
| 	CampaignID                 string `json:"campaignId,omitempty"` | ||||
| 	SellerSavingCampaignID     string `json:"sellerSavingCampaignId,omitempty"` | ||||
| 	SellerSavingCampaignStatus string `json:"sellerSavingCampaignStatus,omitempty"` | ||||
| } | ||||
| 
 | ||||
| // PayloadUpdateSellerAffiliateStatistic ...
 | ||||
|  | @ -62,6 +66,39 @@ type CashFlowOptions struct { | |||
| 	// 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"` | ||||
| } | ||||
| 
 | ||||
| // PayloadUpdateSellerSavingCampaignStatistic ...
 | ||||
| type PayloadUpdateSellerSavingCampaignStatistic struct { | ||||
| 	SellerID  string                        `json:"sellerId"` | ||||
| 	Statistic SellerSavingCampaignStatistic `json:"statistic"` | ||||
| } | ||||
| 
 | ||||
| // SellerSavingCampaignStatistic ...
 | ||||
| type SellerSavingCampaignStatistic struct { | ||||
| 	SavingCampaignCashPending   float64 `json:"savingCampaignCashPending"` | ||||
| 	SavingCampaignCashCompleted float64 `json:"savingCampaignCashCompleted"` | ||||
| } | ||||
| 
 | ||||
| // GenerateVoucherPromotion ...
 | ||||
| type GenerateVoucherPromotion struct { | ||||
| 	Cash       float64                         `json:"cash"` | ||||
| 	TargetID   primitive.ObjectID              `json:"targetId"` | ||||
| 	TargetType string                          `json:"targetType"` | ||||
| 	Options    GenerateVoucherPromotionOptions `json:"options"` | ||||
| 	Seller     primitive.ObjectID              `json:"seller"` | ||||
| } | ||||
| 
 | ||||
| // GenerateVoucherPromotionOptions ...
 | ||||
| type GenerateVoucherPromotionOptions struct { | ||||
| 	Title string `json:"title"` | ||||
| } | ||||
| 
 | ||||
| // SubscriberNotificationTopic ...
 | ||||
|  |  | |||
|  | @ -11,13 +11,17 @@ func getSellyValue(val string) string { | |||
| 
 | ||||
| // Selly ...
 | ||||
| var Selly = struct { | ||||
| 	PushNotification               string | ||||
| 	UpdateSellerAffiliateStatistic string | ||||
| 	CheckAnDInsertCashflowBySeller string | ||||
| 	SubscriberTopic                string | ||||
| 	PushNotification                    string | ||||
| 	UpdateSellerAffiliateStatistic      string | ||||
| 	CheckAnDInsertCashflowBySeller      string | ||||
| 	SubscriberTopic                     string | ||||
| 	UpdateSellerSavingCampaignStatistic string | ||||
| 	GenerateVoucherPromotion            string | ||||
| }{ | ||||
| 	PushNotification:               getSellyValue("push_notifications"), | ||||
| 	UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), | ||||
| 	CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"), | ||||
| 	SubscriberTopic:                getSellyValue("subscriber_topic"), | ||||
| 	PushNotification:                    getSellyValue("push_notifications"), | ||||
| 	UpdateSellerAffiliateStatistic:      getSellyValue("update_seller_affiliate_statistic"), | ||||
| 	CheckAnDInsertCashflowBySeller:      getSellyValue("check_and_insert_cashflow_statistic"), | ||||
| 	SubscriberTopic:                     getSellyValue("subscriber_topic"), | ||||
| 	UpdateSellerSavingCampaignStatistic: getSellyValue("update_seller_saving_campaign_statistic"), | ||||
| 	GenerateVoucherPromotion:            getSellyValue("generate_voucher_promotion"), | ||||
| } | ||||
|  |  | |||
|  | @ -4,9 +4,11 @@ import "time" | |||
| 
 | ||||
| // ResponseSellerInfo ...
 | ||||
| type ResponseSellerInfo struct { | ||||
| 	ID   string `json:"_id"` | ||||
| 	Name string `json:"name"` | ||||
| 	Code string `json:"code"` | ||||
| 	ID            string  `json:"_id"` | ||||
| 	Name          string  `json:"name"` | ||||
| 	Code          string  `json:"code"` | ||||
| 	IsAccountPro  bool    `json:"isAccountPro"` | ||||
| 	CashRemaining float64 `json:"cashRemaining"` | ||||
| } | ||||
| 
 | ||||
| // ResponseListSellerInfo ...
 | ||||
|  |  | |||
|  | @ -0,0 +1,19 @@ | |||
| package model | ||||
| 
 | ||||
| // PayloadEmitSocketEvent ...
 | ||||
| type PayloadEmitSocketEvent struct { | ||||
| 	User        string `json:"user"` | ||||
| 	Message     string `json:"message"` | ||||
| 	Data        string `json:"data"` | ||||
| 	IsNotRemove bool   `json:"isNotRemove"` | ||||
| } | ||||
| 
 | ||||
| // PayloadEventSocketReward ...
 | ||||
| type PayloadEventSocketReward struct { | ||||
| 	Type    string      `json:"type"` | ||||
| 	Title   string      `json:"title"` | ||||
| 	Cash    float64     `json:"cash"` | ||||
| 	Message string      `json:"message"` | ||||
| 	Photo   interface{} `json:"photo"` | ||||
| 	Action  *ActionType `json:"action"` | ||||
| } | ||||
|  | @ -18,6 +18,7 @@ var prefixes = struct { | |||
| 	Queue         string | ||||
| 	Campaign      string | ||||
| 	Affiliate     string | ||||
| 	Socket        string | ||||
| }{ | ||||
| 	Communication: "communication", | ||||
| 	Order:         "order", | ||||
|  | @ -36,4 +37,5 @@ var prefixes = struct { | |||
| 	Queue:         "queue", | ||||
| 	Campaign:      "campaign", | ||||
| 	Affiliate:     "affiliate", | ||||
| 	Socket:        "socket", | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,14 @@ | |||
| package subject | ||||
| 
 | ||||
| import "fmt" | ||||
| 
 | ||||
| func getSocketValue(val string) string { | ||||
| 	return fmt.Sprintf("%s.%s", prefixes.Socket, val) | ||||
| } | ||||
| 
 | ||||
| // Socket ...
 | ||||
| var Socket = struct { | ||||
| 	EmitEventReward string | ||||
| }{ | ||||
| 	EmitEventReward: getSocketValue("emit_event_reward"), | ||||
| } | ||||
		Loading…
	
		Reference in New Issue