feat: 完善小组绩效与有效端统计并修复审查问题
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
package business
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"kra/pkg/database/migration"
|
||||
)
|
||||
|
||||
type businessGroupPO struct {
|
||||
ID uint64 `gorm:"primaryKey"`
|
||||
Name string `gorm:"size:40;not null"`
|
||||
OwnerID uint `gorm:"index"`
|
||||
Sort int
|
||||
CreatedAt, UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
}
|
||||
|
||||
func (businessGroupPO) TableName() string { return "sys_business_groups" }
|
||||
|
||||
type businessGroupMemberPO struct {
|
||||
UserID uint `gorm:"primaryKey;autoIncrement:false"`
|
||||
GroupID uint64 `gorm:"index;not null"`
|
||||
}
|
||||
|
||||
func (businessGroupMemberPO) TableName() string { return "sys_business_group_members" }
|
||||
|
||||
type businessMemberProfilePO struct {
|
||||
UserID uint `gorm:"primaryKey;autoIncrement:false"`
|
||||
HireDate string `gorm:"size:10"`
|
||||
Employment string `gorm:"size:16;not null;default:employed"`
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (businessMemberProfilePO) TableName() string { return "sys_business_member_profiles" }
|
||||
|
||||
type businessGroupStatePO struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement:false"`
|
||||
Revision uint64
|
||||
}
|
||||
|
||||
func (businessGroupStatePO) TableName() string { return "sys_business_group_state" }
|
||||
|
||||
type performanceGoalPO struct {
|
||||
Kind string `gorm:"primaryKey;size:8"`
|
||||
TargetID uint64 `gorm:"primaryKey;autoIncrement:false"`
|
||||
Month string `gorm:"primaryKey;size:7;index"`
|
||||
Open, Effective, Amount *int64
|
||||
UpdatedBy uint
|
||||
CreatedAt, UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (performanceGoalPO) TableName() string { return "sys_business_performance_goals" }
|
||||
|
||||
type effectivenessStatePO struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement:false"`
|
||||
RuleKey string `gorm:"size:64"`
|
||||
Revision uint64
|
||||
BuiltAt *time.Time
|
||||
}
|
||||
|
||||
func (effectivenessStatePO) TableName() string { return "sys_business_effectiveness_state" }
|
||||
|
||||
type effectivenessPO struct {
|
||||
RuleKey string `gorm:"primaryKey;size:64;index:idx_sw_effective_date,priority:1"`
|
||||
// Platform codes are identifiers. Binary storage also avoids collation
|
||||
// conflicts when joining historical SDK tables imported with another collation.
|
||||
SourceDB string `gorm:"primaryKey;type:varbinary(10)"`
|
||||
PromoteID uint64 `gorm:"primaryKey;autoIncrement:false"`
|
||||
QualifiedAt *int64 `gorm:"index:idx_sw_effective_date,priority:2"`
|
||||
WindowPay string `gorm:"type:decimal(28,2);not null;default:0"`
|
||||
Complete bool
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (effectivenessPO) TableName() string { return "sys_business_channel_effectiveness" }
|
||||
|
||||
func migrateBusinessManagement(db *gorm.DB) error {
|
||||
if err := migration.CreateMissingTables(db, &businessGroupPO{}, &businessGroupMemberPO{}, &businessMemberProfilePO{}, &businessGroupStatePO{}, &performanceGoalPO{}, &effectivenessStatePO{}, &effectivenessPO{}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.Clauses(clause.OnConflict{DoNothing: true}).Create(&businessGroupStatePO{ID: 1}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return db.Clauses(clause.OnConflict{DoNothing: true}).Create(&effectivenessStatePO{ID: 1}).Error
|
||||
}
|
||||
|
||||
func migrateEffectivenessQueryIndex(db *gorm.DB) error {
|
||||
return migrateQueryIndexes(db, []businessQueryIndex{{"tab_spend", "idx_sw_spend_effective_scan", []string{"promote_id", "source_db", "pay_status", "pay_time", "id", "pay_amount"}}})
|
||||
}
|
||||
Reference in New Issue
Block a user