3 Commits

Author SHA1 Message Date
  guzeng d5042d59db 修复 3 years ago
  guzeng 15356523bc 修复 3 years ago
  guzeng a7ecf9670b 修复 3 years ago
2 changed files with 25 additions and 25 deletions
Split View
  1. +23
    -23
      commission.go
  2. +2
    -2
      order_status.go

+ 23
- 23
commission.go View File

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


+ 2
- 2
order_status.go View File

@ -96,8 +96,8 @@ func GetOrderStatusText(key string) (text string) {
* 2021/01/28
*/
func GetOrderStatusDescByFlag(flag string) (text string) {
status := GetStatusText(flag)
return GetStatusDesc(status)
status := GetOrderStatusText(flag)
return GetOrderStatusDesc(status)
}
/**


Loading…
Cancel
Save