...
|
...
|
@@ -86,18 +86,24 @@ func (waitPay OrderGoodBonusWaitPay) WartPayPartnerBonus(good *OrderGood) error |
|
|
good.GoodCompute.PartnerBonusHas = 0
|
|
|
//初始状态为待支付时 ,合伙人未收分红等于合伙人应收分红(或者调整的)
|
|
|
if good.UseGoodNumber < 0 {
|
|
|
//数量没有调整,未收等于预计应收分红
|
|
|
good.GoodCompute.PartnerBonusNot = good.GoodCompute.PlanPartnerBonus
|
|
|
} else {
|
|
|
//数量有调整,未收等于调整后的应收分红
|
|
|
good.GoodCompute.PartnerBonusNot = good.GoodCompute.UsePartnerBonus
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (waitPay OrderGoodBonusWaitPay) PayPartnerBonus(good *OrderGood) error {
|
|
|
//待支付状态转支付时 ,合伙人已收收分红等于合伙人应收分红(或者调整的)
|
|
|
if good.GoodCompute.UsePartnerBonus < 0 {
|
|
|
//待支付状态转支付时
|
|
|
//合伙人已收收分红等于合伙人应收分红(或者调整的)
|
|
|
//计算已支付
|
|
|
if good.UseGoodNumber < 0 {
|
|
|
//数量没有调整,已收等于预计应收分红
|
|
|
good.GoodCompute.PartnerBonusHas = good.GoodCompute.PlanPartnerBonus
|
|
|
} else {
|
|
|
//数量有调整,已收等于调整后的应收分红
|
|
|
good.GoodCompute.PartnerBonusHas = good.GoodCompute.UsePartnerBonus
|
|
|
}
|
|
|
good.GoodCompute.PartnerBonusExpense = 0
|
...
|
...
|
@@ -111,6 +117,7 @@ func (hasPay OrderGoodBonusHasPay) PayPartnerBonus(good *OrderGood) error { |
|
|
//计算分红支出
|
|
|
//分红支出=应收分红(有出现调整,则取调整后的应收分红)和已收分红的差额
|
|
|
if good.UseGoodNumber >= 0 {
|
|
|
//有数量调整,分红支出等于 已支付分红-调整后的已收分红
|
|
|
good.GoodCompute.PartnerBonusExpense = good.GoodCompute.PartnerBonusHas - good.GoodCompute.UsePartnerBonus
|
|
|
}
|
|
|
return nil
|
...
|
...
|
@@ -135,11 +142,12 @@ func NewOrderGood() OrderGood { |
|
|
|
|
|
//Compute 数据汇总核算
|
|
|
func (good *OrderGood) Compute() error {
|
|
|
//计算预计货品总值
|
|
|
//计算预计合伙人分红
|
|
|
price := decimal.NewFromFloat(good.Price)
|
|
|
planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber
|
|
|
//price*useGoodNumber
|
|
|
planPartnerBonus := planamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)) //price*planGoodNumber*PartnerBonusPercent
|
|
|
|
|
|
good.GoodCompute.PlanAmount, _ = planamount.Round(2).Float64()
|
|
|
good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
|
|
|
if good.UseGoodNumber < 0 {
|
...
|
...
|
@@ -147,6 +155,8 @@ func (good *OrderGood) Compute() error { |
|
|
good.GoodCompute.UsePartnerBonus = -1
|
|
|
good.GoodCompute.UseAmount = -1
|
|
|
} else {
|
|
|
//计算调整后的货品总值
|
|
|
//计算调整后的合伙人分红
|
|
|
useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber
|
|
|
usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)) //price*useGoodNumber*PartnerBonusPercent
|
|
|
good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
|
...
|
...
|
|