feat: 接入旧站管理端并完整迁移后台能力

This commit is contained in:
yml
2026-11-12 22:03:01 +08:00
parent e5f923706b
commit a4441bba9a
509 changed files with 140714 additions and 1068 deletions
+12 -2
View File
@@ -2,13 +2,21 @@ package model
import "time"
// 录单组别取值。
const (
CSManualEntryGroupCollect = "collect" // 收号
CSManualEntryGroupSell = "sell" // 出号
)
// CSManualEntry 客服手动录单记录。
// 客服在后台手动登记一个编号(如 202610120013),该编号与其登录账号绑定,
// 记录平台、操作人、登记时间等,供后续查询与按客服统计今日录单量。
// 记录组别(收号/出号)、平台、操作人、登记时间等,供后续查询与按客服统计今日录单量。
// 同一编号允许收号、出号两组各登记一次,唯一键为 (entry_no, entry_group)。
// platform / operator 存名称快照:后台删掉选项也不影响历史记录展示。
type CSManualEntry struct {
ID uint64 `gorm:"primaryKey" json:"id"`
EntryNo string `gorm:"size:64;not null;uniqueIndex" json:"entry_no"`
EntryNo string `gorm:"size:64;not null;uniqueIndex:uk_cs_manual_entries_entry_no_group,priority:1" json:"entry_no"`
EntryGroup string `gorm:"size:16;not null;default:'collect';uniqueIndex:uk_cs_manual_entries_entry_no_group,priority:2;index" json:"entry_group"`
Platform string `gorm:"size:64;not null;default:'';index" json:"platform"`
Operator string `gorm:"size:64;not null;default:'';index" json:"operator"`
AdminID uint64 `gorm:"not null;index" json:"admin_id"`
@@ -25,10 +33,12 @@ func (CSManualEntry) TableName() string {
// CSManualEntryOption 客服手动录单的可选项配置(平台 / 操作人)。
// 仅作为录单表单的下拉数据源,记录里保存的是名称快照。
// 操作人选项可通过 group_tag 标记所属组别(收号/出号),录单时用于自动带出组别。
type CSManualEntryOption struct {
ID uint64 `gorm:"primaryKey" json:"id"`
Type string `gorm:"size:16;not null;uniqueIndex:uk_cs_manual_entry_options_type_name,priority:1" json:"type"`
Name string `gorm:"size:64;not null;uniqueIndex:uk_cs_manual_entry_options_type_name,priority:2" json:"name"`
GroupTag string `gorm:"size:16;not null;default:''" json:"group_tag"`
SortOrder int `gorm:"not null;default:0" json:"sort_order"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
+3
View File
@@ -43,6 +43,9 @@ type RentalListing struct {
ManagedAdminID *uint64 `gorm:"index" json:"managed_admin_id"`
DistributionSiteID *uint64 `gorm:"column:distribution_site_id;index" json:"distribution_site_id,omitempty"`
SourceChannel string `gorm:"size:64;not null;default:''" json:"-"`
IsPremium bool `gorm:"not null;default:false" json:"is_premium"`
CompensationPlan string `gorm:"size:16;not null;default:'normal'" json:"compensation_plan"`
InsuranceFeeBps int `gorm:"not null;default:0" json:"insurance_fee_bps"`
ReviewReason string `gorm:"size:255;not null;default:''" json:"review_reason"`
PublishedAt *time.Time `json:"published_at"`
CreatedAt time.Time `json:"created_at"`
+51 -41
View File
@@ -8,51 +8,61 @@ import (
)
type RentalOrder struct {
ID uint64 `gorm:"primaryKey" json:"id"`
OrderNo string `gorm:"size:64;not null;uniqueIndex" json:"order_no"`
ListingID uint64 `gorm:"not null;index" json:"listing_id"`
AccountID uint64 `gorm:"not null;index" json:"account_id"`
OwnerID uint64 `gorm:"not null;index" json:"owner_id"`
RenterID uint64 `gorm:"not null;index" json:"renter_id"`
RentedAt *time.Time `json:"rented_at"`
HandoffStartedAt *time.Time `json:"handoff_started_at"`
EstimatedDurationHours int `gorm:"not null;default:24" json:"estimated_duration_hours"`
RentAmountCent int64 `gorm:"not null;default:0" json:"-"`
OwnerRentAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositWaivedAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositFreeLevelQuotaCent int64 `gorm:"not null;default:0" json:"deposit_free_level_quota_cent"`
DepositFreeManualQuotaCent int64 `gorm:"not null;default:0" json:"deposit_free_manual_quota_cent"`
DepositFreeUsedBeforeCent int64 `gorm:"not null;default:0" json:"deposit_free_used_before_cent"`
PlatformFeeCent int64 `gorm:"not null;default:0" json:"-"`
BasePriceCent int64 `gorm:"not null;default:0" json:"-"`
ShelfMarkupCent int64 `gorm:"not null;default:0" json:"-"`
MarkupSiteID uint64 `gorm:"not null;default:0;index" json:"markup_site_id,omitempty"`
ShelfRatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"shelf_ratio,omitempty"`
ShelfRatioDelta float64 `gorm:"type:decimal(10,2);not null;default:0" json:"shelf_ratio_delta,omitempty"`
RentOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
RentDiscountAmountCent int64 `gorm:"not null;default:0" json:"-"`
PureCoinOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
ExtraItemOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
ActualCoinConsumedM float64 `gorm:"type:decimal(12,2);not null;default:0" json:"actual_coin_consumed_m"`
ActualPureCoinAmountCent int64 `gorm:"not null;default:0" json:"-"`
ActualPureCoinDiscountCent int64 `gorm:"not null;default:0" json:"-"`
ActualExtraItemAmountCent int64 `gorm:"not null;default:0" json:"-"`
RenterGrowthLevel string `gorm:"size:32;not null;default:'normal'" json:"renter_growth_level"`
RenterGrowthLevelName string `gorm:"size:32;not null;default:'普通'" json:"renter_growth_level_name"`
RenterDiscountBps int `gorm:"not null;default:10000" json:"renter_discount_bps"`
GrowthPointsBasisCent int64 `gorm:"not null;default:0" json:"growth_points_basis_cent"`
GrowthPointsPerYuan int64 `gorm:"not null;default:0" json:"growth_points_per_yuan"`
GrowthPointsAwarded int64 `gorm:"not null;default:0" json:"growth_points_awarded"`
GrowthPointsAwardedAt *time.Time `json:"growth_points_awarded_at"`
AccountSnapshot datatypes.JSON `json:"account_snapshot"`
AccountSource string `gorm:"size:32;not null;default:'internal';index" json:"account_source"`
SourceChannel string `gorm:"size:32;not null;default:''" json:"source_channel"`
ID uint64 `gorm:"primaryKey" json:"id"`
OrderNo string `gorm:"size:64;not null;uniqueIndex" json:"order_no"`
ListingID uint64 `gorm:"not null;index" json:"listing_id"`
AccountID uint64 `gorm:"not null;index" json:"account_id"`
OwnerID uint64 `gorm:"not null;index" json:"owner_id"`
RenterID uint64 `gorm:"not null;index" json:"renter_id"`
RentedAt *time.Time `json:"rented_at"`
HandoffStartedAt *time.Time `json:"handoff_started_at"`
EstimatedDurationHours int `gorm:"not null;default:24" json:"estimated_duration_hours"`
RentAmountCent int64 `gorm:"not null;default:0" json:"-"`
OwnerRentAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositWaivedAmountCent int64 `gorm:"not null;default:0" json:"-"`
DepositFreeLevelQuotaCent int64 `gorm:"not null;default:0" json:"deposit_free_level_quota_cent"`
DepositFreeManualQuotaCent int64 `gorm:"not null;default:0" json:"deposit_free_manual_quota_cent"`
DepositFreeUsedBeforeCent int64 `gorm:"not null;default:0" json:"deposit_free_used_before_cent"`
PlatformFeeCent int64 `gorm:"not null;default:0" json:"-"`
BasePriceCent int64 `gorm:"not null;default:0" json:"-"`
ShelfMarkupCent int64 `gorm:"not null;default:0" json:"-"`
MarkupSiteID uint64 `gorm:"not null;default:0;index" json:"markup_site_id,omitempty"`
ShelfRatio float64 `gorm:"type:decimal(10,2);not null;default:0" json:"shelf_ratio,omitempty"`
ShelfRatioDelta float64 `gorm:"type:decimal(10,2);not null;default:0" json:"shelf_ratio_delta,omitempty"`
RentOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
RentDiscountAmountCent int64 `gorm:"not null;default:0" json:"-"`
PureCoinOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
ExtraItemOriginalAmountCent int64 `gorm:"not null;default:0" json:"-"`
ActualCoinConsumedM float64 `gorm:"type:decimal(12,2);not null;default:0" json:"actual_coin_consumed_m"`
ActualPureCoinAmountCent int64 `gorm:"not null;default:0" json:"-"`
ActualPureCoinDiscountCent int64 `gorm:"not null;default:0" json:"-"`
ActualExtraItemAmountCent int64 `gorm:"not null;default:0" json:"-"`
RenterGrowthLevel string `gorm:"size:32;not null;default:'normal'" json:"renter_growth_level"`
RenterGrowthLevelName string `gorm:"size:32;not null;default:'普通'" json:"renter_growth_level_name"`
RenterDiscountBps int `gorm:"not null;default:10000" json:"renter_discount_bps"`
GrowthPointsBasisCent int64 `gorm:"not null;default:0" json:"growth_points_basis_cent"`
GrowthPointsPerYuan int64 `gorm:"not null;default:0" json:"growth_points_per_yuan"`
GrowthPointsMultiplierBps int `gorm:"not null;default:10000" json:"growth_points_multiplier_bps"`
GrowthPointsAwarded int64 `gorm:"not null;default:0" json:"growth_points_awarded"`
GrowthPointsAwardedAt *time.Time `json:"growth_points_awarded_at"`
OwnerGrowthPointsBasisCent int64 `gorm:"not null;default:0" json:"owner_growth_points_basis_cent"`
OwnerGrowthPointsPerYuan int64 `gorm:"not null;default:0" json:"owner_growth_points_per_yuan"`
OwnerGrowthPointsMultiplierBps int `gorm:"not null;default:10000" json:"owner_growth_points_multiplier_bps"`
OwnerGrowthPointsAwarded int64 `gorm:"not null;default:0" json:"owner_growth_points_awarded"`
OwnerGrowthPointsAwardedAt *time.Time `json:"owner_growth_points_awarded_at"`
AccountSnapshot datatypes.JSON `json:"account_snapshot"`
AccountSource string `gorm:"size:32;not null;default:'internal';index" json:"account_source"`
SourceChannel string `gorm:"size:32;not null;default:''" json:"source_channel"`
// 分销正常订单字段:仅在卖家和租客都通过分销网站完成交易时填写。
DistributionSiteID *uint64 `gorm:"index" json:"distribution_site_id,omitempty"`
DistributionMode string `gorm:"size:32;not null;default:'';index" json:"distribution_mode"`
DistributionRuleVersionID *uint64 `gorm:"index" json:"distribution_rule_version_id,omitempty"`
IsPremium bool `gorm:"not null;default:false" json:"is_premium"`
CompensationPlan string `gorm:"size:16;not null;default:'normal'" json:"compensation_plan"`
InsuranceFeeBps int `gorm:"not null;default:0" json:"insurance_fee_bps"`
InsuranceFeeCent int64 `gorm:"not null;default:0" json:"insurance_fee_cent"`
Status string `gorm:"size:32;not null;default:'pending_payment'" json:"status"`
HandoffStatus string `gorm:"size:32;not null;default:'none'" json:"handoff_status"`
HandoffMode string `gorm:"size:16;not null;default:'owner';index" json:"handoff_mode"`
+2
View File
@@ -17,6 +17,8 @@ type OrderCheckout struct {
RentAmountCent int64 `gorm:"not null;default:0" json:"-"`
OwnerRentAmountCent int64 `gorm:"not null;default:0" json:"-"`
PlatformFeeCent int64 `gorm:"not null;default:0" json:"-"`
InsuranceFeeBps int `gorm:"not null;default:0" json:"-"`
InsuranceFeeCent int64 `gorm:"not null;default:0" json:"-"`
DepositAmountCent int64 `gorm:"not null;default:0" json:"-"`
PureCoinAmountCent int64 `gorm:"not null;default:0" json:"-"`
PureCoinDiscountCent int64 `gorm:"not null;default:0" json:"-"`
+1
View File
@@ -11,6 +11,7 @@ type PaymentOrder struct {
PaymentNo string `gorm:"size:64;not null;uniqueIndex" json:"payment_no"`
OrderID uint64 `gorm:"not null;index" json:"order_id"`
OrderNo string `gorm:"size:64;not null;index" json:"order_no"`
BizID uint64 `gorm:"not null;default:0;index:idx_payment_orders_user_biz,priority:3" json:"biz_id"`
UserID uint64 `gorm:"not null;index" json:"user_id"`
PaymentConfigID uint64 `gorm:"not null;default:0;index" json:"payment_config_id"`
Provider string `gorm:"size:32;not null" json:"provider"`
+50
View File
@@ -0,0 +1,50 @@
package model
import "time"
type PointsMallProduct struct {
ID uint64 `gorm:"primaryKey" json:"id"`
Title string `gorm:"size:128;not null" json:"title"`
Subtitle string `gorm:"size:255;not null;default:''" json:"subtitle"`
Description string `gorm:"type:text;not null" json:"description"`
CoverURL string `gorm:"size:512;not null;default:''" json:"cover_url"`
RedemptionInstructions string `gorm:"type:text;not null" json:"redemption_instructions"`
PointsPrice int64 `gorm:"not null;default:0" json:"points_price"`
Stock int64 `gorm:"not null;default:0" json:"stock"`
RedeemedCount int64 `gorm:"not null;default:0" json:"redeemed_count"`
PerUserLimit int `gorm:"not null;default:1" json:"per_user_limit"`
Status string `gorm:"size:16;not null;default:'offline'" json:"status"`
SortOrder int `gorm:"not null;default:0" json:"sort_order"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (PointsMallProduct) TableName() string {
return "points_mall_products"
}
type PointsMallRedemption struct {
ID uint64 `gorm:"primaryKey" json:"id"`
RedemptionNo string `gorm:"size:32;not null;uniqueIndex" json:"redemption_no"`
UserID uint64 `gorm:"not null;index" json:"user_id"`
ProductID uint64 `gorm:"not null;index" json:"product_id"`
ProductTitle string `gorm:"size:128;not null" json:"product_title"`
ProductCoverURL string `gorm:"size:512;not null;default:''" json:"product_cover_url"`
RedemptionInstructions string `gorm:"type:text;not null" json:"redemption_instructions"`
ContactName string `gorm:"size:32;not null;default:''" json:"contact_name"`
ContactPhone string `gorm:"size:32;not null;default:''" json:"contact_phone"`
CustomerRemark string `gorm:"size:500;not null;default:''" json:"customer_remark"`
PointsPrice int64 `gorm:"not null;default:0" json:"points_price"`
Quantity int `gorm:"not null;default:1" json:"quantity"`
TotalPoints int64 `gorm:"not null;default:0" json:"total_points"`
Status string `gorm:"size:16;not null;default:'pending'" json:"status"`
AdminRemark string `gorm:"size:255;not null;default:''" json:"admin_remark"`
CompletedBy *uint64 `json:"completed_by,omitempty"`
CompletedAt *time.Time `json:"completed_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (PointsMallRedemption) TableName() string {
return "points_mall_redemptions"
}
+20 -14
View File
@@ -4,20 +4,26 @@ import "time"
// RenterGrowthLedger 记录租客成长积分变动流水,便于排查订单完成后的积分发放。
type RenterGrowthLedger struct {
ID uint64 `gorm:"primaryKey" json:"id"`
UserID uint64 `gorm:"not null;index" json:"user_id"`
OrderID *uint64 `gorm:"index;uniqueIndex:uk_renter_growth_order_source,priority:1" json:"order_id,omitempty"`
Points int64 `gorm:"not null;default:0" json:"points"`
BasisAmountCent int64 `gorm:"not null;default:0" json:"basis_amount_cent"`
PointsPerYuan int64 `gorm:"not null;default:0" json:"points_per_yuan"`
BeforePoints int64 `gorm:"not null;default:0" json:"before_points"`
AfterPoints int64 `gorm:"not null;default:0" json:"after_points"`
BeforeLevel string `gorm:"size:32;not null;default:'normal'" json:"before_level"`
AfterLevel string `gorm:"size:32;not null;default:'normal'" json:"after_level"`
Source string `gorm:"size:32;not null;default:'order_completed';uniqueIndex:uk_renter_growth_order_source,priority:2" json:"source"`
OperatorAdminID *uint64 `gorm:"index" json:"operator_admin_id,omitempty"`
Remark string `gorm:"size:255;not null;default:''" json:"remark"`
CreatedAt time.Time `json:"created_at"`
ID uint64 `gorm:"primaryKey" json:"id"`
UserID uint64 `gorm:"not null;index" json:"user_id"`
Role string `gorm:"size:16;not null;default:'renter';uniqueIndex:uk_renter_growth_order_role_source,priority:3" json:"role"`
OrderID *uint64 `gorm:"index;uniqueIndex:uk_renter_growth_order_role_source,priority:1" json:"order_id,omitempty"`
RedemptionID uint64 `gorm:"not null;default:0" json:"redemption_id"`
Points int64 `gorm:"not null;default:0" json:"points"`
BasisAmountCent int64 `gorm:"not null;default:0" json:"basis_amount_cent"`
PointsPerYuan int64 `gorm:"not null;default:0" json:"points_per_yuan"`
PointsMultiplierBps int `gorm:"not null;default:10000" json:"points_multiplier_bps"`
BeforePoints int64 `gorm:"not null;default:0" json:"before_points"`
AfterPoints int64 `gorm:"not null;default:0" json:"after_points"`
AvailableBefore int64 `gorm:"not null;default:0" json:"available_before"`
AvailableAfter int64 `gorm:"not null;default:0" json:"available_after"`
BeforeLevel string `gorm:"size:32;not null;default:'normal'" json:"before_level"`
AfterLevel string `gorm:"size:32;not null;default:'normal'" json:"after_level"`
Source string `gorm:"size:32;not null;default:'order_completed';uniqueIndex:uk_renter_growth_order_role_source,priority:2" json:"source"`
BizKey *string `gorm:"size:128;uniqueIndex:uk_renter_growth_biz_key" json:"biz_key,omitempty"`
OperatorAdminID *uint64 `gorm:"index" json:"operator_admin_id,omitempty"`
Remark string `gorm:"size:255;not null;default:''" json:"remark"`
CreatedAt time.Time `json:"created_at"`
}
func (RenterGrowthLedger) TableName() string {
+18 -12
View File
@@ -3,18 +3,24 @@ package model
import "time"
type User struct {
ID uint64 `gorm:"primaryKey" json:"id"`
Phone string `gorm:"size:32;not null;uniqueIndex" json:"phone"`
PasswordHash string `gorm:"size:255;not null;default:''" json:"-"`
Nickname string `gorm:"size:64;not null;default:''" json:"nickname"`
AvatarURL string `gorm:"size:512;not null;default:''" json:"avatar_url"`
RealnameStatus string `gorm:"size:32;not null;default:'unverified'" json:"realname_status"`
RiskStatus string `gorm:"size:32;not null;default:'normal'" json:"risk_status"`
CreditScore int `gorm:"not null;default:100" json:"credit_score"`
DepositFreeQuotaCent int64 `gorm:"not null;default:0" json:"-"`
RenterGrowthPoints int64 `gorm:"not null;default:0;index:idx_users_renter_growth_level,priority:2" json:"renter_growth_points"`
RenterGrowthLevel string `gorm:"size:32;not null;default:'normal';index:idx_users_renter_growth_level,priority:1" json:"renter_growth_level"`
Status string `gorm:"size:32;not null;default:'active'" json:"status"`
ID uint64 `gorm:"primaryKey" json:"id"`
Phone string `gorm:"size:32;not null;uniqueIndex" json:"phone"`
PasswordHash string `gorm:"size:255;not null;default:''" json:"-"`
Nickname string `gorm:"size:64;not null;default:''" json:"nickname"`
AvatarURL string `gorm:"size:512;not null;default:''" json:"avatar_url"`
RealnameStatus string `gorm:"size:32;not null;default:'unverified'" json:"realname_status"`
RiskStatus string `gorm:"size:32;not null;default:'normal'" json:"risk_status"`
CreditScore int `gorm:"not null;default:100" json:"credit_score"`
DepositFreeQuotaCent int64 `gorm:"not null;default:0" json:"-"`
RenterGrowthPoints int64 `gorm:"not null;default:0;index:idx_users_renter_growth_level,priority:2" json:"renter_growth_points"`
RenterGrowthLevel string `gorm:"size:32;not null;default:'normal';index:idx_users_renter_growth_level,priority:1" json:"renter_growth_level"`
RenterGrowthLevelOverride string `gorm:"size:32;not null;default:''" json:"-"`
PointsAvailable int64 `gorm:"not null;default:0" json:"points_available"`
Status string `gorm:"size:32;not null;default:'active'" json:"status"`
QualityOwnerStatus string `gorm:"size:16;not null;default:'none';index:idx_users_quality_owner_status" json:"quality_owner_status"`
QualityOwnerDepositCent int64 `gorm:"not null;default:0" json:"quality_owner_deposit_cent"`
QualityOwnerDepositSource string `gorm:"size:16;not null;default:''" json:"quality_owner_deposit_source"`
QualityOwnerActivatedAt *time.Time `json:"quality_owner_activated_at"`
// 会话版本:递增后该用户已签发的全部令牌立即失效。
// 默认值对齐迁移 000052 的 users.token_version DEFAULT 0。
TokenVersion int64 `gorm:"not null;default:0" json:"-"`