示例#1
0
        public double getActualPrice(int amountinBasket)
        {
            double actualPrice = price;

            if (discount != null && !discount.getIsPartOfComplex())
            {
                actualPrice = price * (1 - discount.getPercentage());
            }
            if (sameProductDiscount != null && !sameProductDiscount.getIsPartOfComplex())
            {
                if (sameProductDiscount.getMinNumOfProducts() <= amountinBasket)
                {
                    actualPrice = price * (1 - sameProductDiscount.getPercentage());
                }
            }
            if (sameProductDiscount != null && sameProductDiscount.getIsPartOfComplex() && sameProductDiscount.getComplexCondition())
            {
                if (sameProductDiscount.getMinNumOfProducts() <= amountinBasket)
                {
                    actualPrice = price * (1 - sameProductDiscount.getPercentage());
                }
            }
            if (discount != null && discount.getIsPartOfComplex() && discount.getComplexCondition())
            {
                actualPrice = price * (1 - discount.getPercentage());
            }
            return(actualPrice);
        }
示例#2
0
        private void addReliantDiscount(ReliantDiscount r)
        {
            //SqlConnection connection = Connector.getInstance().getSQLConnection();
            int    id              = r.getId();
            string type            = "Reliant";
            bool   isPartOfComplex = r.getIsPartOfComplex();
            string reliantType;
            string visibleType = "-1";
            int    productId;
            int    storeId = r.getStoreId();
            int    numOfProducts;
            int    totalAmount;

            if (r.getProduct() == null)
            {
                reliantType   = "totalAmount";
                productId     = -1;
                totalAmount   = r.getTotalAmount();
                numOfProducts = -1;
            }
            else
            {
                reliantType   = "sameProduct";
                productId     = r.getProduct().getProductID();
                totalAmount   = -1;
                numOfProducts = r.getMinNumOfProducts();
            }
            string sql = "INSERT INTO [dbo].[Discount] (id, type, reliantType, visibleType, productId, storeId, numOfProducts, totalAmount)" +
                         " VALUES (@id, @type, @reliantType, @visibleType, @productId, @storeId, @numOfProducts, @totalAmount)";

            connection.Execute(sql, new
            {
                id,
                type,
                reliantType,
                visibleType,
                productId,
                storeId,
                numOfProducts,
                totalAmount
            });
        }