Ejemplo n.º 1
0
        private static void AddOrderItems(OrderFlowInfo orderFlowInfo, IList <ShoppingCartInfo> shoppingCartProductInfoList, IList <ShoppingCartInfo> shoppingCartPresentInfoList, OrderInfo orderInfo, ref double totalWeight, ref decimal totalMoney, UserInfo userInfo)
        {
            bool haveWholesalePurview = false;

            if (!userInfo.UserPurview.IsNull)
            {
                haveWholesalePurview = userInfo.UserPurview.Enablepm;
            }
            foreach (ShoppingCartInfo info in shoppingCartProductInfoList)
            {
                ProductInfo productById = Product.GetProductById(info.ProductId, info.TableName);
                if (!productById.IsNull)
                {
                    AbstractItemInfo info3 = new ConcreteProductInfo(info.Quantity, info.Property, productById, userInfo, orderFlowInfo.NeedInvoice, true, haveWholesalePurview);
                    info3.GetItemInfo();
                    OrderItem.Add(info3.GetOrderItemInfo(orderInfo.OrderId));
                    totalMoney  += info3.SubTotal;
                    totalWeight += info3.TotalWeight;
                    AddPressent(info.Quantity, shoppingCartPresentInfoList, ref totalWeight, ref totalMoney, productById, orderInfo.OrderId);
                }
            }
        }
Ejemplo n.º 2
0
        private static decimal GetMargin(OrderInfo orderInfo, UserInfo userInfo)
        {
            IList <OrderItemInfo> infoListByOrderId = OrderItem.GetInfoListByOrderId(orderInfo.OrderId);
            decimal         num                  = 0M;
            decimal         totalMoney           = 0M;
            double          goodsWeight          = 0.0;
            decimal         num4                 = 0M;
            UserPurviewInfo userPurview          = userInfo.UserPurview;
            bool            haveWholesalePurview = false;

            if (userPurview != null)
            {
                haveWholesalePurview = userPurview.Enablepm;
            }
            foreach (OrderItemInfo info2 in infoListByOrderId)
            {
                if (string.IsNullOrEmpty(info2.TableName))
                {
                    PresentInfo presentById = Present.GetPresentById(info2.ProductId);
                    goodsWeight += presentById.Weight * info2.Amount;
                    totalMoney  += info2.SubTotal;
                }
                else
                {
                    ProductInfo productById = Product.GetProductById(info2.ProductId, info2.TableName);
                    if (!productById.IsNull)
                    {
                        AbstractItemInfo info5 = new ConcreteProductInfo(info2.Amount, info2.Property, productById, userInfo, orderInfo.NeedInvoice, true, haveWholesalePurview);
                        info5.GetItemInfo();
                        totalMoney  += info5.SubTotal;
                        goodsWeight += info5.TotalWeight;
                    }
                }
            }
            PackageInfo packageByGoodsWeight = Package.GetPackageByGoodsWeight(goodsWeight);

            if (!packageByGoodsWeight.IsNull)
            {
                goodsWeight += packageByGoodsWeight.PackageWeight;
            }
            num4 = DeliverCharge.GetDeliverCharge(orderInfo.DeliverType, goodsWeight, orderInfo.ZipCode, totalMoney, orderInfo.NeedInvoice);
            int couponId = orderInfo.CouponId;

            if (couponId > 0)
            {
                CouponInfo couponInfoById = Coupon.GetCouponInfoById(couponId);
                if (!couponInfoById.IsNull)
                {
                    totalMoney -= couponInfoById.Money;
                    if (totalMoney < 0M)
                    {
                        totalMoney = 0M;
                    }
                }
            }
            totalMoney += num4;
            num         = orderInfo.MoneyTotal - totalMoney;
            if (num < 0M)
            {
                num = 0M;
            }
            return(num);
        }