价格包参数添加priceAdd

This commit is contained in:
gazebo
2019-11-11 09:20:14 +08:00
parent 6a37def14f
commit 83f9493352
5 changed files with 18 additions and 17 deletions

View File

@@ -245,29 +245,29 @@ func CaculateUnitPrice(skuPrice int, specQuality float32, specUnit string, skuNa
return unitPrice
}
func CaculateSkuVendorPrice(price, percentage int) (vendorPrice int) {
func CaculateSkuVendorPrice(price, percentage, priceAdd int) (vendorPrice int) {
if percentage <= 10 || percentage >= 400 {
percentage = 100
}
vendorPrice = int(math.Round(float64(price*percentage) / 100))
vendorPrice = int(math.Round(float64(price*percentage)/100)) + priceAdd
if vendorPrice < 1 {
vendorPrice = 1
}
return vendorPrice
}
func CaculateSkuPriceFromVendor(vendorPrice, percentage int) (price int) {
func CaculateSkuPriceFromVendor(vendorPrice, percentage, priceAdd int) (price int) {
if percentage <= 10 || percentage >= 400 {
percentage = 100
}
price = int(math.Round(float64(vendorPrice) * 100 / float64(percentage)))
price = int(math.Round(float64(vendorPrice-priceAdd) * 100 / float64(percentage)))
if price < 0 {
price = 0
}
return price
}
func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercentage int) (pricePercentage int) {
func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercentage int) (pricePercentage, priceAdd int) {
pricePercentage = defPricePercentage
if len(l) > 0 {
var lastItem *model.PricePercentageItem
@@ -279,26 +279,28 @@ func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercenta
}
if lastItem != nil {
pricePercentage = lastItem.PricePercentage
priceAdd = lastItem.PriceAdd
}
}
return pricePercentage
return pricePercentage, priceAdd
}
func GetPricePercentageByVendorPrice(l model.PricePercentagePack, vendorPrice int, defPricePercentage int) (pricePercentage int) {
func GetPricePercentageByVendorPrice(l model.PricePercentagePack, vendorPrice int, defPricePercentage int) (pricePercentage, priceAdd int) {
pricePercentage = defPricePercentage
if len(l) > 0 {
var lastItem *model.PricePercentageItem
for _, v := range l {
if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage) > vendorPrice {
if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage, v.PriceAdd) > vendorPrice {
break
}
lastItem = v
}
if lastItem != nil {
pricePercentage = lastItem.PricePercentage
priceAdd = lastItem.PriceAdd
}
}
return pricePercentage
return pricePercentage, priceAdd
}
func IsSkuSpecial(specQuality float32, specUnit string) bool {