正在显示
3 个修改的文件
包含
14 行增加
和
14 行删除
@@ -143,31 +143,31 @@ func (order *OrderBase) Compute() error { | @@ -143,31 +143,31 @@ func (order *OrderBase) Compute() error { | ||
143 | partnerBonusExpense = partnerBonusExpense.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusExpense)) | 143 | partnerBonusExpense = partnerBonusExpense.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusExpense)) |
144 | } | 144 | } |
145 | //汇总赋值 | 145 | //汇总赋值 |
146 | - order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).Float64() | ||
147 | - order.OrderCompute.PartnerBonusHas, _ = partnerBonusHas.Round(2).Float64() | ||
148 | - order.OrderCompute.PartnerBonusNot, _ = partnerBonusNot.Round(2).Float64() | ||
149 | - order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64() | ||
150 | - order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).Float64() | 146 | + order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).BigFloat().Float64() |
147 | + order.OrderCompute.PartnerBonusHas, _ = partnerBonusHas.Round(2).BigFloat().Float64() | ||
148 | + order.OrderCompute.PartnerBonusNot, _ = partnerBonusNot.Round(2).BigFloat().Float64() | ||
149 | + order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).BigFloat().Float64() | ||
150 | + order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).BigFloat().Float64() | ||
151 | order.OrderCompute.PlanOrderCount = planOrderCount | 151 | order.OrderCompute.PlanOrderCount = planOrderCount |
152 | 152 | ||
153 | if hasUsePartnerBonus { | 153 | if hasUsePartnerBonus { |
154 | - order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64() | 154 | + order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).BigFloat().Float64() |
155 | } else { | 155 | } else { |
156 | order.OrderCompute.UsePartnerBonus = -1 | 156 | order.OrderCompute.UsePartnerBonus = -1 |
157 | } | 157 | } |
158 | if hasUseOrderAmount { | 158 | if hasUseOrderAmount { |
159 | - order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).Float64() | 159 | + order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).BigFloat().Float64() |
160 | //计算业务员的抽成 | 160 | //计算业务员的抽成 |
161 | order.OrderCompute.SalesmanBonus, _ = useOrderAmount. | 161 | order.OrderCompute.SalesmanBonus, _ = useOrderAmount. |
162 | Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)). | 162 | Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)). |
163 | Div(decimal.NewFromInt(100)). | 163 | Div(decimal.NewFromInt(100)). |
164 | - Round(2).Float64() | 164 | + Round(2).BigFloat().Float64() |
165 | } else { | 165 | } else { |
166 | order.OrderCompute.UseOrderAmount = -1 | 166 | order.OrderCompute.UseOrderAmount = -1 |
167 | order.OrderCompute.SalesmanBonus, _ = planOrderAmount. | 167 | order.OrderCompute.SalesmanBonus, _ = planOrderAmount. |
168 | Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)). | 168 | Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)). |
169 | Div(decimal.NewFromInt(100)). | 169 | Div(decimal.NewFromInt(100)). |
170 | - Round(2).Float64() | 170 | + Round(2).BigFloat().Float64() |
171 | } | 171 | } |
172 | if HasUseOrderCount { | 172 | if HasUseOrderCount { |
173 | order.OrderCompute.UseOrderCount = useOrderCount | 173 | order.OrderCompute.UseOrderCount = useOrderCount |
@@ -151,8 +151,8 @@ func (good *OrderGood) Compute() error { | @@ -151,8 +151,8 @@ func (good *OrderGood) Compute() error { | ||
151 | planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber | 151 | planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber |
152 | //price*useGoodNumber | 152 | //price*useGoodNumber |
153 | planPartnerBonus := planamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*planGoodNumber*PartnerBonusPercent | 153 | planPartnerBonus := planamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*planGoodNumber*PartnerBonusPercent |
154 | - good.GoodCompute.PlanAmount, _ = planamount.Round(2).Float64() | ||
155 | - good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64() | 154 | + good.GoodCompute.PlanAmount, _ = planamount.Round(2).BigFloat().Float64() |
155 | + good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).BigFloat().Float64() | ||
156 | if good.UseGoodNumber < 0 { | 156 | if good.UseGoodNumber < 0 { |
157 | //没有出现数量调整 | 157 | //没有出现数量调整 |
158 | good.GoodCompute.UsePartnerBonus = -1 | 158 | good.GoodCompute.UsePartnerBonus = -1 |
@@ -162,8 +162,8 @@ func (good *OrderGood) Compute() error { | @@ -162,8 +162,8 @@ func (good *OrderGood) Compute() error { | ||
162 | //计算调整后的合伙人分红 | 162 | //计算调整后的合伙人分红 |
163 | useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber | 163 | useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber |
164 | usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*useGoodNumber*PartnerBonusPercent | 164 | usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*useGoodNumber*PartnerBonusPercent |
165 | - good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64() | ||
166 | - good.GoodCompute.UseAmount, _ = useamount.Round(2).Float64() | 165 | + good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).BigFloat().Float64() |
166 | + good.GoodCompute.UseAmount, _ = useamount.Round(2).BigFloat().Float64() | ||
167 | } | 167 | } |
168 | 168 | ||
169 | return nil | 169 | return nil |
@@ -235,7 +235,7 @@ func (postData postOrderGood) Valid() error { | @@ -235,7 +235,7 @@ func (postData postOrderGood) Valid() error { | ||
235 | return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例超额") | 235 | return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例超额") |
236 | } | 236 | } |
237 | partnerRatio := fmt.Sprint(postData.PartnerRatio) | 237 | partnerRatio := fmt.Sprint(postData.PartnerRatio) |
238 | - regexpStr := `^(100|[1-9]\d|\d)(.\d{1,2})$` | 238 | + regexpStr := `^(100|[1-9]\d|\d)(.\d{1,2})?$` |
239 | ok := regexp.MustCompile(regexpStr).MatchString(partnerRatio) | 239 | ok := regexp.MustCompile(regexpStr).MatchString(partnerRatio) |
240 | if !ok { | 240 | if !ok { |
241 | return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例精确到小数点2位") | 241 | return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例精确到小数点2位") |
-
请 注册 或 登录 后发表评论