作者 tangxvhui

更新

... ... @@ -99,27 +99,34 @@ func (order *OrderBase) Compute() error {
partnerBonusExpense := decimal.NewFromFloat(0)
//统计所以货品的值
for i := range order.Goods {
planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
planPartnerBonus = planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
planOrderAmount = planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
planOrderCount += order.Goods[i].PlanGoodNumber
//调整值 非负值得情况
goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount)
if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
//调整值非负值得情况
hasUseOrderAmount = true
useOrderAmount.Add(goodUseAmount)
useOrderAmount = useOrderAmount.Add(goodUseAmount)
} else {
useOrderAmount = useOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
}
goodUsePartnerBonus := decimal.NewFromFloat(order.Goods[i].GoodCompute.UsePartnerBonus)
if goodUsePartnerBonus.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
hasUsePartnerBonus = true
usePartnerBonus.Add(goodUsePartnerBonus)
usePartnerBonus = usePartnerBonus.Add(goodUsePartnerBonus)
} else {
usePartnerBonus = usePartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
}
if order.Goods[i].UseGoodNumber >= 0 {
HasUseOrderCount = true
useOrderCount += order.Goods[i].UseGoodNumber
} else {
useOrderCount += order.Goods[i].PlanGoodNumber
}
partnerBonusHas.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusHas))
partnerBonusNot.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusNot))
partnerBonusExpense.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusExpense))
partnerBonusHas = partnerBonusHas.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusHas))
partnerBonusNot = partnerBonusNot.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusNot))
partnerBonusExpense = partnerBonusExpense.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusExpense))
}
//汇总赋值
order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).Float64()
... ... @@ -128,6 +135,7 @@ func (order *OrderBase) Compute() error {
order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).Float64()
order.OrderCompute.PlanOrderCount = planOrderCount
if hasUsePartnerBonus {
order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
} else {
... ... @@ -135,8 +143,11 @@ 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()
} else {
order.OrderCompute.UseOrderAmount = -1
order.OrderCompute.SalesmanBonus, _ = planOrderAmount.Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).Round(2).Float64()
}
if HasUseOrderCount {
order.OrderCompute.UseOrderCount = useOrderCount
... ...
... ... @@ -135,7 +135,7 @@ func NewOrderGood() OrderGood {
//Compute 数据汇总核算
func (good *OrderGood) Compute() error {
price := decimal.NewFromInt(int64(good.PlanGoodNumber))
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
... ...