示例#1
0
        private void CheckExistsRule(SaleDiscountRule data)
        {
            int  c3SysNo      = data.C3SysNo ?? 0;
            int  brandSysNo   = data.BrandSysNo ?? 0;
            int  productSysNo = data.ProductSysNo ?? 0;
            int  excludeSysNo = data.SysNo ?? 0;
            bool exists       = true;

            //限定分类+品牌
            if (c3SysNo > 0 && brandSysNo > 0)
            {
                exists = _daSaleDiscountRule.CheckExistsProductScope_CategoryBrand(excludeSysNo, c3SysNo, brandSysNo);
                if (exists)
                {
                    //throw new BizException("已存在限定此分类+此品牌的有效销售规则,请不要重复设置。");
                    throw new BizException(ResouceManager.GetMessageString("MKT.SaleDiscountRule", "SaleDiscountRule_ExsistCategoryAndBrandActiveDiscountRule"));
                }
            }
            //限定分类
            else if (c3SysNo > 0)
            {
                exists = _daSaleDiscountRule.CheckExistsProductScope_Category(excludeSysNo, c3SysNo);
                if (exists)
                {
                    //throw new BizException("已存在限定此分类的有效销售规则,请不要重复设置。");
                    throw new BizException(ResouceManager.GetMessageString("MKT.SaleDiscountRule", "SaleDiscountRule_ExsistCategoryActiveDiscountRule"));
                }
            }
            //限定品牌
            else if (brandSysNo > 0)
            {
                exists = _daSaleDiscountRule.CheckExistsProductScope_Brand(excludeSysNo, brandSysNo);
                if (exists)
                {
                    //throw new BizException("已存在限定此品牌的有效销售规则,请不要重复设置。");
                    throw new BizException(ResouceManager.GetMessageString("MKT.SaleDiscountRule", "SaleDiscountRule_ExsistBrandActiveDiscountRule"));
                }
            }
            //限定商品(包含商品组的概念)
            else if (productSysNo > 0)
            {
                List <int> productSysNos = new List <int>(0);
                productSysNos.Add(productSysNo);
                var productInGroup = ExternalDomainBroker.GetProductsInSameGroupWithProductSysNo(productSysNo);
                if (productInGroup != null && productInGroup.Count > 0)
                {
                    productSysNos.Clear();
                    productSysNos = productInGroup.Select(item => item.SysNo).ToList();
                }
                exists = _daSaleDiscountRule.CheckExistsProductScope_Product(excludeSysNo, productSysNo);
                if (exists)
                {
                    //throw new BizException("已存在限定此商品或商品组的有效销售规则,请不要重复设置。");
                    throw new BizException(ResouceManager.GetMessageString("MKT.SaleDiscountRule", "SaleDiscountRule_ExsistActiveDiscountRule"));
                }
            }
        }
示例#2
0
        /// <summary>
        /// 验证商品是否存在相冲突时间段的限时抢购中
        /// </summary>
        private void CheckGroupBuyAndCountDownConflict(GroupBuyingInfo groupBuy)
        {
            List <int> productSysNos = new List <int>();

            productSysNos.Add(groupBuy.ProductSysNo.Value);

            if (groupBuy.IsByGroup.Value)
            {
                List <ProductInfo> products = ExternalDomainBroker.GetProductsInSameGroupWithProductSysNo(groupBuy.ProductSysNo.Value);

                foreach (ProductInfo p in products)
                {
                    productSysNos.Add(p.SysNo);
                }
            }

            if (ObjectFactory <CountdownProcessor> .Instance.CheckGroupBuyAndCountDownConflict(productSysNos, groupBuy.BeginDate.Value, groupBuy.EndDate.Value))
            {
                // throw new BizException("该商品或者同组商品已经存在一个时间冲突的限时抢购!");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_ExsistTimeConflictCountdown"));
            }
        }
