作者 tangxvhui

更新

... ... @@ -158,10 +158,16 @@ func (order *OrderBase) Compute() error {
if hasUseOrderAmount {
order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).Float64()
//计算业务员的抽成
order.OrderCompute.SalesmanBonus, _ = useOrderAmount.Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).Round(2).Float64()
order.OrderCompute.SalesmanBonus, _ = useOrderAmount.
Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).
Div(decimal.NewFromInt(100)).
Round(2).Float64()
} else {
order.OrderCompute.UseOrderAmount = -1
order.OrderCompute.SalesmanBonus, _ = planOrderAmount.Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).Round(2).Float64()
order.OrderCompute.SalesmanBonus, _ = planOrderAmount.
Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).
Div(decimal.NewFromInt(100)).
Round(2).Float64()
}
if HasUseOrderCount {
order.OrderCompute.UseOrderCount = useOrderCount
... ...
... ... @@ -150,7 +150,7 @@ 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
planPartnerBonus := planamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*planGoodNumber*PartnerBonusPercent
good.GoodCompute.PlanAmount, _ = planamount.Round(2).Float64()
good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
if good.UseGoodNumber < 0 {
... ... @@ -160,8 +160,8 @@ func (good *OrderGood) Compute() error {
} else {
//计算调整后的货品总值
//计算调整后的合伙人分红
useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber
usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)) //price*useGoodNumber*PartnerBonusPercent
useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber
usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*useGoodNumber*PartnerBonusPercent
good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
good.GoodCompute.UseAmount, _ = useamount.Round(2).Float64()
}
... ...