作者 tangxvhui

更新

... ... @@ -143,31 +143,31 @@ func (order *OrderBase) Compute() error {
partnerBonusExpense = partnerBonusExpense.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PartnerBonusExpense))
}
//汇总赋值
order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).Float64()
order.OrderCompute.PartnerBonusHas, _ = partnerBonusHas.Round(2).Float64()
order.OrderCompute.PartnerBonusNot, _ = partnerBonusNot.Round(2).Float64()
order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).Float64()
order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).BigFloat().Float64()
order.OrderCompute.PartnerBonusHas, _ = partnerBonusHas.Round(2).BigFloat().Float64()
order.OrderCompute.PartnerBonusNot, _ = partnerBonusNot.Round(2).BigFloat().Float64()
order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).BigFloat().Float64()
order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).BigFloat().Float64()
order.OrderCompute.PlanOrderCount = planOrderCount
if hasUsePartnerBonus {
order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).BigFloat().Float64()
} else {
order.OrderCompute.UsePartnerBonus = -1
}
if hasUseOrderAmount {
order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).Float64()
order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).BigFloat().Float64()
//计算业务员的抽成
order.OrderCompute.SalesmanBonus, _ = useOrderAmount.
Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).
Div(decimal.NewFromInt(100)).
Round(2).Float64()
Round(2).BigFloat().Float64()
} else {
order.OrderCompute.UseOrderAmount = -1
order.OrderCompute.SalesmanBonus, _ = planOrderAmount.
Mul(decimal.NewFromFloat(order.SalesmanBonusPercent)).
Div(decimal.NewFromInt(100)).
Round(2).Float64()
Round(2).BigFloat().Float64()
}
if HasUseOrderCount {
order.OrderCompute.UseOrderCount = useOrderCount
... ...
... ... @@ -151,8 +151,8 @@ func (good *OrderGood) Compute() error {
planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber
//price*useGoodNumber
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()
good.GoodCompute.PlanAmount, _ = planamount.Round(2).BigFloat().Float64()
good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).BigFloat().Float64()
if good.UseGoodNumber < 0 {
//没有出现数量调整
good.GoodCompute.UsePartnerBonus = -1
... ... @@ -162,8 +162,8 @@ func (good *OrderGood) Compute() error {
//计算调整后的合伙人分红
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()
good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).BigFloat().Float64()
good.GoodCompute.UseAmount, _ = useamount.Round(2).BigFloat().Float64()
}
return nil
... ...
... ... @@ -235,7 +235,7 @@ func (postData postOrderGood) Valid() error {
return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例超额")
}
partnerRatio := fmt.Sprint(postData.PartnerRatio)
regexpStr := `^(100|[1-9]\d|\d)(.\d{1,2})$`
regexpStr := `^(100|[1-9]\d|\d)(.\d{1,2})?$`
ok := regexp.MustCompile(regexpStr).MatchString(partnerRatio)
if !ok {
return lib.ThrowError(lib.ARG_ERROR, "合伙人分红比例精确到小数点2位")
... ...