CaculateJxPriceByPricePack

This commit is contained in:
gazebo
2020-02-07 14:20:24 +08:00
parent 1855af8757
commit fbdd8849f6
2 changed files with 64 additions and 3 deletions

View File

@@ -253,7 +253,7 @@ func CaculateUnitPrice(skuPrice int, specQuality float32, specUnit string, skuNa
}
func ConstrainPricePercentage(percentage int) int {
if percentage <= model.MinVendorPricePercentage || percentage >= model.MaxVendorPricePercentage {
if percentage < model.MinVendorPricePercentage || percentage > model.MaxVendorPricePercentage {
percentage = model.DefVendorPricePercentage
}
return percentage
@@ -271,8 +271,8 @@ func CaculateSkuVendorPrice(price, percentage, priceAdd int) (vendorPrice int) {
func CaculateSkuPriceFromVendor(vendorPrice, percentage, priceAdd int) (price int) {
percentage = ConstrainPricePercentage(percentage)
price = int(math.Round(float64(vendorPrice-priceAdd) * 100 / float64(percentage)))
if price < 0 {
price = 0
if price < 1 {
price = 1
}
return price
}
@@ -330,6 +330,12 @@ func CaculatePriceByPricePack(l model.PricePercentagePack, defPricePercentage, p
return CaculateSkuVendorPrice(price, pricePercentage, priceAdd)
}
func CaculateJxPriceByPricePack(l model.PricePercentagePack, defPricePercentage, vendorPrice int) (jxPrice int) {
pricePercentage, priceAdd := GetPricePercentageByVendorPrice(l, vendorPrice, defPricePercentage)
jxPrice = CaculateSkuPriceFromVendor(vendorPrice, pricePercentage, priceAdd)
return jxPrice
}
func ConstrainPayPercentage(payPerCentage int) int {
if payPerCentage <= 50 {
payPerCentage = 70