Beispiel #1
0
        /// <summary>
        /// 计算PaidPrice
        /// </summary>
        public static decimal CalculatePaidPrice(ShopCartItemModel cart)
        {
            decimal ordTotalPrice = cart.CartItemModels.Sum(c => c.price * c.count);
            decimal ordDisPrice   = cart.Coupon == null ? 0 : cart.Coupon.BasePrice;

            return(ordTotalPrice - ordDisPrice);
        }
Beispiel #2
0
 /// <summary>
 /// 满额免
 /// </summary>
 public static void SetFullFree(decimal ordPaidPrice, decimal freeFreight, ShopCartItemModel item)
 {
     item.isFreeFreight = false;
     if (freeFreight > 0)
     {
         item.shopFreeFreight = freeFreight;
         if (ordPaidPrice >= freeFreight)
         {
             item.Freight       = 0;
             item.isFreeFreight = true;
         }
     }
 }
Beispiel #3
0
        private void GetOrderProductsInfo(string cartItemIds)
        {
            CartHelper cartHelper = new CartHelper();
            IEnumerable <ShoppingCartItem> cartItems = null;

            if (!string.IsNullOrWhiteSpace(cartItemIds))
            {
                char[]             chrArray = new char[] { ',' };
                IEnumerable <long> nums     =
                    from t in cartItemIds.Split(chrArray)
                    select long.Parse(t);

                cartItems = ServiceHelper.Create <ICartService>().GetCartItems(nums);
            }
            else
            {
                cartItems = cartHelper.GetCart(base.CurrentUser.Id).Items;
            }
            int cityId = 0;
            ShippingAddressInfo defaultUserShippingAddressByUserId = ServiceHelper.Create <IShippingAddressService>().GetDefaultUserShippingAddressByUserId(base.CurrentUser.Id);

            if (defaultUserShippingAddressByUserId != null)
            {
                cityId = Instance <IRegionService> .Create.GetCityId(defaultUserShippingAddressByUserId.RegionIdPath);
            }
            IProductService      productService = ServiceHelper.Create <IProductService>();
            IShopService         shopService    = ServiceHelper.Create <IShopService>();
            List <CartItemModel> list           = cartItems.Select <ShoppingCartItem, CartItemModel>((ShoppingCartItem item) => {
                ProductInfo product = productService.GetProduct(item.ProductId);
                SKUInfo sku         = productService.GetSku(item.SkuId);
                return(new CartItemModel()
                {
                    skuId = item.SkuId,
                    id = product.Id,
                    imgUrl = product.GetImage(ProductInfo.ImageSize.Size_100, 1),
                    name = product.ProductName,
                    price = sku.SalePrice,
                    shopId = product.ShopId,
                    count = item.Quantity
                });
            }).ToList();
            IEnumerable <IGrouping <long, CartItemModel> > groupings =
                from a in list
                group a by a.shopId;
            List <ShopCartItemModel> shopCartItemModels = new List <ShopCartItemModel>();

            foreach (IGrouping <long, CartItemModel> nums1 in groupings)
            {
                IEnumerable <long> nums2 =
                    from r in nums1
                    select r.id;
                IEnumerable <int> nums3 =
                    from r in nums1
                    select r.count;
                ShopCartItemModel shopCartItemModel = new ShopCartItemModel()
                {
                    shopId = nums1.Key
                };
                if (ServiceHelper.Create <IVShopService>().GetVShopByShopId(shopCartItemModel.shopId) != null)
                {
                    shopCartItemModel.vshopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(shopCartItemModel.shopId).Id;
                }
                else
                {
                    shopCartItemModel.vshopId = 0;
                }
                shopCartItemModel.CartItemModels = (
                    from a in list
                    where a.shopId == shopCartItemModel.shopId
                    select a).ToList();
                shopCartItemModel.ShopName = shopService.GetShop(shopCartItemModel.shopId, false).ShopName;
                if (cityId > 0)
                {
                    shopCartItemModel.Freight = ServiceHelper.Create <IProductService>().GetFreight(nums2, nums3, cityId);
                }
                List <ShopBonusReceiveInfo> detailToUse = ServiceHelper.Create <IShopBonusService>().GetDetailToUse(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                List <CouponRecordInfo>     userCoupon  = ServiceHelper.Create <ICouponService>().GetUserCoupon(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                if (detailToUse.Count() > 0 && userCoupon.Count() > 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo = detailToUse.FirstOrDefault();
                    CouponRecordInfo     couponRecordInfo     = userCoupon.FirstOrDefault();
                    decimal?price = shopBonusReceiveInfo.Price;
                    decimal num   = couponRecordInfo.ChemCloud_Coupon.Price;
                    if ((price.GetValueOrDefault() <= num ? true : !price.HasValue))
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = couponRecordInfo.ChemCloud_Coupon.CouponName,
                            CouponId    = couponRecordInfo.Id,
                            CouponPrice = couponRecordInfo.ChemCloud_Coupon.Price,
                            Type        = 0
                        };
                    }
                    else
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = shopBonusReceiveInfo.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                            CouponId    = shopBonusReceiveInfo.Id,
                            CouponPrice = shopBonusReceiveInfo.Price.Value,
                            Type        = 1
                        };
                    }
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() <= 0)
                {
                    shopCartItemModel.Coupon = null;
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() > 0)
                {
                    CouponRecordInfo couponRecordInfo1 = userCoupon.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = couponRecordInfo1.ChemCloud_Coupon.CouponName,
                        CouponId    = couponRecordInfo1.Id,
                        CouponPrice = couponRecordInfo1.ChemCloud_Coupon.Price,
                        Type        = 0
                    };
                }
                else if (detailToUse.Count() > 0 && userCoupon.Count() <= 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo1 = detailToUse.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = shopBonusReceiveInfo1.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                        CouponId    = shopBonusReceiveInfo1.Id,
                        CouponPrice = shopBonusReceiveInfo1.Price.Value,
                        Type        = 1
                    };
                }
                decimal num1        = shopCartItemModel.CartItemModels.Sum <CartItemModel>((CartItemModel d) => d.price * d.count);
                decimal num2        = num1 - (shopCartItemModel.Coupon == null ? new decimal(0) : shopCartItemModel.Coupon.CouponPrice);
                decimal freeFreight = shopService.GetShop(shopCartItemModel.shopId, false).FreeFreight;
                shopCartItemModel.isFreeFreight = false;
                if (freeFreight > new decimal(0))
                {
                    shopCartItemModel.shopFreeFreight = freeFreight;
                    if (num2 >= freeFreight)
                    {
                        shopCartItemModel.Freight       = new decimal(0);
                        shopCartItemModel.isFreeFreight = true;
                    }
                }
                shopCartItemModels.Add(shopCartItemModel);
            }
            decimal num3 = (
                from a in shopCartItemModels
                where a.Coupon != null
                select a).Sum <ShopCartItemModel>((ShopCartItemModel b) => b.Coupon.CouponPrice);

            ViewBag.products         = shopCartItemModels;
            base.ViewBag.totalAmount = list.Sum <CartItemModel>((CartItemModel item) => item.price * item.count);
            base.ViewBag.Freight     = shopCartItemModels.Sum <ShopCartItemModel>((ShopCartItemModel a) => a.Freight);
            dynamic viewBag = base.ViewBag;
            dynamic obj     = ViewBag.totalAmount;

            viewBag.orderAmount = obj + ViewBag.Freight - num3;
            IMemberIntegralService memberIntegralService = ServiceHelper.Create <IMemberIntegralService>();
            MemberIntegral         memberIntegral        = memberIntegralService.GetMemberIntegral(base.CurrentUser.Id);
            int num4 = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);

            ViewBag.userIntegrals      = num4;
            ViewBag.integralPerMoney   = 0;
            ViewBag.memberIntegralInfo = memberIntegral;
            MemberIntegralExchangeRules integralChangeRule = memberIntegralService.GetIntegralChangeRule();
            decimal num5     = new decimal(0);
            decimal num6     = new decimal(0);
            decimal viewBag1 = (decimal)ViewBag.totalAmount;

            if (integralChangeRule == null || integralChangeRule.IntegralPerMoney <= 0)
            {
                num5 = new decimal(0);
                num6 = new decimal(0);
            }
            else
            {
                if (((viewBag1 - num3) - Math.Round((decimal)num4 / integralChangeRule.IntegralPerMoney, 2)) <= new decimal(0))
                {
                    num5 = Math.Round(viewBag1 - num3, 2);
                    num6 = Math.Round((viewBag1 - num3) * integralChangeRule.IntegralPerMoney);
                }
                else
                {
                    num5 = Math.Round((decimal)num4 / integralChangeRule.IntegralPerMoney, 2);
                    num6 = num4;
                }
                if (num5 <= new decimal(0))
                {
                    num5 = new decimal(0);
                    num6 = new decimal(0);
                }
            }
            ViewBag.integralPerMoney = num5;
            ViewBag.userIntegrals    = num6;
        }
