private void checkAndUpdateDiscountsByPolicys(string country) { Boolean skip = false; foreach (UserCart uc in products) { Sale s = SalesManager.getInstance().getSale(uc.getSaleId()); LinkedList <Discount> relevantDiscounts = DiscountsManager.getInstance().getAllDiscountsById(s.ProductInStoreId); uc.PriceAfterDiscount = uc.Price; LinkedList <PurchasePolicy> policys = PurchasePolicyManager.getInstance().getAllRelevantPolicysForProductInStore(s.ProductInStoreId, country); foreach (PurchasePolicy p in policys) { if (p.NoDiscount) { skip = true; } } if (skip) { skip = false; continue; } foreach (Discount d in relevantDiscounts) { checkPolicysAndUpdatePrice(uc, d, country, s.TypeOfSale); } } }
public virtual int removeNoCouponPolicyOnCountry(User session, int storeId, string country) { if (StoreManagement.getInstance().getStore(storeId) == null) { return(-1); } return(PurchasePolicyManager.getInstance().removeNoCouponPolicyOnCountry(storeId, country)); }
public virtual int removeNoCouponPolicyOnProductInStore(User session, int storeId, int productInStoreId) { if (StoreManagement.getInstance().getStore(storeId) == null) { return(-1); } return(PurchasePolicyManager.getInstance().removeNoCouponPolicyOnProductInStore(productInStoreId)); }
public virtual int removeNoDiscountPolicyOnCategoty(User session, int storeId, String category) { if (StoreManagement.getInstance().getStore(storeId) == null) { return(-1); } return(PurchasePolicyManager.getInstance().removeNoDiscountPolicyOnCategoty(storeId, category)); }
public virtual int removeAmountPolicyOnStore(User session, int storeId) { if (StoreManagement.getInstance().getStore(storeId) == null) { return(-1); } return(PurchasePolicyManager.getInstance().removeAmountPolicyOnStore(storeId)); }
public virtual int setNoDiscountPolicyOnProductInStore(User session, int storeId, int productInStoreId) { if (StoreManagement.getInstance().getStore(storeId) == null) { return(-1); } return(PurchasePolicyManager.getInstance().setNoDiscountPolicyOnProductInStore(productInStoreId)); }
public virtual int setNoCouponsPolicyOnStore(User session, int storeId) { if (StoreManagement.getInstance().getStore(storeId) == null) { return(-1); } return(PurchasePolicyManager.getInstance().setNoCouponsPolicyOnStore(storeId)); }
public virtual int setAmountPolicyOnCountry(User session, int storeId, string country, int minAmount, int maxAmount) { if (StoreManagement.getInstance().getStore(storeId) == null || minAmount < 0 || maxAmount < 0) { return(-1); } return(PurchasePolicyManager.getInstance().setAmountPolicyOnCountry(storeId, country, minAmount, maxAmount)); }
public virtual int setAmountPolicyOnProductInStore(User session, int storeId, int productInStoreId, int minAmount, int maxAmount) { if (StoreManagement.getInstance().getStore(storeId) == null || minAmount < 0 || maxAmount < 0) { return(-1); } return(PurchasePolicyManager.getInstance().setAmountPolicyOnProductInStore(productInStoreId, minAmount, maxAmount)); }
public override int removeNoCouponsPolicyOnProduct(string productName) { if (productName == null) { return(-1); } return(PurchasePolicyManager.getInstance().removeNoCouponsPolicyOnProduct(productName)); }
public override int setNoDiscountPolicyOnProduct(string productName) { if (productName == null) { return(-1); } return(PurchasePolicyManager.getInstance().setNoDiscountPolicyOnProduct(productName)); }
public override int setAmountPolicyOnProduct(string productName, int minAmount, int maxAmount) { if (productName == null || minAmount < 0 || maxAmount < 0) { return(-1); } return(PurchasePolicyManager.getInstance().setAmountPolicyOnProduct(productName, minAmount, maxAmount)); }
public LinkedList <UserCart> applyCoupon(User session, string couponId, string country) { if (couponId == null || couponId.Equals("")) { return(products); } if (country == null) { country = ""; } if (usedCoupons.Contains(couponId)) { return(products); } Coupon coupon = CouponsManager.getInstance().getCoupon(couponId); if (coupon == null) { return(products); } Boolean skip = false; foreach (UserCart uc in products) { Sale s = SalesManager.getInstance().getSale(uc.getSaleId()); LinkedList <Coupon> relevantCoupons = CouponsManager.getInstance().getAllCouponsById(s.ProductInStoreId); LinkedList <PurchasePolicy> policys = PurchasePolicyManager.getInstance().getAllRelevantPolicysForProductInStore(s.ProductInStoreId, country); foreach (PurchasePolicy p in policys) { if (p.NoCoupons) { skip = true; } } if (skip) { skip = false; continue; } if (relevantCoupons.Contains(coupon)) { checkAndUpdateCouponByPolicy(uc, coupon, country, s.TypeOfSale); } } usedCoupons.AddLast(couponId); return(products); }
private int checkAmountFulfillment(string country) { foreach (UserCart uc in products) { Sale s = SalesManager.getInstance().getSale(uc.getSaleId()); ProductInStore theProduct = ProductManager.getInstance().getProductInStore(s.ProductInStoreId); LinkedList <PurchasePolicy> storePolicys = PurchasePolicyManager.getInstance().getAllStorePolicys(theProduct.store.storeId); LinkedList <PurchasePolicy> countrysPolicys = PurchasePolicyManager.getInstance().getAllCountryPolicys(country, theProduct.store.storeId); LinkedList <PurchasePolicy> categorysPolicys = PurchasePolicyManager.getInstance().getAllCategoryPolicys(theProduct.Category, theProduct.store.storeId); LinkedList <PurchasePolicy> productPolicys = PurchasePolicyManager.getInstance().getAllProductPolicys(theProduct.getProduct().name); LinkedList <PurchasePolicy> productInStorePolicys = PurchasePolicyManager.getInstance().getAllProductInStorePolicys(theProduct.getProductInStoreId()); int currAmount = uc.getAmount(); foreach (PurchasePolicy p in storePolicys) { if (!p.NoLimit) { if (currAmount < p.MinAmount || currAmount > p.MaxAmount) { return(uc.getSaleId()); } } } foreach (PurchasePolicy p in countrysPolicys) { if (!p.NoLimit) { if (currAmount < p.MinAmount || currAmount > p.MaxAmount) { return(uc.getSaleId()); } } } foreach (PurchasePolicy p in categorysPolicys) { if (!p.NoLimit) { if (currAmount < p.MinAmount || currAmount > p.MaxAmount) { return(uc.getSaleId()); } } } foreach (PurchasePolicy p in productPolicys) { if (!p.NoLimit) { if (currAmount < p.MinAmount || currAmount > p.MaxAmount) { return(uc.getSaleId()); } } } foreach (PurchasePolicy p in productInStorePolicys) { if (!p.NoLimit) { if (currAmount < p.MinAmount || currAmount > p.MaxAmount) { return(uc.getSaleId()); } } } } return(-1); }