Beispiel #1
0
        /// <summary>
        /// 取得满足优惠券条件的商品总金额
        /// </summary>
        /// <param name="order"></param>
        /// <param name="coupon"></param>
        /// <returns></returns>
        private decimal GetCanCalculateAmount(ref OrderInfo order, CouponInfo coupon)
        {
            List <SOItemInfo> soItemList       = InternalHelper.ConvertToSOItemList(order, false, true);
            List <int>        productSysNoList = new List <int>();

            soItemList.ForEach(f => productSysNoList.Add(f.ProductSysNo));

            //couponProductList:满足条件的商品列表,使用OrderProductItem这个对象来记录,UnitSalePrice是这个商品的价格,UnitQuantity会作为这个商品的总数量
            List <OrderProductItem> couponProductList = new List <OrderProductItem>();

            List <SimpleItemEntity> productList = PromotionDA.GetSimpleItemListBySysNumbers(productSysNoList);

            //主商品
            foreach (OrderItemGroup itemGroup in order.OrderItemGroupList)
            {
                foreach (OrderProductItem item in itemGroup.ProductItemList)
                {
                    SimpleItemEntity product = productList.Find(f => f.ProductSysNo == item.ProductSysNo);
                    if (CheckIsCouponProduct(product, coupon))
                    {
                        OrderProductItem couponProduct = couponProductList.Find(f => f.ProductSysNo == product.ProductSysNo);
                        if (couponProduct == null)
                        {
                            couponProduct = new OrderProductItem();
                            couponProduct.ProductSysNo  = item.ProductSysNo;
                            couponProduct.UnitSalePrice = item.UnitSalePrice;
                            couponProduct.UnitQuantity  = item.UnitQuantity * itemGroup.Quantity;
                            couponProductList.Add(couponProduct);
                        }
                        else
                        {
                            couponProduct.UnitQuantity += item.UnitQuantity * itemGroup.Quantity;
                        }
                    }
                }
            }
            //加购商品
            if (order.PlusPriceItemList != null)
            {
                foreach (OrderGiftItem item in order.PlusPriceItemList)
                {
                    SimpleItemEntity product = productList.Find(f => f.ProductSysNo == item.ProductSysNo);
                    if (CheckIsCouponProduct(product, coupon))
                    {
                        OrderProductItem couponProduct = couponProductList.Find(f => f.ProductSysNo == product.ProductSysNo);
                        if (couponProduct == null)
                        {
                            couponProduct = new OrderProductItem();
                            couponProduct.ProductSysNo  = item.ProductSysNo;
                            couponProduct.UnitSalePrice = item.UnitSalePrice;
                            couponProduct.UnitQuantity  = item.UnitQuantity;
                            couponProductList.Add(couponProduct);
                        }
                        else
                        {
                            couponProduct.UnitQuantity += item.UnitQuantity;
                        }
                    }
                }
            }

            decimal totalAmount = 0.00m;

            foreach (OrderProductItem couponProduct in couponProductList)
            {
                totalAmount += couponProduct.UnitSalePrice * couponProduct.UnitQuantity;
            }

            order.CouponProductList = couponProductList;

            return(totalAmount);
        }