|
@ -85,16 +85,16 @@ func DistributionPrice(business map[string]string, productSpecialPrice []map[str |
|
|
switch { |
|
|
switch { |
|
|
case strings.Contains(formula, "+"): |
|
|
case strings.Contains(formula, "+"): |
|
|
price = strings.Split(formula, "+") |
|
|
price = strings.Split(formula, "+") |
|
|
result = FloatAdd(price[0], price[1]) |
|
|
|
|
|
|
|
|
result = helper.FloatAdd(price[0], price[1]) |
|
|
case strings.Contains(formula, "-"): |
|
|
case strings.Contains(formula, "-"): |
|
|
price = strings.Split(formula, "-") |
|
|
price = strings.Split(formula, "-") |
|
|
result = FloatSub(price[0], price[1]) |
|
|
|
|
|
|
|
|
result = helper.FloatSub(price[0], price[1]) |
|
|
case strings.Contains(formula, "*"): |
|
|
case strings.Contains(formula, "*"): |
|
|
price = strings.Split(formula, "*") |
|
|
price = strings.Split(formula, "*") |
|
|
result = FloatMul(price[0], price[1], 2) |
|
|
|
|
|
|
|
|
result = helper.FloatMul(price[0], price[1], 2) |
|
|
case strings.Contains(formula, "/"): |
|
|
case strings.Contains(formula, "/"): |
|
|
price = strings.Split(formula, "/") |
|
|
price = strings.Split(formula, "/") |
|
|
result = FloatQuo(price[0], price[1], 2) |
|
|
|
|
|
|
|
|
result = helper.FloatQuo(price[0], price[1], 2) |
|
|
default: |
|
|
default: |
|
|
//使用固定价格或者使用基础分销价
|
|
|
//使用固定价格或者使用基础分销价
|
|
|
if formula != "" { |
|
|
if formula != "" { |
|
@ -109,7 +109,7 @@ func DistributionPrice(business map[string]string, productSpecialPrice []map[str |
|
|
return 0, errors.New("商品价格错误") |
|
|
return 0, errors.New("商品价格错误") |
|
|
} |
|
|
} |
|
|
price = strings.Split(percent_age, ":") |
|
|
price = strings.Split(percent_age, ":") |
|
|
totalCommission := FloatSub(productPrice, distributionPrice) //总佣金
|
|
|
|
|
|
|
|
|
totalCommission := helper.FloatSub(productPrice, distributionPrice) //总佣金
|
|
|
|
|
|
|
|
|
if totalCommission <= 0 { |
|
|
if totalCommission <= 0 { |
|
|
return helper.ToFloat64(productPrice) //总佣金为负,返回商品原价
|
|
|
return helper.ToFloat64(productPrice) //总佣金为负,返回商品原价
|
|
@ -120,7 +120,7 @@ func DistributionPrice(business map[string]string, productSpecialPrice []map[str |
|
|
var totalPercent, cent, commission float64 //总分配份数,分销比例,获得的佣金
|
|
|
var totalPercent, cent, commission float64 //总分配份数,分销比例,获得的佣金
|
|
|
switch level_count { |
|
|
switch level_count { |
|
|
case 3: |
|
|
case 3: |
|
|
totalPercent = FloatAdd(price[0], price[1], price[2]) |
|
|
|
|
|
|
|
|
totalPercent = helper.FloatAdd(price[0], price[1], price[2]) |
|
|
if totalPercent <= 0 { |
|
|
if totalPercent <= 0 { |
|
|
result = distribution_price_float //佣金分配比例为0,返回基础分销价
|
|
|
result = distribution_price_float //佣金分配比例为0,返回基础分销价
|
|
|
} else { |
|
|
} else { |
|
@ -130,17 +130,17 @@ func DistributionPrice(business map[string]string, productSpecialPrice []map[str |
|
|
cent = 1 //分销比例
|
|
|
cent = 1 //分销比例
|
|
|
case "2": |
|
|
case "2": |
|
|
//二级分销商得到所有佣金
|
|
|
//二级分销商得到所有佣金
|
|
|
cent = FloatQuo(FloatAdd(price[0], price[1]), totalPercent) //分销比例
|
|
|
|
|
|
|
|
|
cent = helper.FloatQuo(helper.FloatAdd(price[0], price[1]), totalPercent) //分销比例
|
|
|
case "0", "3": |
|
|
case "0", "3": |
|
|
//三级或无级别分销商得到所有佣金
|
|
|
//三级或无级别分销商得到所有佣金
|
|
|
cent = FloatQuo(price[0], totalPercent) //分销比例
|
|
|
|
|
|
|
|
|
cent = helper.FloatQuo(price[0], totalPercent) //分销比例
|
|
|
} |
|
|
} |
|
|
commission = FloatMul(totalCommission, cent, 2) |
|
|
|
|
|
|
|
|
commission = helper.FloatMul(totalCommission, cent, 2) |
|
|
|
|
|
|
|
|
result = FloatSub(productPrice, commission) //分销价=商品价-佣金
|
|
|
|
|
|
|
|
|
result = helper.FloatSub(productPrice, commission) //分销价=商品价-佣金
|
|
|
} |
|
|
} |
|
|
case 2: |
|
|
case 2: |
|
|
totalPercent = FloatAdd(price[0], price[1]) |
|
|
|
|
|
|
|
|
totalPercent = helper.FloatAdd(price[0], price[1]) |
|
|
if totalPercent <= 0 { |
|
|
if totalPercent <= 0 { |
|
|
result = distribution_price_float //佣金分配比例为0,返回基础分销价
|
|
|
result = distribution_price_float //佣金分配比例为0,返回基础分销价
|
|
|
} else { |
|
|
} else { |
|
@ -150,10 +150,10 @@ func DistributionPrice(business map[string]string, productSpecialPrice []map[str |
|
|
cent = 1 //分销比例
|
|
|
cent = 1 //分销比例
|
|
|
case "0", "2": |
|
|
case "0", "2": |
|
|
//二级或无级别分销商得到所有佣金
|
|
|
//二级或无级别分销商得到所有佣金
|
|
|
cent = FloatQuo(price[0], totalPercent) //分销比例
|
|
|
|
|
|
|
|
|
cent = helper.FloatQuo(price[0], totalPercent) //分销比例
|
|
|
} |
|
|
} |
|
|
commission = FloatMul(totalCommission, cent, 2) |
|
|
|
|
|
result = FloatSub(productPrice, commission) //分销价=商品价-佣金
|
|
|
|
|
|
|
|
|
commission = helper.FloatMul(totalCommission, cent, 2) |
|
|
|
|
|
result = helper.FloatSub(productPrice, commission) //分销价=商品价-佣金
|
|
|
} |
|
|
} |
|
|
case 1: |
|
|
case 1: |
|
|
//只有一级
|
|
|
//只有一级
|
|
@ -214,16 +214,16 @@ func VipPrice(productSpecialPrice []map[string]string, productPrice interface{}) |
|
|
switch { |
|
|
switch { |
|
|
case strings.Contains(formula, "+"): |
|
|
case strings.Contains(formula, "+"): |
|
|
price = strings.Split(formula, "+") |
|
|
price = strings.Split(formula, "+") |
|
|
result = FloatAdd(price[0], price[1]) |
|
|
|
|
|
|
|
|
result = helper.FloatAdd(price[0], price[1]) |
|
|
case strings.Contains(formula, "-"): |
|
|
case strings.Contains(formula, "-"): |
|
|
price = strings.Split(formula, "-") |
|
|
price = strings.Split(formula, "-") |
|
|
result = FloatSub(price[0], price[1]) |
|
|
|
|
|
|
|
|
result = helper.FloatSub(price[0], price[1]) |
|
|
case strings.Contains(formula, "*"): |
|
|
case strings.Contains(formula, "*"): |
|
|
price = strings.Split(formula, "*") |
|
|
price = strings.Split(formula, "*") |
|
|
result = FloatMul(price[0], price[1], 2) |
|
|
|
|
|
|
|
|
result = helper.FloatMul(price[0], price[1], 2) |
|
|
case strings.Contains(formula, "/"): |
|
|
case strings.Contains(formula, "/"): |
|
|
price = strings.Split(formula, "/") |
|
|
price = strings.Split(formula, "/") |
|
|
result = FloatQuo(price[0], price[1], 2) |
|
|
|
|
|
|
|
|
result = helper.FloatQuo(price[0], price[1], 2) |
|
|
default: |
|
|
default: |
|
|
result = product_price_float |
|
|
result = product_price_float |
|
|
} |
|
|
} |
|
|