feat(benefits): 增加权益中心
This commit is contained in:
@@ -76,3 +76,33 @@ func TestRedeemDeductsAvailablePointsAndStock(t *testing.T) {
|
||||
t.Fatalf("redemption status = %s, want completed", completed.Status)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSummaryIncludesGrowthLevelRules(t *testing.T) {
|
||||
db := database.NewTestDB()
|
||||
user := model.User{
|
||||
Phone: "13900009602",
|
||||
RenterGrowthPoints: 1000,
|
||||
PointsAvailable: 432,
|
||||
}
|
||||
if err := db.Create(&user).Error; err != nil {
|
||||
t.Fatalf("create user failed: %v", err)
|
||||
}
|
||||
|
||||
summary, err := NewRepository(db).Summary(t.Context(), user.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("summary failed: %v", err)
|
||||
}
|
||||
if !summary.GrowthEnabled || len(summary.Levels) != 4 {
|
||||
t.Fatalf("growth config = enabled %v levels %d", summary.GrowthEnabled, len(summary.Levels))
|
||||
}
|
||||
if summary.LevelCode != "diamond" || summary.PointsMultiplierBps != 15_000 {
|
||||
t.Fatalf(
|
||||
"current level = %s multiplier %d, want diamond/15000",
|
||||
summary.LevelCode,
|
||||
summary.PointsMultiplierBps,
|
||||
)
|
||||
}
|
||||
if summary.Levels[2].DiscountBps != 9800 || summary.Levels[2].DepositFreeQuotaCent != 100_000 {
|
||||
t.Fatalf("diamond rules = %+v", summary.Levels[2])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user