Exemple #1
0
        /// <summary>
        /// 为SO提供计算当前订单能能享受的所有促销活动结果
        /// </summary>
        /// <param name="soInfo">订单信息</param>
        /// <returns></returns>
        public virtual List <SOPromotionInfo> CalculateSOPromotion(SOInfo soInfo, List <SOPromotionInfo> alreadyApplyPromoList)
        {
            //只有零售才享受销售立减
            if (soInfo.BaseInfo.IsWholeSale.HasValue && soInfo.BaseInfo.IsWholeSale.Value)
            {
                return(new List <SOPromotionInfo>(0));
            }

            List <SOItemInfo> soItemList = new List <SOItemInfo>();

            foreach (SOItemInfo soItem in soInfo.Items)
            {
                if (soItem.ProductType.Value == SOProductType.Product)
                {
                    var product = ExternalDomainBroker.GetSimpleProductInfo(soItem.ProductSysNo.Value);
                    soItem.C3SysNo           = product.ProductBasicInfo.ProductCategoryInfo.SysNo ?? 0;
                    soItem.BrandSysNo        = product.ProductBasicInfo.ProductBrandInfo.SysNo ?? 0;
                    soItem.ProductGroupSysNo = product.ProductGroupSysno;
                    soItemList.Add(soItem);
                }
            }

            if (soItemList.Count == 0)
            {
                return(new List <SOPromotionInfo>(0));
            }

            var promotionInfoList = SaleDiscountRuleCalculator.Instance.CalcSaleDiscountRule(soItemList, soInfo.SysNo ?? 0, alreadyApplyPromoList);

            return(promotionInfoList);
        }
        public virtual SaleAdvertisement LoadBySysNo(int sysNo)
        {
            var result = da.LoadBySysNo(sysNo);

            if (result == null)
            {
                //throw new BizException("页面促销模板信息不存在!");
                throw new BizException(ResouceManager.GetMessageString("MKT.SaleAdvertisement", "SaleAdvertisement_NotExistAdvertise"));
            }
            result.Groups = da.LoadSaleAdvGroupsBySaleAdvSysNo(sysNo);
            result.Items  = da.GetSaleAdvItems(sysNo);

            if (result.Groups != null && result.Items != null)
            {
                result.Groups.ForEach(p =>
                {
                    p.ItemsCount = result.Items.Count(i => i.GroupSysNo == p.SysNo);
                });
            }
            if (result.Items != null)
            {
                //获取商品和库存的相关信息
                var productSysNoList = result.Items.Select(p => p.ProductSysNo.Value).ToList();

                //var products = ExternalDomainBroker.GetProductInfoListByProductSysNoList(productSysNoList);
                var inventorys = ExternalDomainBroker.GetProductInventoryInfoByProductSysNoList(productSysNoList);
                result.Items.ForEach(i =>
                {
                    //ProductInfo product = products.FirstOrDefault(p => p.SysNo == i.ProductSysNo);
                    ProductInfo product = ExternalDomainBroker.GetSimpleProductInfo(i.ProductSysNo.Value);
                    if (product != null)
                    {
                        i.ProductID     = product.ProductID;
                        i.ProductName   = product.ProductName;
                        i.ProductStatus = product.ProductStatus;
                    }

                    var inventory = inventorys.FirstOrDefault(p => p.ProductSysNo == i.ProductSysNo);
                    if (inventory != null)
                    {
                        i.OnlineQty = inventory.OnlineQty;
                    }
                });
            }
            return(result);
        }
        /// <summary>
        /// Check 厂商赠品的赠品不能作为其它赠品活动的赠品
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private List <String> CheckVendorGiftRules(SaleGiftBatchInfo info)
        {
            List <SaleGiftInfo> giftInfoListTmp = new List <SaleGiftInfo>();
            List <String>       msgTmp          = new List <String>();

            foreach (var item in info.Gifts)
            {
                giftInfoListTmp.AddRange(_da.GetGiftItemListByProductSysNo(item.ProductSysNo.Value, SaleGiftStatus.Run));
                giftInfoListTmp.AddRange(_da.GetGiftItemListByProductSysNo(item.ProductSysNo.Value, SaleGiftStatus.Ready));
                giftInfoListTmp.AddRange(_da.GetGiftItemListByProductSysNo(item.ProductSysNo.Value, SaleGiftStatus.WaitingAudit));

                if (info.SaleGiftType == SaleGiftType.Vendor)
                {
                    if (giftInfoListTmp != null && giftInfoListTmp.Where(p => p.SysNo != info.SysNo && p.Type != SaleGiftType.Vendor).ToList().Count > 0)
                    {
                        //msgTmp.Add(string.Format("厂商赠品 ({0}) 在其他赠品活动中存在有效的重复的记录!", ExternalDomainBroker.GetSimpleProductInfo(item.ProductSysNo.Value).ProductID));
                        msgTmp.Add(string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_ExsisitActivityInOther"), ExternalDomainBroker.GetSimpleProductInfo(item.ProductSysNo.Value).ProductID));
                        continue;
                    }
                }
                else
                {
                    if (giftInfoListTmp != null && giftInfoListTmp.Where(p => p.SysNo != info.SysNo && p.Type == SaleGiftType.Vendor).ToList().Count > 0)
                    {
                        //msgTmp.Add(string.Format("赠品 ({0}) 在厂商赠品活动中存在有效的重复的记录!", ExternalDomainBroker.GetSimpleProductInfo(item.ProductSysNo.Value).ProductID));
                        msgTmp.Add(string.Format(ResouceManager.GetMessageString("MKT.Promotion.SaleGift", "SaleGift_ExsisitActivityInMerchant"), ExternalDomainBroker.GetSimpleProductInfo(item.ProductSysNo.Value).ProductID));
                        continue;
                    }
                }
            }
            return(msgTmp);
        }