0

我正在使用 AspDotNetStoreFront 来运行一个站点。作为代码的一部分,如果产品正在销售,它会显示全价、销售价格和节省的百分比。计算这个百分比的代码是

 if (m_VATOn)
    {
        vatPrice = TaxMultiplier * Price;
        vatSalePrice = TaxMultiplier * SalePrice;
        vatExtPrice = TaxMultiplier * ExtPrice;
    }
    int saving = (int)(100*((vatPrice - vatSalePrice) / vatPrice));

对于某些处于客户级别的客户,还有一个代码。他们显示的不是百分比,而是正常价格,然后是最后的折扣价(他们会自动获得一揽子折扣)。但我试图获得百分比,就像上面的销售产品一样,显示出来,以便他们有

常规价格 客户级别价格 节省的百分比

我认为计算这个的公式是 Price-SalePrice/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 + "&nbsp;" + NCCurrencyDisplay(vatSalePrice, ThisCustomer.CurrencySetting) + "</span>";
                    PriceString += "<span class=\"Saving\" >&nbsp;Saving&nbsp;" + saving.ToString() + "&#37;</span>";
                }

                results.Append(PriceString);

                if (m_VATEnabled)
                {
                    results.Append("&nbsp;" + 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) + "&nbsp;", "") + 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 + "&nbsp;" + 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) + "&nbsp;", "") + NCCurrencyDisplay(CustLvlPrice, ThisCustomer.CurrencySetting) + "</span>";
            PriceString += "<span class=\"Saving\" >&nbsp;Saving&nbsp;" + practsaving.ToString() + "&#37;</span>";
            PriceString += CommonLogic.IIF(AppLogic.AppConfigBool("MicroPay.ShowPointsWithPrices"), "(" + Points.ToString() + " Points)", "");
            results.Append(PriceString);
            if (m_VATEnabled)
            {
                results.Append("&nbsp;" + CommonLogic.IIF(m_VATOn, AppLogic.GetString("setvatsetting.aspx.6", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("setvatsetting.aspx.7", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
            }
        }
    }
4

1 回答 1

0

如果有人需要,答案是

int practsaving = (int)(100*((vatPrice - CustLvlPrice) / vatPrice));
于 2014-06-10T09:15:53.030 回答