From a1d6840fd92d73f9d4619a39a5a530f17a4b7746 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Tue, 28 Feb 2023 17:14:49 +0700 Subject: [PATCH 1/9] add field get list seller by ids --- js/model/selly.go | 7 +++++++ model/seller_response.go | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/model/selly.go b/js/model/selly.go index 68d3342..66e5673 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -62,4 +62,11 @@ 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"` } diff --git a/model/seller_response.go b/model/seller_response.go index 01c80e5..2892e08 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -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"` + PlanPackage *SellerPlanPackageInfo `json:"planPackage,omitempty"` + CashRemaining float64 `json:"cashRemaining"` } // ResponseListSellerInfo ... From 2f64f1fa3744c64d6821c575d18da2b1c91b0045 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Tue, 28 Feb 2023 18:04:14 +0700 Subject: [PATCH 2/9] update --- model/seller_response.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/model/seller_response.go b/model/seller_response.go index 2892e08..e380435 100644 --- a/model/seller_response.go +++ b/model/seller_response.go @@ -4,11 +4,11 @@ import "time" // ResponseSellerInfo ... type ResponseSellerInfo struct { - ID string `json:"_id"` - Name string `json:"name"` - Code string `json:"code"` - PlanPackage *SellerPlanPackageInfo `json:"planPackage,omitempty"` - CashRemaining float64 `json:"cashRemaining"` + ID string `json:"_id"` + Name string `json:"name"` + Code string `json:"code"` + IsAccountPro bool `json:"isAccountPro"` + CashRemaining float64 `json:"cashRemaining"` } // ResponseListSellerInfo ... From 7b01640583ce5691ea52ac212fc2b56cb3b39b15 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 2 Mar 2023 11:44:13 +0700 Subject: [PATCH 3/9] update js model --- js/consumer/selly.go | 14 ++++++++------ js/model/selly.go | 12 ++++++++++++ js/subject/selly.go | 14 ++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/js/consumer/selly.go b/js/consumer/selly.go index 975cb5b..e72e7ce 100644 --- a/js/consumer/selly.go +++ b/js/consumer/selly.go @@ -2,11 +2,13 @@ package jsconsumer // Selly ... var Selly = struct { - PushNotification string - UpdateSellerAffiliateStatistic string - CheckAnDInsertCashflowBySeller string + PushNotification string + UpdateSellerAffiliateStatistic string + CheckAnDInsertCashflowBySeller string + UpdateSellerSavingCampaignStatistic string }{ - PushNotification: "PULL_PUSH_NOTIFICATION", - UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", - CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", + PushNotification: "PULL_PUSH_NOTIFICATION", + UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", + CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", + UpdateSellerSavingCampaignStatistic: "PULL_UPDATE_SELLER_SAVING_CAMPAIGN_STATISTIC", } diff --git a/js/model/selly.go b/js/model/selly.go index 66e5673..3e7f949 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -70,3 +70,15 @@ type CashFlowOptions struct { 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"` +} diff --git a/js/subject/selly.go b/js/subject/selly.go index 2f665bb..91d904e 100644 --- a/js/subject/selly.go +++ b/js/subject/selly.go @@ -11,11 +11,13 @@ func getSellyValue(val string) string { // Selly ... var Selly = struct { - PushNotification string - UpdateSellerAffiliateStatistic string - CheckAnDInsertCashflowBySeller string + PushNotification string + UpdateSellerAffiliateStatistic string + CheckAnDInsertCashflowBySeller string + UpdateSellerSavingCampaignStatistic string }{ - PushNotification: getSellyValue("push_notifications"), - UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), - CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"), + PushNotification: getSellyValue("push_notifications"), + UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), + CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"), + UpdateSellerSavingCampaignStatistic: getSellyValue("update_seller_saving_campaign_statistic"), } From ffe9418671276222ab23a67797bb9c1cf7ead0ef Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 2 Mar 2023 14:15:15 +0700 Subject: [PATCH 4/9] rerun --- js/model/selly.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/model/selly.go b/js/model/selly.go index 3e7f949..b84662a 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -12,9 +12,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 ... From 41b79b4ae8e258e127ebe33e0ce53887707b4a91 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Tue, 14 Mar 2023 11:34:38 +0700 Subject: [PATCH 5/9] jet stream generate voucher promotion --- js/consumer/selly.go | 2 ++ js/model/selly.go | 15 +++++++++++++++ js/subject/selly.go | 2 ++ 3 files changed, 19 insertions(+) diff --git a/js/consumer/selly.go b/js/consumer/selly.go index e72e7ce..be303ea 100644 --- a/js/consumer/selly.go +++ b/js/consumer/selly.go @@ -6,9 +6,11 @@ var Selly = struct { UpdateSellerAffiliateStatistic string CheckAnDInsertCashflowBySeller string UpdateSellerSavingCampaignStatistic string + GenerateVoucherPromotion string }{ PushNotification: "PULL_PUSH_NOTIFICATION", UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", UpdateSellerSavingCampaignStatistic: "PULL_UPDATE_SELLER_SAVING_CAMPAIGN_STATISTIC", + GenerateVoucherPromotion: "PULL_GENERATE_VOUCHER_PROMOTION", } diff --git a/js/model/selly.go b/js/model/selly.go index b84662a..8f52a8b 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -1,5 +1,7 @@ package jsmodel +import "go.mongodb.org/mongo-driver/bson/primitive" + // PushNotification ... type PushNotification struct { User string `json:"user"` @@ -84,3 +86,16 @@ 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"` +} + +// GenerateVoucherPromotionOptions ... +type GenerateVoucherPromotionOptions struct { + Title string `json:"title"` +} diff --git a/js/subject/selly.go b/js/subject/selly.go index 91d904e..a32f7b8 100644 --- a/js/subject/selly.go +++ b/js/subject/selly.go @@ -15,9 +15,11 @@ var Selly = struct { UpdateSellerAffiliateStatistic string CheckAnDInsertCashflowBySeller string UpdateSellerSavingCampaignStatistic string + GenerateVoucherPromotion string }{ PushNotification: getSellyValue("push_notifications"), UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"), UpdateSellerSavingCampaignStatistic: getSellyValue("update_seller_saving_campaign_statistic"), + GenerateVoucherPromotion: getSellyValue("generate_voucher_promotion"), } From 71d674b74c95683e9e611e8ab554ed82891d26d7 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Tue, 14 Mar 2023 11:47:16 +0700 Subject: [PATCH 6/9] update --- js/model/selly.go | 1 + 1 file changed, 1 insertion(+) diff --git a/js/model/selly.go b/js/model/selly.go index 8f52a8b..3771889 100644 --- a/js/model/selly.go +++ b/js/model/selly.go @@ -93,6 +93,7 @@ type GenerateVoucherPromotion struct { TargetID primitive.ObjectID `json:"targetId"` TargetType string `json:"targetType"` Options GenerateVoucherPromotionOptions `json:"options"` + Seller primitive.ObjectID `json:"seller"` } // GenerateVoucherPromotionOptions ... From afd6b215d6b686a39c406ceae88cf487d1eca2d6 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 23 Mar 2023 10:34:58 +0700 Subject: [PATCH 7/9] reqrep socket --- client/socket.go | 21 +++++++++++++++++++++ model/socket.go | 9 +++++++++ subject/config.go | 2 ++ subject/socket.go | 14 ++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 client/socket.go create mode 100644 model/socket.go create mode 100644 subject/socket.go diff --git a/client/socket.go b/client/socket.go new file mode 100644 index 0000000..6c0a125 --- /dev/null +++ b/client/socket.go @@ -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 +} diff --git a/model/socket.go b/model/socket.go new file mode 100644 index 0000000..6271383 --- /dev/null +++ b/model/socket.go @@ -0,0 +1,9 @@ +package model + +// PayloadEmitSocketEvent ... +type PayloadEmitSocketEvent struct { + User string `json:"user"` + Message string `json:"message"` + Data string `json:"data"` + IsNotRemove bool `json:"isNotRemove"` +} diff --git a/subject/config.go b/subject/config.go index 0ba5952..d319a6f 100644 --- a/subject/config.go +++ b/subject/config.go @@ -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", } diff --git a/subject/socket.go b/subject/socket.go new file mode 100644 index 0000000..dae77c1 --- /dev/null +++ b/subject/socket.go @@ -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"), +} From 985a86dbd7e67b3c026dd2fc22751068acd250e2 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 23 Mar 2023 10:46:10 +0700 Subject: [PATCH 8/9] model --- model/socket.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/model/socket.go b/model/socket.go index 6271383..4b9de8c 100644 --- a/model/socket.go +++ b/model/socket.go @@ -7,3 +7,13 @@ type PayloadEmitSocketEvent struct { 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 *FilePhoto `json:"photo"` + Action *ActionType `json:"action"` +} From 8ed19af4ea473ab1b08aec6922006ce283090954 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Thu, 23 Mar 2023 14:31:06 +0700 Subject: [PATCH 9/9] change struct socket reward payload --- model/socket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/socket.go b/model/socket.go index 4b9de8c..f9f6de8 100644 --- a/model/socket.go +++ b/model/socket.go @@ -14,6 +14,6 @@ type PayloadEventSocketReward struct { Title string `json:"title"` Cash float64 `json:"cash"` Message string `json:"message"` - Photo *FilePhoto `json:"photo"` + Photo interface{} `json:"photo"` Action *ActionType `json:"action"` }