- 修复CaculateSkuPrice四舍五入的bug

This commit is contained in:
gazebo
2019-09-19 16:56:38 +08:00
parent 72f9852d42
commit a74c9230f1
2 changed files with 45 additions and 7 deletions

View File

@@ -211,16 +211,16 @@ func CaculateSkuPrice(unitPrice int, specQuality float32, specUnit string, skuNa
return unitPrice
}
specQuality2 := RegularizeSkuQuality(specQuality, specUnit)
price := int(math.Round(float64(unitPrice * specQuality2 / model.SpecialSpecQuality)))
floatPrice := float64(unitPrice) * float64(specQuality2) / float64(model.SpecialSpecQuality)
// if specQuality2 < 250 {
// price = price * 110 / 100
// floatPrice = floatPrice * 110 / 100
// } else if specQuality2 < 500 {
// price = price * 105 / 100
// floatPrice = floatPrice * 105 / 100
// }
if price <= 0 {
price = 1
if floatPrice <= 1 {
floatPrice = 1
}
return price
return int(math.Round(floatPrice))
}
// 计算SKU标准价格CaculateSkuPrice的逆过程
@@ -268,7 +268,7 @@ func CaculateSkuPriceFromVendor(vendorPrice, percentage, catPercentage int) int
catPercentage = 100
}
percentage = percentage * catPercentage / 100
price := int(math.Round(float64(vendorPrice * 100 / percentage)))
price := int(math.Round(float64(vendorPrice) * 100 / float64(percentage)))
if price < 0 {
price = 0
}