在AspDotNetStorefront中计算客户级别的百分比

时间:2014-06-09 08:33:22

标签: c# percentage aspdotnetstorefront

我正在使用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)));
            }
        }
    }

1 个答案:

答案 0 :(得分:0)

如果有人需要,答案是

int practsaving = (int)(100*((vatPrice - CustLvlPrice) / vatPrice));