From c8aea841a99ee4dd2617d2210c35d006c6a1d507 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 18 Jul 2019 09:17:02 +0800 Subject: [PATCH] =?UTF-8?q?-=20GetPricePercentage=E4=B8=8EGetPricePercenta?= =?UTF-8?q?geByVendorPrice=E5=90=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxutils/jxutils_cms.go | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index 64501dc05..c67aa3402 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -245,35 +245,35 @@ func CaculateSkuPriceFromVendor(vendorPrice, percentage, catPercentage int) int func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercentage int) (pricePercentage int) { pricePercentage = defPricePercentage - // if len(l) > 0 { - // var lastItem *model.PricePercentageItem - // for _, v := range l { - // lastItem = v - // if v.BeginPrice > price { - // break - // } - // } - // if lastItem != nil { - // pricePercentage = lastItem.PricePercentage - // } - // } + if len(l) > 0 { + var lastItem *model.PricePercentageItem + for _, v := range l { + lastItem = v + if v.BeginPrice > price { + break + } + } + if lastItem != nil { + pricePercentage = lastItem.PricePercentage + } + } return pricePercentage } func GetPricePercentageByVendorPrice(l model.PricePercentagePack, vendorPrice int, defPricePercentage int) (pricePercentage int) { pricePercentage = defPricePercentage - // if len(l) > 0 { - // var lastItem *model.PricePercentageItem - // for _, v := range l { - // lastItem = v - // if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage, 0) > vendorPrice { - // break - // } - // } - // if lastItem != nil { - // pricePercentage = lastItem.PricePercentage - // } - // } + if len(l) > 0 { + var lastItem *model.PricePercentageItem + for _, v := range l { + lastItem = v + if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage, 0) > vendorPrice { + break + } + } + if lastItem != nil { + pricePercentage = lastItem.PricePercentage + } + } return pricePercentage }