feat(points): 增加双边积分与虚拟积分商城
This commit is contained in:
@@ -8,47 +8,53 @@ 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"`
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
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"`
|
||||
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"
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -14,6 +14,7 @@ type User struct {
|
||||
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"`
|
||||
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"`
|
||||
|
||||
Reference in New Issue
Block a user