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 ...
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",
}

View File

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

View File

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

View File

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

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

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