|
@@ -99,27 +99,34 @@ func (order *OrderBase) Compute() error { |
|
@@ -99,27 +99,34 @@ func (order *OrderBase) Compute() error { |
99
|
partnerBonusExpense := decimal.NewFromFloat(0)
|
99
|
partnerBonusExpense := decimal.NewFromFloat(0)
|
100
|
//统计所以货品的值
|
100
|
//统计所以货品的值
|
101
|
for i := range order.Goods {
|
101
|
for i := range order.Goods {
|
102
|
- planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
|
|
|
103
|
- planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
|
102
|
+ planPartnerBonus = planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
|
|
|
103
|
+ planOrderAmount = planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
|
104
|
planOrderCount += order.Goods[i].PlanGoodNumber
|
104
|
planOrderCount += order.Goods[i].PlanGoodNumber
|
105
|
- //调整值 非负值得情况
|
105
|
+
|
106
|
goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount)
|
106
|
goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount)
|
107
|
if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
|
107
|
if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
|
|
|
108
|
+ //调整值非负值得情况
|
108
|
hasUseOrderAmount = true
|
109
|
hasUseOrderAmount = true
|
109
|
- useOrderAmount.Add(goodUseAmount)
|
110
|
+ useOrderAmount = useOrderAmount.Add(goodUseAmount)
|
|
|
111
|
+ } else {
|
|
|
112
|
+ useOrderAmount = useOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
|
110
|
}
|
113
|
}
|
111
|
goodUsePartnerBonus := decimal.NewFromFloat(order.Goods[i].GoodCompute.UsePartnerBonus)
|
114
|
goodUsePartnerBonus := decimal.NewFromFloat(order.Goods[i].GoodCompute.UsePartnerBonus)
|
112
|
if goodUsePartnerBonus.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
|
115
|
if goodUsePartnerBonus.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
|
113
|
hasUsePartnerBonus = true
|
116
|
hasUsePartnerBonus = true
|
114
|
- usePartnerBonus.Add(goodUsePartnerBonus)
|
117
|
+ usePartnerBonus = usePartnerBonus.Add(goodUsePartnerBonus)
|
|
|
118
|
+ } else {
|
|
|
119
|
+ usePartnerBonus = usePartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
|
115
|
}
|
120
|
}
|
116
|
if order.Goods[i].UseGoodNumber >= 0 {
|
121
|
if order.Goods[i].UseGoodNumber >= 0 {
|
117
|
HasUseOrderCount = true
|
122
|
HasUseOrderCount = true
|
118
|
useOrderCount += order.Goods[i].UseGoodNumber
|
123
|
useOrderCount += order.Goods[i].UseGoodNumber
|
|
|
124
|
+ } else {
|
|
|
125
|
+ useOrderCount += order.Goods[i].PlanGoodNumber
|
119
|
}
|
126
|
}
|
120
|
- partnerBonusHas.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusHas))
|
|
|
121
|
- partnerBonusNot.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusNot))
|
|
|
122
|
- partnerBonusExpense.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusExpense))
|
127
|
+ partnerBonusHas = partnerBonusHas.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusHas))
|
|
|
128
|
+ partnerBonusNot = partnerBonusNot.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusNot))
|
|
|
129
|
+ partnerBonusExpense = partnerBonusExpense.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusExpense))
|
123
|
}
|
130
|
}
|
124
|
//汇总赋值
|
131
|
//汇总赋值
|
125
|
order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).Float64()
|
132
|
order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).Float64()
|
|
@@ -128,6 +135,7 @@ func (order *OrderBase) Compute() error { |
|
@@ -128,6 +135,7 @@ func (order *OrderBase) Compute() error { |
128
|
order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
|
135
|
order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
|
129
|
order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).Float64()
|
136
|
order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).Float64()
|
130
|
order.OrderCompute.PlanOrderCount = planOrderCount
|
137
|
order.OrderCompute.PlanOrderCount = planOrderCount
|
|
|
138
|
+
|
131
|
if hasUsePartnerBonus {
|
139
|
if hasUsePartnerBonus {
|
132
|
order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
|
140
|
order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
|
133
|
} else {
|
141
|
} else {
|
|
@@ -135,8 +143,11 @@ func (order *OrderBase) Compute() error { |
|
@@ -135,8 +143,11 @@ func (order *OrderBase) Compute() error { |
135
|
}
|
143
|
}
|
136
|
if hasUseOrderAmount {
|
144
|
if hasUseOrderAmount {
|
137
|
order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).Float64()
|
145
|
order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).Float64()
|
|
|
146
|
+ //计算业务员的抽成
|
|
|
147
|
+ order.OrderCompute.SalesmanBonus, _ = useOrderAmount.Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).Round(2).Float64()
|
138
|
} else {
|
148
|
} else {
|
139
|
order.OrderCompute.UseOrderAmount = -1
|
149
|
order.OrderCompute.UseOrderAmount = -1
|
|
|
150
|
+ order.OrderCompute.SalesmanBonus, _ = planOrderAmount.Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).Round(2).Float64()
|
140
|
}
|
151
|
}
|
141
|
if HasUseOrderCount {
|
152
|
if HasUseOrderCount {
|
142
|
order.OrderCompute.UseOrderCount = useOrderCount
|
153
|
order.OrderCompute.UseOrderCount = useOrderCount
|