fix(distribution): 分成改为分主站提价利润,分站自主提价溢价全额归卖方
- 文档:升级至 v0.7,固化号主保底、主站提价利润分账(35/40/25)与分站加价溢价独享逻辑 - 定价:修正货架兑换比例调价方向为调减比例提价(site_ratio = base_ratio - delta) - 分账:分成基数剔除号主成本与分站加价,提价利润按规则切分,分站自主加价溢价 100% 归卖出方 - 前端:更新分销后台提价说明文案,提示调减比例提高售价且溢价归本站
This commit is contained in:
@@ -146,7 +146,7 @@ func CalculateSettlement(rule Rule, input SettlementInput) (SettlementResult, er
|
||||
}
|
||||
netPaid := input.GrossPaidAmountCent - input.RefundAmountCent
|
||||
paymentFee := roundHalfUp(float64(netPaid) * float64(rule.PaymentFeeBPS) / 10000)
|
||||
profit := netPaid - input.OwnerRentAmountCent - paymentFee
|
||||
profit := netPaid - input.OwnerRentAmountCent - input.MarkupAmountCent - paymentFee
|
||||
if profit < 0 {
|
||||
profit = 0
|
||||
}
|
||||
@@ -212,8 +212,9 @@ type PartySplit struct {
|
||||
AmountCent int64
|
||||
}
|
||||
|
||||
// SplitSettlement 按百分数切利润:收号 35%、卖出 40%。服务费 25% 记在财务快照,不并进参与方。
|
||||
func SplitSettlement(rule Rule, profitCent int64) []PartySplit {
|
||||
// SplitSettlement 按百分数切主站提价利润(收号 35%、卖出 40%),并将分站自主加价溢价(markupCent)100% 独立全额归入卖出方。
|
||||
// 平台服务费 25% 记在财务快照,不并进参与方。
|
||||
func SplitSettlement(rule Rule, profitCent int64, markupCent int64) []PartySplit {
|
||||
roles := []struct {
|
||||
role string
|
||||
ratio float64
|
||||
@@ -242,19 +243,34 @@ func SplitSettlement(rule Rule, profitCent int64) []PartySplit {
|
||||
amount := roundHalfUp(float64(profitCent) * item.ratio / 100)
|
||||
splits = append(splits, PartySplit{PartyRole: item.role, Ratio: item.ratio, AmountCent: maxInt64(amount, 0)})
|
||||
}
|
||||
if markupCent > 0 {
|
||||
sellerRole := "distributor_sell"
|
||||
switch rule.Mode {
|
||||
case ModeTwoPartyDistributorReceive:
|
||||
sellerRole = "platform_sell"
|
||||
case ModeThreeParty:
|
||||
sellerRole = "distributor_b"
|
||||
}
|
||||
for i := range splits {
|
||||
if splits[i].PartyRole == sellerRole {
|
||||
splits[i].AmountCent += markupCent
|
||||
}
|
||||
}
|
||||
}
|
||||
return splits
|
||||
}
|
||||
|
||||
// SplitRemainderCent 返回利润扣除各方分成后的剩余(未扣服务费)。
|
||||
func SplitRemainderCent(splitBase int64, splits []PartySplit) int64 {
|
||||
// SplitRemainderCent 返回主站提价利润扣除各方提价分成后的剩余(未扣服务费)。
|
||||
func SplitRemainderCent(splitBase int64, splits []PartySplit, markupCent int64) int64 {
|
||||
sum := int64(0)
|
||||
for _, item := range splits {
|
||||
sum += item.AmountCent
|
||||
}
|
||||
return splitBase - sum
|
||||
profitSplitSum := sum - markupCent
|
||||
return splitBase - profitSplitSum
|
||||
}
|
||||
|
||||
// SplitRoundingCent 返回利润扣完收号、卖出和服务费后的四舍五入尾差。
|
||||
func SplitRoundingCent(profitCent, serviceFeeCent int64, splits []PartySplit) int64 {
|
||||
return SplitRemainderCent(profitCent, splits) - serviceFeeCent
|
||||
// SplitRoundingCent 返回提价利润扣完收号、卖出和服务费后的四舍五入尾差。
|
||||
func SplitRoundingCent(profitCent, serviceFeeCent, markupCent int64, splits []PartySplit) int64 {
|
||||
return SplitRemainderCent(profitCent, splits, markupCent) - serviceFeeCent
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user