在AspDotNetStorefront中计算客户级别的百分比
本文关键字:百分比 客户 AspDotNetStorefront 计算 | 更新日期: 2023-09-27 18:07:31
我使用AspDotNetStoreFront来运行一个网站。作为代码的一部分,如果产品正在销售,它会显示全价,销售价格和节省的百分比。计算这个百分比的代码是
if (m_VATOn)
{
vatPrice = TaxMultiplier * Price;
vatSalePrice = TaxMultiplier * SalePrice;
vatExtPrice = TaxMultiplier * ExtPrice;
}
int saving = (int)(100*((vatPrice - vatSalePrice) / vatPrice));
对于处于客户级别的一些客户也有一个代码。他们得到的不是一个百分比,而是一个常规价格,最后是折扣价(他们会自动获得一个全面折扣)。但我想让百分比,就像上面的销售产品一样,显示出来,这样他们就有
常规价格客户级价格百分比保存
我认为计算这个的公式是Price- sales Price/Customer Level Price。但是对于我的生活,我似乎无法复制和调整这一行来计算
int saving = (int)(100*((vatPrice - vatSalePrice) / vatPrice));
显示此内容的其他代码如下所示。如果有人可以帮助我的公式,我会很高兴!
decimal LevelDiscountPct = 0;
if (ThisCustomer.CustomerLevelID != 0)
{
LevelDiscountPct = Prices.LevelDiscount(ThisCustomer.CustomerLevelID, VariantID);
}
if (LevelDiscountPct == 0)
{
LevelDiscountPct = ThisCustomer.LevelDiscountPct;
}
if (ThisCustomer.CustomerLevelID == 0 || (LevelDiscountPct == 0.0M && ExtPrice == 0.0M))
{
if (ThisCustomer.CustomerLevelID == 0 && AppLogic.AppConfigBool("WholesaleOnlySite"))
{
results.Append(" ");
}
else
{
// show consumer pricing (e.g. level 0):
String PriceString = "<span class='"RegularPrice'">" + Localization.CurrencyStringForDisplayWithoutExchangeRate(vatPrice, ThisCustomer.CurrencySetting) + "</span>";
if (SalePrice == Decimal.Zero || ThisCustomer.CustomerLevelID > 0)
{
PriceString = "<span class='"RegularPrice'">" + CommonLogic.IIF(Showpricelabel, AppLogic.GetString("showproduct.aspx.26", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), "") + NCCurrencyDisplay(vatPrice, ThisCustomer.CurrencySetting) + "</span>";
}
else
{
PriceString = "<span class='"SalePrice'" >" + SalesPromptName + " " + NCCurrencyDisplay(vatSalePrice, ThisCustomer.CurrencySetting) + "</span>";
PriceString += "<span class='"Saving'" > Saving " + saving.ToString() + "%</span>";
}
results.Append(PriceString);
if (m_VATEnabled)
{
results.Append(" " + CommonLogic.IIF(m_VATOn, AppLogic.GetString("setvatsetting.aspx.6", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("setvatsetting.aspx.7", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
}
}
}
else
{
decimal CustLvlPrice = CommonLogic.IIF(ExtPrice == 0.0M, Price, ExtPrice);
if (LevelDiscountPct != 0.0M && (ExtPrice == 0.0M || (ExtPrice > 0.0M && ThisCustomer.DiscountExtendedPrices)))
{
CustLvlPrice = CustLvlPrice * (decimal)(1.00M - (LevelDiscountPct / 100.0M)) * CommonLogic.IIF(m_VATOn, TaxMultiplier, 1.0M);
}
// show level pricing:
String PriceString = "<span class='"RegularPrice'" >" + CommonLogic.IIF(Showpricelabel, AppLogic.GetString("showproduct.aspx.27", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + " ", "") + NCCurrencyDisplay(vatPrice, ThisCustomer.CurrencySetting) + "</span> ";
// 10.05.14 Fix the sale price 0.00 issue
if (SalePrice > Decimal.Zero)
{
/* NEW*/ PriceString += "<span class='"SalePrice'" >" + SalesPromptName + " " + NCCurrencyDisplay(vatSalePrice, ThisCustomer.CurrencySetting) + "</span><br />";
}
PriceString += "<br /><span class='"LevelPrice'" style='"color:" + AppLogic.AppConfig("OnSaleForTextColor") + "'">" + CommonLogic.IIF(Showpricelabel, ThisCustomer.CustomerLevelName + " " + AppLogic.GetString("showproduct.aspx.26", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + " ", "") + NCCurrencyDisplay(CustLvlPrice, ThisCustomer.CurrencySetting) + "</span>";
PriceString += "<span class='"Saving'" > Saving " + practsaving.ToString() + "%</span>";
PriceString += CommonLogic.IIF(AppLogic.AppConfigBool("MicroPay.ShowPointsWithPrices"), "(" + Points.ToString() + " Points)", "");
results.Append(PriceString);
if (m_VATEnabled)
{
results.Append(" " + CommonLogic.IIF(m_VATOn, AppLogic.GetString("setvatsetting.aspx.6", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("setvatsetting.aspx.7", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
}
}
}
如果有人需要的话,答案是
int practsaving = (int)(100*((vatPrice - CustLvlPrice) / vatPrice));