Compare commits

..

11 Commits

Author SHA1 Message Date
Minh Nguyen aaf8de9830 Merge pull request 'saving campaign' (#153) from feature/saving-campaign-bk into master
Reviewed-on: #153
2023-03-24 07:25:45 +00:00
Nguyen Minh 9c2f55e434 fix conflict 2023-03-24 14:19:33 +07:00
Nguyen Minh 8ed19af4ea change struct socket reward payload 2023-03-23 14:31:06 +07:00
Nguyen Minh 985a86dbd7 model 2023-03-23 10:46:10 +07:00
Nguyen Minh afd6b215d6 reqrep socket 2023-03-23 10:34:58 +07:00
Nguyen Minh 71d674b74c update 2023-03-14 11:47:16 +07:00
Nguyen Minh 41b79b4ae8 jet stream generate voucher promotion 2023-03-14 11:34:38 +07:00
Nguyen Minh ffe9418671 rerun 2023-03-02 14:15:15 +07:00
Nguyen Minh 7b01640583 update js model 2023-03-02 11:44:13 +07:00
tuannt20 2f64f1fa37 update 2023-02-28 18:04:14 +07:00
tuannt20 a1d6840fd9 add field get list seller by ids 2023-02-28 17:14:49 +07:00
8 changed files with 125 additions and 22 deletions

21
client/socket.go Normal file
View File

@ -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
}

View File

@ -2,13 +2,17 @@ package jsconsumer
// Selly ... // Selly ...
var Selly = struct { var Selly = struct {
PushNotification string PushNotification string
UpdateSellerAffiliateStatistic string UpdateSellerAffiliateStatistic string
CheckAnDInsertCashflowBySeller string CheckAnDInsertCashflowBySeller string
SubscriberTopic string SubscriberTopic string
UpdateSellerSavingCampaignStatistic string
GenerateVoucherPromotion string
}{ }{
PushNotification: "PULL_PUSH_NOTIFICATION", PushNotification: "PULL_PUSH_NOTIFICATION",
UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC", UpdateSellerAffiliateStatistic: "PULL_UPDATE_SELLER_AFFILIATE_STATISTIC",
CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER", CheckAnDInsertCashflowBySeller: "PULL_CHECK_AND_INSERT_CASHFLOW_BY_SELLER",
SubscriberTopic: "PULL_SUBSCRIBER_TOPIC", SubscriberTopic: "PULL_SUBSCRIBER_TOPIC",
UpdateSellerSavingCampaignStatistic: "PULL_UPDATE_SELLER_SAVING_CAMPAIGN_STATISTIC",
GenerateVoucherPromotion: "PULL_GENERATE_VOUCHER_PROMOTION",
} }

View File

@ -1,5 +1,7 @@
package jsmodel package jsmodel
import "go.mongodb.org/mongo-driver/bson/primitive"
// PushNotification ... // PushNotification ...
type PushNotification struct { type PushNotification struct {
User string `json:"user"` User string `json:"user"`
@ -12,9 +14,11 @@ type PushNotification struct {
// NotificationOptions ... // NotificationOptions ...
type NotificationOptions struct { type NotificationOptions struct {
Title string `json:"title"` Title string `json:"title"`
Content string `json:"content"` Content string `json:"content"`
CampaignID string `json:"campaignId,omitempty"` CampaignID string `json:"campaignId,omitempty"`
SellerSavingCampaignID string `json:"sellerSavingCampaignId,omitempty"`
SellerSavingCampaignStatus string `json:"sellerSavingCampaignStatus,omitempty"`
} }
// PayloadUpdateSellerAffiliateStatistic ... // PayloadUpdateSellerAffiliateStatistic ...
@ -62,6 +66,39 @@ type CashFlowOptions struct {
// Campaign // Campaign
CampaignID string `json:"campaignId,omitempty"` CampaignID string `json:"campaignId,omitempty"`
CampaignName string `json:"campaignName,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 ... // SubscriberNotificationTopic ...

View File

@ -11,13 +11,17 @@ func getSellyValue(val string) string {
// Selly ... // Selly ...
var Selly = struct { var Selly = struct {
PushNotification string PushNotification string
UpdateSellerAffiliateStatistic string UpdateSellerAffiliateStatistic string
CheckAnDInsertCashflowBySeller string CheckAnDInsertCashflowBySeller string
SubscriberTopic string SubscriberTopic string
UpdateSellerSavingCampaignStatistic string
GenerateVoucherPromotion string
}{ }{
PushNotification: getSellyValue("push_notifications"), PushNotification: getSellyValue("push_notifications"),
UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"), UpdateSellerAffiliateStatistic: getSellyValue("update_seller_affiliate_statistic"),
CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"), CheckAnDInsertCashflowBySeller: getSellyValue("check_and_insert_cashflow_statistic"),
SubscriberTopic: getSellyValue("subscriber_topic"), SubscriberTopic: getSellyValue("subscriber_topic"),
UpdateSellerSavingCampaignStatistic: getSellyValue("update_seller_saving_campaign_statistic"),
GenerateVoucherPromotion: getSellyValue("generate_voucher_promotion"),
} }

View File

@ -4,9 +4,11 @@ import "time"
// ResponseSellerInfo ... // ResponseSellerInfo ...
type ResponseSellerInfo struct { type ResponseSellerInfo struct {
ID string `json:"_id"` ID string `json:"_id"`
Name string `json:"name"` Name string `json:"name"`
Code string `json:"code"` Code string `json:"code"`
IsAccountPro bool `json:"isAccountPro"`
CashRemaining float64 `json:"cashRemaining"`
} }
// ResponseListSellerInfo ... // ResponseListSellerInfo ...

19
model/socket.go Normal file
View File

@ -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"`
}

View File

@ -18,6 +18,7 @@ var prefixes = struct {
Queue string Queue string
Campaign string Campaign string
Affiliate string Affiliate string
Socket string
}{ }{
Communication: "communication", Communication: "communication",
Order: "order", Order: "order",
@ -36,4 +37,5 @@ var prefixes = struct {
Queue: "queue", Queue: "queue",
Campaign: "campaign", Campaign: "campaign",
Affiliate: "affiliate", Affiliate: "affiliate",
Socket: "socket",
} }

14
subject/socket.go Normal file
View File

@ -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"),
}