fix(distribution): 货架加价打通前台、下单与卖方分成

分站公开列表和详情展示当前货架加价;下单写入 base_price / shelf_markup / markup_site_id 快照并计入实付。
支付分账改用快照加价,不再误用 PlatformFeeCent;结账不退加价,事后改价不影响历史订单。
This commit is contained in:
yml2213
2026-09-08 17:07:17 +08:00
parent 8521bf4753
commit 96bc6a4db6
16 changed files with 417 additions and 42 deletions
@@ -348,8 +348,6 @@ func TestApplyPublicListingURLsHidesSourceChannel(t *testing.T) {
}
}
func uint64Pointer(value uint64) *uint64 {
return &value
}
@@ -703,7 +701,7 @@ func TestListPublicWithDistributionSiteCode(t *testing.T) {
site := model.DistributionSite{SiteCode: "site_alpha", SiteName: "分销A", Domain: "a.com", Status: "active", DisplayAccountEnabled: true}
db.Create(&site)
dsa := model.DistributionSiteAccount{SiteID: site.ID, AccountID: account1.ID, ListingID: l1.ID, DisplayStatus: "enabled"}
dsa := model.DistributionSiteAccount{SiteID: site.ID, AccountID: account1.ID, ListingID: l1.ID, DisplayStatus: "enabled", MarkupAmountCent: 10000}
db.Create(&dsa)
res, err := repo.ListPublic(context.Background(), PublicListQuery{
@@ -715,6 +713,24 @@ func TestListPublicWithDistributionSiteCode(t *testing.T) {
if len(res.Items) != 1 || res.Items[0].ListingNo != "L101" {
t.Fatalf("expected only L101, got %+v", res.Items)
}
if res.Items[0].PriceCent != 11000 {
t.Fatalf("expected public price 11000 with markup, got %d", res.Items[0].PriceCent)
}
detail, err := repo.FindPublic(context.Background(), l1.ID, "site_alpha")
if err != nil {
t.Fatalf("FindPublic err: %v", err)
}
if detail.PriceCent != 11000 {
t.Fatalf("expected detail price 11000 with markup, got %d", detail.PriceCent)
}
mainDetail, err := repo.FindPublic(context.Background(), l1.ID, "")
if err != nil {
t.Fatalf("FindPublic main err: %v", err)
}
if mainDetail.PriceCent != 1000 {
t.Fatalf("main site must keep original price, got %d", mainDetail.PriceCent)
}
allRes, err := repo.ListPublic(context.Background(), PublicListQuery{})
if err != nil {
@@ -946,5 +962,3 @@ func TestListMineSiteIsolation(t *testing.T) {
t.Fatalf("expected 2 listings, got %d", len(allItems))
}
}