From 22431a68b192d54457d46fbd2c690836a44434b6 Mon Sep 17 00:00:00 2001 From: Matrix-X Date: Sun, 1 Oct 2023 23:32:42 +0800 Subject: [PATCH 1/2] feat(wechat): official account get menu --- api/admin/wechat/officialaccount/menu.api | 3 ++- cmd/ctl/database/migrate/powerx.go | 5 +++-- .../officialaccount/menu/querymenuslogic.go | 19 +++++++++++++++---- internal/logic/gethomelogic.go | 2 +- internal/types/types.go | 3 ++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/api/admin/wechat/officialaccount/menu.api b/api/admin/wechat/officialaccount/menu.api index 426d1324..e3e07a9f 100644 --- a/api/admin/wechat/officialaccount/menu.api +++ b/api/admin/wechat/officialaccount/menu.api @@ -96,7 +96,8 @@ type ( type ( QueryMenusReply struct { - Menu *OAMenu `json:"menu,optional"` + Button interface{} `json:"button"` + MatchRule interface{} `json:"matchrule"` } ) diff --git a/cmd/ctl/database/migrate/powerx.go b/cmd/ctl/database/migrate/powerx.go index aac8c38d..f815cc8d 100644 --- a/cmd/ctl/database/migrate/powerx.go +++ b/cmd/ctl/database/migrate/powerx.go @@ -6,11 +6,11 @@ import ( "PowerX/internal/model" "PowerX/internal/model/crm/customerdomain" "PowerX/internal/model/crm/market" + "PowerX/internal/model/crm/membership" "PowerX/internal/model/crm/product" "PowerX/internal/model/crm/trade" infoorganizatoin "PowerX/internal/model/infoorganization" "PowerX/internal/model/media" - "PowerX/internal/model/membership" "PowerX/internal/model/origanzation" "PowerX/internal/model/permission" "PowerX/internal/model/scene" @@ -19,6 +19,7 @@ import ( "PowerX/internal/model/scrm/organization" "PowerX/internal/model/scrm/resource" "PowerX/internal/model/scrm/tag" + "PowerX/internal/model/wechat" "gorm.io/driver/mysql" "gorm.io/driver/postgres" "gorm.io/gorm" @@ -58,7 +59,7 @@ func (m *PowerMigrator) AutoMigrate() { // customer domain _ = m.db.AutoMigrate(&customerdomain.Lead{}, &customerdomain.Contact{}, &customerdomain.Customer{}, &membership.Membership{}) - _ = m.db.AutoMigrate(&model.WechatOACustomer{}, &model.WechatMPCustomer{}, &model.WeWorkExternalContact{}) + _ = m.db.AutoMigrate(&wechat.WechatOACustomer{}, &wechat.WechatMPCustomer{}, &wechat.WeWorkExternalContact{}) _ = m.db.AutoMigrate( &product.PivotProductToProductCategory{}, ) diff --git a/internal/logic/admin/wechat/officialaccount/menu/querymenuslogic.go b/internal/logic/admin/wechat/officialaccount/menu/querymenuslogic.go index eac016b4..87d0d64e 100644 --- a/internal/logic/admin/wechat/officialaccount/menu/querymenuslogic.go +++ b/internal/logic/admin/wechat/officialaccount/menu/querymenuslogic.go @@ -1,10 +1,11 @@ package menu import ( - "context" - "PowerX/internal/svc" "PowerX/internal/types" + "PowerX/internal/types/errorx" + "context" + "github.com/ArtisanCloud/PowerLibs/v3/object" "github.com/zeromicro/go-zero/core/logx" ) @@ -24,7 +25,17 @@ func NewQueryMenusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryM } func (l *QueryMenusLogic) QueryMenus() (resp *types.QueryMenusReply, err error) { - // todo: add your logic here and delete this line - return + res, err := l.svcCtx.PowerX.WechatOA.App.Menu.Get(l.ctx) + if err != nil { + return nil, err + } + if res.ErrCode != 0 { + return nil, errorx.WithCause(errorx.ErrNotFoundObject, res.ErrMsg) + } + + return &types.QueryMenusReply{ + Button: res.Menus.Buttons, + MatchRule: object.HashMap{}, + }, nil } diff --git a/internal/logic/gethomelogic.go b/internal/logic/gethomelogic.go index 3077e90f..12670986 100644 --- a/internal/logic/gethomelogic.go +++ b/internal/logic/gethomelogic.go @@ -27,6 +27,6 @@ func (l *GetHomeLogic) GetHome() (resp *types.GetHomeReply, err error) { return &types.GetHomeReply{ Greet: "Hello, I am PowerX!", Description: "This is awesome! you create me and make me alive", - Version: "V1.0.0", + Version: "V1.0.1", }, nil } diff --git a/internal/types/types.go b/internal/types/types.go index 86888c6f..71736bdb 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -2828,7 +2828,8 @@ type CreateMenuReply struct { } type QueryMenusReply struct { - Menu *OAMenu `json:"menu,optional"` + Button interface{} `json:"button"` + MatchRule interface{} `json:"matchrule"` } type DeleteMenuReply struct { From 87883f2d893f478bb2ac8f6ea1a5f8bda607d7c5 Mon Sep 17 00:00:00 2001 From: Matrix-X Date: Thu, 5 Oct 2023 23:01:39 +0800 Subject: [PATCH 2/2] feat(mgm): add mgm rules with migrate and seed --- api/admin/crm/market/mgm.api | 106 ++++++++++++++++++ cmd/ctl/database/migrate/powerx.go | 3 +- .../seed/datadictionary/datadictionary.go | 1 + cmd/ctl/database/seed/datadictionary/mgm.go | 66 +++++++++++ cmd/ctl/database/seed/mgm.go | 97 ++++++++++++++++ cmd/ctl/database/seed/payment.go | 2 +- cmd/ctl/database/seed/powerx.go | 4 + cmd/ctl/database/seed/pricebook.go | 2 +- cmd/ctl/database/seed/product.go | 2 +- cmd/ctl/database/seed/token.go | 8 +- internal/model/crm/customerdomain/customer.go | 1 + internal/model/crm/market/mgm.go | 64 +++++++++++ internal/model/crm/market/promotion.go | 4 +- internal/model/crm/trade/token.go | 4 +- 14 files changed, 352 insertions(+), 12 deletions(-) create mode 100644 api/admin/crm/market/mgm.api create mode 100644 cmd/ctl/database/seed/datadictionary/mgm.go create mode 100644 cmd/ctl/database/seed/mgm.go create mode 100644 internal/model/crm/market/mgm.go diff --git a/api/admin/crm/market/mgm.api b/api/admin/crm/market/mgm.api new file mode 100644 index 00000000..c8a24e82 --- /dev/null +++ b/api/admin/crm/market/mgm.api @@ -0,0 +1,106 @@ +syntax = "v1" + +info( + title: "MGM管理" + desc: "MGM管理" + author: "MichaelHu" + email: "matrix-x@artisan-cloud.com" + version: "v1" +) + +@server( + group: admin/crm/market/mgm + prefix: /api/v1/admin/market + middleware: EmployeeJWTAuth +) + +service PowerX { + @doc "查询MGM列表" + @handler ListMGMsPage + get /mgms/page-list (ListMGMsPageRequest) returns (ListMGMsPageReply) + @doc "请求MGM上传链接" + @handler CreateMGM + post /mgms (CreateMGMRequest) returns (CreateMGMReply) + + @doc "创建或更新MGM" + @handler UpdateMGM + put /mgms/:id (UpdateMGMRequest) returns (UpdateMGMReply) + + @doc "根据获取MGM" + @handler GetMGM + get /mgms/:id (GetMGMRequest) returns (GetMGMReply) + + @doc "删除MGM" + @handler DeleteMGM + delete /mgms/:id (DeleteMGMRequest) returns (DeleteMGMReply) +} + +type ( + ListMGMsPageRequest struct { + MGMTypes []int8 `form:"mgmTypes,optional"` + Keys []string `form:"keys,optional"` + OrderBy string `form:"orderBy,optional"` + PageIndex int `form:"pageIndex,optional"` + PageSize int `form:"pageSize,optional"` + } + + MGM struct { + Id int64 `json:"id,optional"` + + Title string `json:"title,optional"` + SubTitle string `json:"subTitle,optional"` + CoverImageId int64 `json:"coverImageId,optional"` + ResourceUrl string `json:"resourceUrl,optional"` + Description string `json:"description,optional"` + MGMType int `json:"mgmType,optional"` + ViewedCount int `json:"viewedCount,optional"` + } + + ListMGMsPageReply struct { + List []*MGM `json:"list"` + PageIndex int `json:"pageIndex"` + PageSize int `json:"pageSize"` + Total int64 `json:"total"` + } +) + +type ( + CreateMGMRequest struct { + MGM + } + + CreateMGMReply struct { + MGMId int64 `json:"id"` + } +) + +type ( + UpdateMGMRequest struct { + MGMId int64 `path:"id"` + MGM + } + + UpdateMGMReply struct { + MGMId int64 `json:"id"` + } +) + +type ( + GetMGMRequest struct { + MGMId int64 `path:"id"` + } + + GetMGMReply struct { + *MGM + } +) + +type ( + DeleteMGMRequest struct { + MGMId int64 `path:"id"` + } + + DeleteMGMReply struct { + MGMId int64 `json:"id"` + } +) diff --git a/cmd/ctl/database/migrate/powerx.go b/cmd/ctl/database/migrate/powerx.go index f815cc8d..76922cc9 100644 --- a/cmd/ctl/database/migrate/powerx.go +++ b/cmd/ctl/database/migrate/powerx.go @@ -72,6 +72,7 @@ func (m *PowerMigrator) AutoMigrate() { // market _ = m.db.AutoMigrate(&market.Media{}) + _ = m.db.AutoMigrate(&market.MGMRule{}, market.InviteRecord{}, market.CommissionRecord{}) // media _ = m.db.AutoMigrate(&media.MediaResource{}, &media.PivotMediaResourceToObject{}) @@ -83,7 +84,7 @@ func (m *PowerMigrator) AutoMigrate() { _ = m.db.AutoMigrate(&trade.OrderStatusTransition{}, &trade.PivotOrderToInventoryLog{}) _ = m.db.AutoMigrate(&trade.Payment{}, &trade.PaymentItem{}) _ = m.db.AutoMigrate(&trade.RefundOrder{}, &trade.RefundOrderItem{}) - _ = m.db.AutoMigrate(&trade.TokenBalance{}, &trade.ExchangeRatio{}, &trade.ExchangeRecord{}) + _ = m.db.AutoMigrate(&trade.TokenBalance{}, &trade.TokenExchangeRatio{}, &trade.TokenExchangeRecord{}) // custom migrate.AutoMigrateCustom(m.db) diff --git a/cmd/ctl/database/seed/datadictionary/datadictionary.go b/cmd/ctl/database/seed/datadictionary/datadictionary.go index 03c20609..94fce59d 100644 --- a/cmd/ctl/database/seed/datadictionary/datadictionary.go +++ b/cmd/ctl/database/seed/datadictionary/datadictionary.go @@ -50,6 +50,7 @@ func DefaultDataDictionary() (data []*model.DataDictionaryType) { defaultPaymentTypeDataDictionary(), defaultPaymentStatusDataDictionary(), defaultTokenCategoryDataDictionary(), + defaultMGMDataDictionary(), } return data diff --git a/cmd/ctl/database/seed/datadictionary/mgm.go b/cmd/ctl/database/seed/datadictionary/mgm.go new file mode 100644 index 00000000..4964ed76 --- /dev/null +++ b/cmd/ctl/database/seed/datadictionary/mgm.go @@ -0,0 +1,66 @@ +package datadictionary + +import ( + "PowerX/internal/model" + "PowerX/internal/model/crm/market" +) + +func defaultMGMDataDictionary() *model.DataDictionaryType { + return &model.DataDictionaryType{ + Items: []*model.DataDictionaryItem{ + &model.DataDictionaryItem{ + Key: market.MGMSceneDirectRecruitment, + Type: market.TypeMGMScene, + Name: "直接会员招募", + Value: market.MGMSceneDirectRecruitment, + Sort: 0, + }, + &model.DataDictionaryItem{ + Key: market.MGMSceneIndirectRecruitment, + Type: market.TypeMGMScene, + Name: "间接会员招募", + Value: market.MGMSceneIndirectRecruitment, + Sort: 0, + }, + &model.DataDictionaryItem{ + Key: market.MGMSceneTeamPerformanceReward, + Type: market.TypeMGMScene, + Name: "团队业绩奖励(仅限两层)", + Value: market.MGMSceneTeamPerformanceReward, + Sort: 0, + }, + &model.DataDictionaryItem{ + Key: market.MGMSceneLevelUpgradeReward, + Type: market.TypeMGMScene, + Name: "级别升级奖励", + Value: market.MGMSceneLevelUpgradeReward, + Sort: 0, + }, + &model.DataDictionaryItem{ + Key: market.MGMSceneMonthlyRecruitmentCompetition, + Type: market.TypeMGMScene, + Name: "月度拉新竞赛(仅限两层)", + Value: market.MGMSceneMonthlyRecruitmentCompetition, + Sort: 0, + }, + &model.DataDictionaryItem{ + Key: market.MGMSceneProductPromotionReward, + Type: market.TypeMGMScene, + Name: "推广特定产品奖励", + Value: market.MGMSceneProductPromotionReward, + Sort: 0, + }, + &model.DataDictionaryItem{ + Key: market.MGMSceneVIPMemberReward, + Type: market.TypeMGMScene, + Name: "VIP会员奖励", + Value: market.MGMSceneVIPMemberReward, + Sort: 0, + }, + }, + Type: market.TypeMGMScene, + Name: "MGM场景类型", + Description: "各种MGM 客户转介绍的类型", + } + +} diff --git a/cmd/ctl/database/seed/mgm.go b/cmd/ctl/database/seed/mgm.go new file mode 100644 index 00000000..fdb98b65 --- /dev/null +++ b/cmd/ctl/database/seed/mgm.go @@ -0,0 +1,97 @@ +package seed + +import ( + "PowerX/internal/model/crm/market" + "PowerX/internal/uc/powerx" + "context" + "github.com/pkg/errors" + "gorm.io/gorm" +) + +func CreateMGMRules(db *gorm.DB) (err error) { + + var count int64 + if err = db.Model(&market.MGMRule{}).Count(&count).Error; err != nil { + panic(errors.Wrap(err, "init mgm rules failed")) + } + + data := DefaultMGMRules(db) + if count == 0 { + if err = db.Model(&market.MGMRule{}).Create(data).Error; err != nil { + panic(errors.Wrap(err, "init mgm rules failed")) + } + } + + return err +} + +func DefaultMGMRules(db *gorm.DB) []*market.MGMRule { + + ucDD := powerx.NewDataDictionaryUseCase(db) + arrayRules := []*market.MGMRule{} + item, _ := ucDD.GetDataDictionaryItem(context.Background(), market.TypeMGMScene, market.MGMSceneDirectRecruitment) + rule := &market.MGMRule{ + CommissionRate1: 0.05, + CommissionRate2: 0, + Scene: int(item.Id), + Description: "描述:会员A成功招募了新会员B,新会员B在系统内进行了消费。\n\n分佣率:A获得B的总消费额的一定比例,例如5%。", + } + arrayRules = append(arrayRules, rule) + + item, _ = ucDD.GetDataDictionaryItem(context.Background(), market.TypeMGMScene, market.MGMSceneIndirectRecruitment) + rule = &market.MGMRule{ + CommissionRate1: 0.05, + CommissionRate2: 0.3, + Scene: int(item.Id), + Description: "描述:会员A招募了新会员B,新会员B成功招募了C。C在系统内进行了消费。\n\n分佣率:A获得C的总消费额的一定比例,例如3%。", + } + arrayRules = append(arrayRules, rule) + + item, _ = ucDD.GetDataDictionaryItem(context.Background(), market.TypeMGMScene, market.MGMSceneTeamPerformanceReward) + rule = &market.MGMRule{ + CommissionRate1: 0.02, + CommissionRate2: 0, + Scene: int(item.Id), + Description: "描述:会员A成功招募了多个会员,并带领团队一起推广,团队的总业绩达到一定水平。\n\n分佣率:A获得团队总业绩的一定比例,例如2%。", + } + arrayRules = append(arrayRules, rule) + + item, _ = ucDD.GetDataDictionaryItem(context.Background(), market.TypeMGMScene, market.MGMSceneLevelUpgradeReward) + rule = &market.MGMRule{ + CommissionRate1: 0.05, + CommissionRate2: 0, + Scene: int(item.Id), + Description: "描述:会员A的团队中达到一定数量的下级会员,A升级成高级会员。\n\n分佣率:A获得自己及其下级会员的总业绩的一定比例,例如5%。", + } + arrayRules = append(arrayRules, rule) + + item, _ = ucDD.GetDataDictionaryItem(context.Background(), market.TypeMGMScene, market.MGMSceneMonthlyRecruitmentCompetition) + rule = &market.MGMRule{ + CommissionRate1: 0.05, + CommissionRate2: 0, + Scene: int(item.Id), + Description: "描述:每个月内,会员A成功拉新的会员数量排名前三的获得额外奖励。\n\n分佣率:第一名获得总消费额的5%,第二名获得总消费额的3%,第三名获得总消费额的2%。\n\n", + } + arrayRules = append(arrayRules, rule) + + item, _ = ucDD.GetDataDictionaryItem(context.Background(), market.TypeMGMScene, market.MGMSceneProductPromotionReward) + rule = &market.MGMRule{ + CommissionRate1: 0.1, + CommissionRate2: 0, + Scene: int(item.Id), + Description: "描述:会员A成功推广了某个特定产品,被推广的产品有额外奖励计划。\n\n分佣率:A获得特定产品销售额的一定比例,例如10%。", + } + arrayRules = append(arrayRules, rule) + + item, _ = ucDD.GetDataDictionaryItem(context.Background(), market.TypeMGMScene, market.MGMSceneVIPMemberReward) + rule = &market.MGMRule{ + CommissionRate1: 0.15, + CommissionRate2: 0, + Scene: int(item.Id), + Description: "描述:成功招募并维持了高额消费的VIP会员获得额外奖励。\n\n分佣率:VIP会员的消费额度的一定比例,例如15%。", + } + arrayRules = append(arrayRules, rule) + + return arrayRules + +} diff --git a/cmd/ctl/database/seed/payment.go b/cmd/ctl/database/seed/payment.go index 4d819d58..6825f186 100644 --- a/cmd/ctl/database/seed/payment.go +++ b/cmd/ctl/database/seed/payment.go @@ -3,7 +3,7 @@ package seed import ( "PowerX/internal/model/crm/trade" "PowerX/internal/uc/powerx" - trade2 "PowerX/internal/uc/powerx/trade" + trade2 "PowerX/internal/uc/powerx/crm/trade" "context" "fmt" "github.com/pkg/errors" diff --git a/cmd/ctl/database/seed/powerx.go b/cmd/ctl/database/seed/powerx.go index fec68a45..cdc50ad1 100644 --- a/cmd/ctl/database/seed/powerx.go +++ b/cmd/ctl/database/seed/powerx.go @@ -52,10 +52,14 @@ func (s *PowerSeeder) CreatePowerX() (err error) { _ = CreatePayments(s.db) } + // Product _ = CreateTokenProducts(s.db) _ = CreatePriceBooks(s.db) _ = CreateTokenExchangeRatios(s.db) + // Marketing + _ = CreateMGMRules(s.db) + // custom seed.CreateCustomSeeds(s.db) diff --git a/cmd/ctl/database/seed/pricebook.go b/cmd/ctl/database/seed/pricebook.go index a271a9bb..5529e1ec 100644 --- a/cmd/ctl/database/seed/pricebook.go +++ b/cmd/ctl/database/seed/pricebook.go @@ -4,7 +4,7 @@ import ( "PowerX/internal/model/crm/product" "PowerX/internal/types" "PowerX/internal/uc/powerx" - product2 "PowerX/internal/uc/powerx/product" + product2 "PowerX/internal/uc/powerx/crm/product" "context" "github.com/pkg/errors" "gorm.io/gorm" diff --git a/cmd/ctl/database/seed/product.go b/cmd/ctl/database/seed/product.go index 26452709..12b3c865 100644 --- a/cmd/ctl/database/seed/product.go +++ b/cmd/ctl/database/seed/product.go @@ -5,7 +5,7 @@ import ( "PowerX/internal/model/crm/product" "PowerX/internal/model/media" "PowerX/internal/uc/powerx" - product2 "PowerX/internal/uc/powerx/product" + product2 "PowerX/internal/uc/powerx/crm/product" "PowerX/pkg/mathx" "context" "fmt" diff --git a/cmd/ctl/database/seed/token.go b/cmd/ctl/database/seed/token.go index 99191d51..6961f6b8 100644 --- a/cmd/ctl/database/seed/token.go +++ b/cmd/ctl/database/seed/token.go @@ -11,13 +11,13 @@ import ( func CreateTokenExchangeRatios(db *gorm.DB) (err error) { var count int64 - if err = db.Model(&trade.ExchangeRatio{}).Count(&count).Error; err != nil { + if err = db.Model(&trade.TokenExchangeRatio{}).Count(&count).Error; err != nil { panic(errors.Wrap(err, "init exchange rate failed")) } data := DefaultExchangeRecord(db) if count == 0 { - if err = db.Model(&trade.ExchangeRatio{}).Create(data).Error; err != nil { + if err = db.Model(&trade.TokenExchangeRatio{}).Create(data).Error; err != nil { panic(errors.Wrap(err, "init price book failed")) } } @@ -25,12 +25,12 @@ func CreateTokenExchangeRatios(db *gorm.DB) (err error) { return err } -func DefaultExchangeRecord(db *gorm.DB) []*trade.ExchangeRatio { +func DefaultExchangeRecord(db *gorm.DB) []*trade.TokenExchangeRatio { ucDD := powerx.NewDataDictionaryUseCase(db) categoryId := ucDD.GetCachedDD(context.Background(), trade.TypeTokenCategory, trade.TokenCategoryPurchase).Id - return []*trade.ExchangeRatio{ + return []*trade.TokenExchangeRatio{ { FromCategory: int(categoryId), Ratio: 1, diff --git a/internal/model/crm/customerdomain/customer.go b/internal/model/crm/customerdomain/customer.go index 9c017ab5..c54a29ca 100644 --- a/internal/model/crm/customerdomain/customer.go +++ b/internal/model/crm/customerdomain/customer.go @@ -21,6 +21,7 @@ type Customer struct { Password string `gorm:"comment:客户密码" json:"password"` Email string `gorm:"comment:邮箱地址" json:"email"` InviterId int64 `gorm:"comment:邀请方" json:"inviterId"` + MgmId int `gorm:"comment:MGM Id" json:"mgmId"` Source int `gorm:"comment:注册来源" json:"source"` Type int `gorm:"comment:类型:个人,企业" json:"type"` IsActivated bool `gorm:"comment:激活状态" json:"isActivated"` diff --git a/internal/model/crm/market/mgm.go b/internal/model/crm/market/mgm.go new file mode 100644 index 00000000..e67c8464 --- /dev/null +++ b/internal/model/crm/market/mgm.go @@ -0,0 +1,64 @@ +package market + +import ( + "PowerX/internal/model/powermodel" +) + +type MGMRule struct { + powermodel.PowerModel + + CommissionRate1 float32 `gorm:"type:decimal(10,2); comment:分佣率1" json:"commissionRate1"` + CommissionRate2 float32 `gorm:"type:decimal(10,2); comment:分佣率2" json:"commissionRate2"` + Scene int `gorm:"comment:场景码" json:"sceneCode"` + Description string `gorm:"comment:场景描述" json:"description"` +} + +const ( + TypeMGMScene = "_mgm_scene" + + // 直接会员招募 + MGMSceneDirectRecruitment = "_direct_recruitment" // "直接会员招募", + // 间接会员招募 + MGMSceneIndirectRecruitment = "_indirect_recruitment" // "间接会员招募", + // 团队业绩奖励(仅限两层) + MGMSceneTeamPerformanceReward = "_team_performance_reward" // "团队业绩奖励(仅限两层)", + // 级别升级奖励 + MGMSceneLevelUpgradeReward = "_level_upgrade_reward" // "级别升级奖励", + // 月度拉新竞赛(仅限两层) + MGMSceneMonthlyRecruitmentCompetition = "_monthly_recruitment_competition" // "月度拉新竞赛(仅限两层)", + // 推广特定产品奖励 + MGMSceneProductPromotionReward = "_product_promotion_reward" // "推广特定产品奖励", + // VIP会员奖励 + MGMSceneVIPMemberReward = "_vip_member_reward" // "VIP会员奖励", +) + +// InviteRecord 表示会员邀请记录 +type InviteRecord struct { + powermodel.PowerModel + + InviterID int64 `gorm:"comment:邀请人ID" json:"inviterId"` + InviteeID int64 `gorm:"comment:被邀请人ID" json:"inviteeId"` + InvitationCode string `gorm:"comment:邀请码" json:"invitationCode"` + MgmSceneId int `gorm:"comment:MGM场景ID" json:"mgmSceneId"` +} + +// CommissionRecord 表示分佣记录 +type CommissionRecord struct { + powermodel.PowerModel + + InviterID int64 `gorm:"comment:邀请人ID" json:"inviterId"` + InviteeID int64 `gorm:"comment:被邀请人ID" json:"inviteeId"` + Amount float64 `gorm:"comment:分佣金额" json:"amount"` + OperationType string `gorm:"comment:操作对象类型" json:"operationType"` + OperationId int64 `gorm:"comment:操作对象ID" json:"operationId"` +} + +// RewardRecord 表示奖励记录 +type RewardRecord struct { + powermodel.PowerModel + + CustomerID int64 `gorm:"comment:会员ID" json:"customerId"` + Amount float64 `gorm:"comment:奖励金额" json:"amount"` + OperationType string `gorm:"comment:操作对象类型" json:"operationType"` + OperationId int64 `gorm:"comment:操作对象ID" json:"operationId"` +} diff --git a/internal/model/crm/market/promotion.go b/internal/model/crm/market/promotion.go index 7f73bcb7..1923024b 100644 --- a/internal/model/crm/market/promotion.go +++ b/internal/model/crm/market/promotion.go @@ -1,9 +1,9 @@ package market -import "github.com/ArtisanCloud/PowerLibs/v3/database" +import "PowerX/internal/model/powermodel" type PromotionRule struct { - database.PowerModel + powermodel.PowerModel MinPurchase float64 `gorm:"comment:起订购买量" json:"minPurchase"` BonusAmount float64 `gorm:"comment:额外赠送" json:"bonusAmount"` diff --git a/internal/model/crm/trade/token.go b/internal/model/crm/trade/token.go index 6b18ed1e..0cb8d3b1 100644 --- a/internal/model/crm/trade/token.go +++ b/internal/model/crm/trade/token.go @@ -6,7 +6,7 @@ import ( "github.com/ArtisanCloud/PowerLibs/v3/database" ) -type ExchangeRatio struct { +type TokenExchangeRatio struct { database.PowerModel FromCategory int `gorm:"comment:要兑换的代币种类" json:"fromCategory"` @@ -24,7 +24,7 @@ type TokenBalance struct { const TokenBalanceUniqueId = powermodel.UniqueId -type ExchangeRecord struct { +type TokenExchangeRecord struct { database.PowerModel CustomerId int64 `gorm:"comment:客户Id; index" json:"customerId"`