修复平台代管订单流程
This commit is contained in:
@@ -233,6 +233,42 @@ func TestCalculateCheckoutSettlementUsesExplicitRatiosForActualConsume(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalculateCheckoutSettlementCapsFullUseRatioRounding(t *testing.T) {
|
||||
// 发布量刚好用完时,比例换算的四舍五入不能把线下待打款抬高。
|
||||
order := model.RentalOrder{
|
||||
RentAmountCent: 37210,
|
||||
OwnerRentAmountCent: 34000,
|
||||
PlatformFeeCent: 3210,
|
||||
DepositAmountCent: 50000,
|
||||
AccountSnapshot: datatypes.JSON([]byte(`{
|
||||
"haf_coin_amount": 160000000,
|
||||
"asset_summary": {
|
||||
"price_breakdown": {
|
||||
"buyer_ratio": 43,
|
||||
"seller_ratio": 47,
|
||||
"buyer_coin_base_price": 372.1,
|
||||
"seller_coin_base_price": 340,
|
||||
"consumable_price": 0
|
||||
}
|
||||
}
|
||||
}`)),
|
||||
}
|
||||
|
||||
settlement := calculateCheckoutSettlement(order, 0, 160, 0)
|
||||
if settlement.ActualRentAmountCent != order.RentAmountCent {
|
||||
t.Fatalf("ActualRentAmountCent = %d, want %d", settlement.ActualRentAmountCent, order.RentAmountCent)
|
||||
}
|
||||
if settlement.OwnerRentIncomeCent != order.OwnerRentAmountCent {
|
||||
t.Fatalf("OwnerRentIncomeCent = %d, want %d", settlement.OwnerRentIncomeCent, order.OwnerRentAmountCent)
|
||||
}
|
||||
if settlement.PlatformFeeCent != order.PlatformFeeCent {
|
||||
t.Fatalf("PlatformFeeCent = %d, want %d", settlement.PlatformFeeCent, order.PlatformFeeCent)
|
||||
}
|
||||
if settlement.OvershootAmountCent != 0 {
|
||||
t.Fatalf("OvershootAmountCent = %d, want 0", settlement.OvershootAmountCent)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalculateDepositWaiverUsesSharedRemainingQuota(t *testing.T) {
|
||||
paid, waived := calculateDepositWaiver(500, 300, 0)
|
||||
if paid != 200 || waived != 300 {
|
||||
|
||||
Reference in New Issue
Block a user