feat(distribution): 收口账号同步与支付配置并优化结算

This commit is contained in:
yml2213
2026-10-30 16:03:30 +08:00
parent d37cbad323
commit 81a19431fa
11 changed files with 1122 additions and 26 deletions
@@ -66,3 +66,37 @@ func TestBuildOrderPricingUsesCentBreakdown(t *testing.T) {
t.Fatalf("OwnerPureCoinAmountCent = %d, want 23315", pricing.OwnerPureCoinAmountCent)
}
}
func TestCalculateCheckoutSettlementPrefersRatioBPS(t *testing.T) {
// bps 必须优先于旧 float 比例:buyer 1:40、seller 1:45,消耗 180M。
order := model.RentalOrder{
RentAmountCent: 25000,
OwnerRentAmountCent: 22222,
DepositAmountCent: 50000,
AccountSnapshot: datatypes.JSON([]byte(`{
"haf_coin_amount": 100000000,
"asset_summary": {
"price_breakdown": {
"buyer_ratio": 1,
"seller_ratio": 1,
"buyer_ratio_bps": 400000,
"seller_ratio_bps": 450000,
"buyer_coin_base_price": 250,
"seller_coin_base_price": 222.22,
"consumable_price": 0
}
}
}`)),
}
settlement := calculateCheckoutSettlement(order, 0, 180, 0)
if settlement.ActualRentAmountCent != 45000 {
t.Fatalf("ActualRentAmountCent = %d, want 45000", settlement.ActualRentAmountCent)
}
if settlement.OwnerRentIncomeCent != 40000 {
t.Fatalf("OwnerRentIncomeCent = %d, want 40000", settlement.OwnerRentIncomeCent)
}
if settlement.PlatformFeeCent != 5000 {
t.Fatalf("PlatformFeeCent = %d, want 5000", settlement.PlatformFeeCent)
}
}