Beispiel #4
0
        private void GetOrderProductsInfo(IEnumerable <string> skuIds, IEnumerable <int> counts)
        {
            IProductService     productService = ServiceHelper.Create <IProductService>();
            IShopService        shopService    = ServiceHelper.Create <IShopService>();
            int                 num3           = 0;
            int                 cityId         = 0;
            ShippingAddressInfo defaultUserShippingAddressByUserId = ServiceHelper.Create <IShippingAddressService>().GetDefaultUserShippingAddressByUserId(base.CurrentUser.Id);

            if (defaultUserShippingAddressByUserId != null)
            {
                cityId = Instance <IRegionService> .Create.GetCityId(defaultUserShippingAddressByUserId.RegionIdPath);
            }
            List <CartItemModel> list = skuIds.Select <string, CartItemModel>((string item) => {
                SKUInfo sku            = productService.GetSku(item);
                IEnumerable <int> nums = counts;
                int num  = num3;
                int num1 = num;
                num3     = num + 1;
                int num2 = nums.ElementAt <int>(num1);
                LimitTimeMarketInfo limitTimeMarketItemByProductId = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(sku.ProductInfo.Id);
                if (limitTimeMarketItemByProductId != null && num2 > limitTimeMarketItemByProductId.MaxSaleCount)
                {
                    throw new HimallException(string.Concat("超过最大限购数量:", limitTimeMarketItemByProductId.MaxSaleCount.ToString()));
                }
                return(new CartItemModel()
                {
                    skuId = item,
                    id = sku.ProductInfo.Id,
                    imgUrl = sku.ProductInfo.GetImage(ProductInfo.ImageSize.Size_100, 1),
                    name = sku.ProductInfo.ProductName,
                    shopId = sku.ProductInfo.ShopId,
                    price = (limitTimeMarketItemByProductId == null ? sku.SalePrice : limitTimeMarketItemByProductId.Price),
                    count = num2,
                    productCode = sku.ProductInfo.ProductCode
                });
            }).ToList();
            IEnumerable <IGrouping <long, CartItemModel> > groupings =
                from a in list
                group a by a.shopId;
            List <ShopCartItemModel> shopCartItemModels = new List <ShopCartItemModel>();

            foreach (IGrouping <long, CartItemModel> nums1 in groupings)
            {
                IEnumerable <long> nums2 =
                    from r in nums1
                    select r.id;
                IEnumerable <int> nums3 =
                    from r in nums1
                    select r.count;
                ShopCartItemModel shopCartItemModel = new ShopCartItemModel()
                {
                    shopId = nums1.Key
                };
                shopCartItemModel.CartItemModels = (
                    from a in list
                    where a.shopId == shopCartItemModel.shopId
                    select a).ToList();
                shopCartItemModel.ShopName = shopService.GetShop(shopCartItemModel.shopId, false).ShopName;
                if (cityId != 0)
                {
                    shopCartItemModel.Freight = ServiceHelper.Create <IProductService>().GetFreight(nums2, nums3, cityId);
                }
                List <ShopBonusReceiveInfo> detailToUse = ServiceHelper.Create <IShopBonusService>().GetDetailToUse(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                List <CouponRecordInfo>     userCoupon  = ServiceHelper.Create <ICouponService>().GetUserCoupon(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                if (detailToUse.Count() > 0 && userCoupon.Count() > 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo = detailToUse.FirstOrDefault();
                    CouponRecordInfo     couponRecordInfo     = userCoupon.FirstOrDefault();
                    decimal?price  = shopBonusReceiveInfo.Price;
                    decimal price1 = couponRecordInfo.ChemCloud_Coupon.Price;
                    if ((price.GetValueOrDefault() <= price1 ? true : !price.HasValue))
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = couponRecordInfo.ChemCloud_Coupon.CouponName,
                            CouponId    = couponRecordInfo.Id,
                            CouponPrice = couponRecordInfo.ChemCloud_Coupon.Price,
                            Type        = 0
                        };
                    }
                    else
                    {
                        shopCartItemModel.Coupon = new CouponModel()
                        {
                            CouponName  = shopBonusReceiveInfo.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                            CouponId    = shopBonusReceiveInfo.Id,
                            CouponPrice = shopBonusReceiveInfo.Price.Value,
                            Type        = 1
                        };
                    }
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() <= 0)
                {
                    shopCartItemModel.Coupon = null;
                }
                else if (detailToUse.Count() <= 0 && userCoupon.Count() > 0)
                {
                    CouponRecordInfo couponRecordInfo1 = userCoupon.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = couponRecordInfo1.ChemCloud_Coupon.CouponName,
                        CouponId    = couponRecordInfo1.Id,
                        CouponPrice = couponRecordInfo1.ChemCloud_Coupon.Price,
                        Type        = 0
                    };
                }
                else if (detailToUse.Count() > 0 && userCoupon.Count() <= 0)
                {
                    ShopBonusReceiveInfo shopBonusReceiveInfo1 = detailToUse.FirstOrDefault();
                    shopCartItemModel.Coupon = new CouponModel()
                    {
                        CouponName  = shopBonusReceiveInfo1.ChemCloud_ShopBonusGrant.ChemCloud_ShopBonus.Name,
                        CouponId    = shopBonusReceiveInfo1.Id,
                        CouponPrice = shopBonusReceiveInfo1.Price.Value,
                        Type        = 1
                    };
                }
                decimal num4        = shopCartItemModel.CartItemModels.Sum <CartItemModel>((CartItemModel d) => d.price * d.count);
                decimal num5        = num4 - (shopCartItemModel.Coupon == null ? new decimal(0) : shopCartItemModel.Coupon.CouponPrice);
                decimal freeFreight = shopService.GetShop(shopCartItemModel.shopId, false).FreeFreight;
                shopCartItemModel.isFreeFreight = false;
                if (freeFreight > new decimal(0))
                {
                    shopCartItemModel.shopFreeFreight = freeFreight;
                    if (num5 >= freeFreight)
                    {
                        shopCartItemModel.Freight       = new decimal(0);
                        shopCartItemModel.isFreeFreight = true;
                    }
                }
                shopCartItemModels.Add(shopCartItemModel);
            }
            decimal num6 = (
                from a in shopCartItemModels
                where a.Coupon != null
                select a).Sum <ShopCartItemModel>((ShopCartItemModel b) => b.Coupon.CouponPrice);

            ViewBag.products         = shopCartItemModels;
            base.ViewBag.totalAmount = list.Sum <CartItemModel>((CartItemModel item) => item.price * item.count);
            base.ViewBag.Freight     = shopCartItemModels.Sum <ShopCartItemModel>((ShopCartItemModel a) => a.Freight);
            dynamic viewBag = base.ViewBag;
            dynamic obj     = ViewBag.totalAmount;

            viewBag.orderAmount = obj + ViewBag.Freight - num6;
            IMemberIntegralService memberIntegralService = ServiceHelper.Create <IMemberIntegralService>();
            MemberIntegral         memberIntegral        = memberIntegralService.GetMemberIntegral(base.CurrentUser.Id);
            int num7 = (memberIntegral == null ? 0 : memberIntegral.AvailableIntegrals);

            ViewBag.userIntegrals      = num7;
            ViewBag.integralPerMoney   = 0;
            ViewBag.memberIntegralInfo = memberIntegral;
            MemberIntegralExchangeRules integralChangeRule = memberIntegralService.GetIntegralChangeRule();
            decimal viewBag1 = new decimal(0);
            decimal viewBag2 = new decimal(0);

            if (integralChangeRule == null || integralChangeRule.IntegralPerMoney <= 0)
            {
                viewBag1 = new decimal(0);
                viewBag2 = new decimal(0);
            }
            else
            {
                if (ViewBag.totalAmount - num6 - Math.Round((decimal)num7 / integralChangeRule.IntegralPerMoney, 2) <= 0)
                {
                    viewBag1 = Math.Round(ViewBag.totalAmount - num6, 2);
                    viewBag2 = Math.Round((ViewBag.totalAmount - num6) * integralChangeRule.IntegralPerMoney);
                }
                else
                {
                    viewBag1 = Math.Round((decimal)num7 / integralChangeRule.IntegralPerMoney, 2);
                    viewBag2 = num7;
                }
                if (viewBag1 <= new decimal(0))
                {
                    viewBag1 = new decimal(0);
                    viewBag2 = new decimal(0);
                }
            }
            ViewBag.integralPerMoney = viewBag1;
            ViewBag.userIntegrals    = viewBag2;
        }
        private void GetOrderProductsInfo(string cartItemIds, long?regionId)
        {
            ShippingAddressInfo shippingAddressInfo = new ShippingAddressInfo();

            shippingAddressInfo = (!regionId.HasValue ? ServiceHelper.Create <IShippingAddressService>().GetDefaultUserShippingAddressByUserId(base.CurrentUser.Id) : ServiceHelper.Create <IShippingAddressService>().GetUserShippingAddress(regionId.Value));
            int cityId = 0;

            if (shippingAddressInfo != null)
            {
                cityId = Instance <IRegionService> .Create.GetCityId(shippingAddressInfo.RegionIdPath);
            }
            CartHelper cartHelper = new CartHelper();
            IEnumerable <ShoppingCartItem> cartItems = null;

            if (!string.IsNullOrWhiteSpace(cartItemIds))
            {
                char[]             chrArray = new char[] { ',' };
                IEnumerable <long> nums     =
                    from t in cartItemIds.Split(chrArray)
                    select long.Parse(t);

                cartItems = ServiceHelper.Create <ICartService>().GetCartItems(nums);
            }
            else
            {
                cartItems = cartHelper.GetCart(base.CurrentUser.Id).Items;
            }
            IProductService      productService = ServiceHelper.Create <IProductService>();
            IShopService         shopService    = ServiceHelper.Create <IShopService>();
            List <CartItemModel> list           = cartItems.Select <ShoppingCartItem, CartItemModel>((ShoppingCartItem item) =>
            {
                ProductInfo product = productService.GetProduct(item.ProductId);
                SKUInfo sku         = productService.GetSku(item.SkuId);
                return(new CartItemModel()
                {
                    skuId = item.SkuId,
                    id = product.Id,
                    imgUrl = product.GetImage(ProductInfo.ImageSize.Size_50, 1),
                    name = product.ProductName,
                    price = sku.SalePrice,
                    shopId = product.ShopId,
                    count = item.Quantity,
                    productCode = product.ProductCode
                });
            }).ToList();
            IEnumerable <IGrouping <long, CartItemModel> > groupings =
                from a in list
                group a by a.shopId;
            List <ShopCartItemModel> shopCartItemModels = new List <ShopCartItemModel>();

            foreach (IGrouping <long, CartItemModel> nums1 in groupings)
            {
                IEnumerable <long> nums2 =
                    from r in nums1
                    select r.id;
                IEnumerable <int> nums3 =
                    from r in nums1
                    select r.count;
                ShopCartItemModel shopCartItemModel = new ShopCartItemModel()
                {
                    shopId = nums1.Key,

                    Freight = (cityId <= 0 ? new decimal(0) : ServiceHelper.Create <IProductService>().GetFreight(nums2, nums3, cityId)),
                };

                shopCartItemModel.CartItemModels = (
                    from a in list
                    where a.shopId == shopCartItemModel.shopId
                    select a).ToList();
                shopCartItemModel.ShopName    = shopService.GetShop(shopCartItemModel.shopId, false).ShopName;
                shopCartItemModel.UserCoupons = ServiceHelper.Create <ICouponService>().GetUserCoupon(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                shopCartItemModel.UserBonus   = ServiceHelper.Create <IShopBonusService>().GetDetailToUse(shopCartItemModel.shopId, base.CurrentUser.Id, nums1.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));

                shopCartItemModels.Add(shopCartItemModel);
            }
            ViewBag.products         = shopCartItemModels;
            base.ViewBag.totalAmount = list.Sum <CartItemModel>((CartItemModel item) => item.price * item.count);
            base.ViewBag.Freight     = shopCartItemModels.Sum <ShopCartItemModel>((ShopCartItemModel a) => a.Freight);
            dynamic viewBag = base.ViewBag;
            dynamic obj     = ViewBag.totalAmount;

            viewBag.orderAmount = obj + ViewBag.Freight;
        }
        private void GetOrderProductsInfo(string skuIds, string counts, string collIds = null)
        {
            ShippingAddressInfo defaultUserShippingAddressByUserId = ServiceHelper.Create <IShippingAddressService>().GetDefaultUserShippingAddressByUserId(base.CurrentUser.Id);
            int cityId = 0;

            if (defaultUserShippingAddressByUserId != null)
            {
                cityId = Instance <IRegionService> .Create.GetCityId(defaultUserShippingAddressByUserId.RegionIdPath);
            }
            IEnumerable <long> nums = null;

            string[] strArrays = skuIds.Split(new char[] { ',' });
            string   str       = counts.TrimEnd(new char[] { ',' });

            char[]            chrArray = new char[] { ',' };
            IEnumerable <int> nums1    =
                from t in str.Split(chrArray)
                select int.Parse(t);

            if (!string.IsNullOrEmpty(collIds))
            {
                string str1      = collIds.TrimEnd(new char[] { ',' });
                char[] chrArray1 = new char[] { ',' };
                nums =
                    from t in str1.Split(chrArray1)
                    select long.Parse(t);
            }
            IProductService      productService = ServiceHelper.Create <IProductService>();
            int                  num2           = 0;
            int                  length         = strArrays.Length;
            List <CartItemModel> list           = strArrays.Select <string, CartItemModel>((string item) =>
            {
                SKUInfo sku = productService.GetSku(item);
                int num     = nums1.ElementAt <int>(num2);
                long num1   = (nums != null ? nums.ElementAt <long>(num2) : 0);
                num2++;
                return(new CartItemModel()
                {
                    skuId = item,
                    id = sku.ProductInfo.Id,
                    imgUrl = sku.ProductInfo.GetImage(ProductInfo.ImageSize.Size_50, 1),
                    name = sku.ProductInfo.ProductName,
                    shopId = sku.ProductInfo.ShopId,
                    price = GetSalePrice(sku.ProductInfo.Id, sku, new long?(num1), length),
                    count = num,
                    productCode = sku.ProductInfo.ProductCode
                });
            }).ToList();
            IShopService create = Instance <IShopService> .Create;
            IEnumerable <IGrouping <long, CartItemModel> > groupings =
                from a in list
                group a by a.shopId;
            List <ShopCartItemModel> shopCartItemModels = new List <ShopCartItemModel>();

            foreach (IGrouping <long, CartItemModel> nums2 in groupings)
            {
                IEnumerable <long> nums3 =
                    from r in nums2
                    select r.id;
                IEnumerable <int> nums4 =
                    from r in nums2
                    select r.count;
                ShopCartItemModel shopCartItemModel = new ShopCartItemModel()
                {
                    shopId = nums2.Key
                };
                shopCartItemModel.CartItemModels = (
                    from a in list
                    where a.shopId == shopCartItemModel.shopId
                    select a).ToList();
                shopCartItemModel.ShopName = create.GetShop(shopCartItemModel.shopId, false).ShopName;
                if (cityId != 0)
                {
                    shopCartItemModel.Freight = ServiceHelper.Create <IProductService>().GetFreight(nums3, nums4, cityId);
                }
                shopCartItemModel.UserCoupons = ServiceHelper.Create <ICouponService>().GetUserCoupon(shopCartItemModel.shopId, base.CurrentUser.Id, nums2.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                shopCartItemModel.UserBonus   = ServiceHelper.Create <IShopBonusService>().GetDetailToUse(shopCartItemModel.shopId, base.CurrentUser.Id, nums2.Sum <CartItemModel>((CartItemModel a) => a.price * a.count));
                shopCartItemModels.Add(shopCartItemModel);
            }
            ViewBag.CollIds          = collIds;
            ViewBag.products         = shopCartItemModels;
            base.ViewBag.totalAmount = list.Sum <CartItemModel>((CartItemModel item) => item.price * item.count);
            base.ViewBag.Freight     = shopCartItemModels.Sum <ShopCartItemModel>((ShopCartItemModel a) => a.Freight);
            dynamic viewBag = base.ViewBag;
            dynamic obj     = ViewBag.totalAmount;

            viewBag.orderAmount = obj + ViewBag.Freight;
        }