示例#3
0
        /// <summary>
        /// 验证商品是否存在相冲突时间段的团购中
        /// </summary>
        private void CheckGroupBuyConflict(int?GroupBuySysNo, GroupBuyingInfo groupBuy)
        {
            List <int> productSysNos = new List <int>();

            productSysNos.Add(groupBuy.ProductSysNo.Value);

            if (groupBuy.IsByGroup.Value)
            {
                List <ProductInfo> products = ExternalDomainBroker.GetProductsInSameGroupWithProductSysNo(groupBuy.ProductSysNo.Value);

                foreach (ProductInfo p in products)
                {
                    productSysNos.Add(p.SysNo);
                }
            }

            if (m_GroupBuyingDA.CheckConflict(GroupBuySysNo, productSysNos, groupBuy.BeginDate.Value, groupBuy.EndDate.Value))
            {
                //throw new BizException("该商品或者同组商品已经存在一个时间冲突的团购!");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.GroupBuying", "GroupBuying_ExsistTimeConflictGroupBuying"));
            }
        }
示例#4
0
        private void CheckData(BuyLimitRule data)
        {
            int sysNo = data.SysNo ?? 0;

            if (data.LimitType == LimitType.Combo)
            {
                //1.验证套餐是否存在
                var combo = ObjectFactory <ComboProcessor> .Instance.Load(data.ItemSysNo);

                if (combo == null)
                {
                    throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_NotExistThisGroupBuy"), data.ItemSysNo));
                }
                //2.验证套餐是否已存在规则设置
                //CheckExistsRule(LimitType.Combo, "该套餐已存在相关限购规则,请不要重复设置。"
                //    , sysNo, data.ItemSysNo);
                CheckExistsRule(LimitType.Combo, ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_ExisitThisLimitRuleForGroupBuy")
                                , sysNo, data.ItemSysNo);
            }
            else
            {
                //1.验证商品是否存在
                var product = ExternalDomainBroker.GetProductInfo(data.ItemSysNo);
                if (product == null)
                {
                    //throw new BizException("商品不存在。");
                    throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_NotExistProduct"));
                }
                //2.验证商品或其所属商品组是否已存在规则设置
                var        productInGroup = ExternalDomainBroker.GetProductsInSameGroupWithProductSysNo(data.ItemSysNo);
                List <int> productSysNos  = new List <int>(0);
                if (productInGroup != null && productInGroup.Count > 0)
                {
                    productSysNos = productInGroup.Select(item => item.SysNo).ToList();
                }
                else
                {
                    productSysNos.Add(data.ItemSysNo);
                }
                //CheckExistsRule(LimitType.SingleProduct, "该单品或其所属商品组已存在相关限购规则,请不要重复设置。"
                //    , sysNo, productSysNos.ToArray());
                CheckExistsRule(LimitType.SingleProduct, ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_ExisitThisLimitRuleForProduct")
                                , sysNo, productSysNos.ToArray());
            }
            if (data.EndDate <= data.BeginDate)
            {
                //throw new BizException("结束时间必须大于开始时间。");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_EndDateNeedMoreThanStartDate"));
            }
            if (data.EndDate.HasValue && data.EndDate.Value <= DateTime.Now)
            {
                //throw new BizException("结束时间必须大于当前时间。");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_EndDateNeedMoreThanCurrentDate"));
            }
            if (data.MinQty < 0)
            {
                //throw new BizException("限购下限必须大于等于零。");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_LowerLimitNeedMoreThan0"));
            }
            if (data.MaxQty < 0)
            {
                //throw new BizException("限购上限必须大于等于零。");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_UpperLimitNeedMoreThan0"));
            }
            if (data.MaxQty < data.MinQty)
            {
                //throw new BizException("限购上限必须大于等于限购下限");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_UpperLimitNeedMoreThanLowerLimit"));
            }

            if (data.OrderTimes < 0)
            {
                //throw new BizException("当日限购次数必须大于等于零。");
                throw new BizException(ResouceManager.GetMessageString("MKT.Promotion.BuyLimit", "BuyLimit_LimitCountNeedMoreThan0InCurrentDay"));
            }
        }