예제 #1
0
        public static void UpdateOrderInfo(OrderInfo orderInfo, IList <OrderItemInfo> orderItemInfoList)
        {
            decimal totalMoney  = 0M;
            double  goodsWeight = 0.0;
            decimal num3        = 0M;

            foreach (OrderItemInfo info in orderItemInfoList)
            {
                totalMoney  += info.SubTotal;
                goodsWeight += DataConverter.CDouble(info.Weight) * info.Amount;
            }
            orderInfo.MoneyGoods = totalMoney;
            PackageInfo packageByGoodsWeight = Package.GetPackageByGoodsWeight(goodsWeight);

            if (!packageByGoodsWeight.IsNull)
            {
                goodsWeight += packageByGoodsWeight.PackageWeight;
            }
            num3 = DeliverCharge.GetDeliverCharge(orderInfo.DeliverType, goodsWeight, orderInfo.ZipCode, totalMoney, orderInfo.NeedInvoice);
            if (num3 > 0M)
            {
                totalMoney += num3;
            }
            orderInfo.MoneyTotal    = totalMoney;
            orderInfo.ChargeDeliver = num3;
            Update(orderInfo);
        }
예제 #2
0
        public static int Add(OrderFlowInfo orderFlowInfo, UserInfo userInfo, string cartId, int couponId, decimal trueTotalMoney)
        {
            decimal num5;
            int     num6;
            int     num7;

            if (string.IsNullOrEmpty(cartId))
            {
                return(1);
            }
            IList <ShoppingCartInfo> infoByCart = ShoppingCart.GetInfoByCart(cartId, false);

            if (infoByCart.Count <= 0)
            {
                return(2);
            }
            IList <ShoppingCartInfo> shoppingCartPresentInfoList = ShoppingCart.GetInfoByCart(cartId, true);
            OrderInfo orderInfo   = new OrderInfo();
            double    totalWeight = 0.0;
            decimal   totalMoney  = 0M;
            double    discount    = PaymentType.GetPaymentTypeById(orderFlowInfo.PaymentType).Discount;
            string    userName    = "";
            int       clientId    = 0;

            if (!userInfo.IsNull)
            {
                ProcessSubscriber(orderFlowInfo, userInfo);
                userName = userInfo.UserName;
                clientId = userInfo.ClientId;
            }
            AddOrder(orderFlowInfo, orderInfo, discount, userName, clientId);
            AddOrderItems(orderFlowInfo, infoByCart, shoppingCartPresentInfoList, orderInfo, ref totalWeight, ref totalMoney, userInfo);
            CheckPresentProject(orderFlowInfo, orderInfo, ref totalWeight, ref totalMoney, out num5, out num6, out num7);
            decimal     num8 = totalMoney;
            PackageInfo packageByGoodsWeight = Package.GetPackageByGoodsWeight(totalWeight);

            if (!packageByGoodsWeight.IsNull)
            {
                totalWeight += packageByGoodsWeight.PackageWeight;
            }
            decimal num9 = DeliverCharge.GetDeliverCharge(orderFlowInfo.DeliverType, totalWeight, orderFlowInfo.ZipCode, totalMoney, orderFlowInfo.NeedInvoice);

            totalMoney             += num9;
            orderInfo.MoneyGoods    = num8;
            orderInfo.ChargeDeliver = num9;
            if (couponId > 0)
            {
                orderInfo.MoneyTotal = trueTotalMoney;
                orderInfo.CouponId   = couponId;
            }
            else
            {
                orderInfo.MoneyTotal = totalMoney;
            }
            orderInfo.PresentMoney = num5;
            orderInfo.PresentExp   = num6;
            orderInfo.PresentPoint = num7;
            Update(orderInfo);
            ShoppingCart.Delete(cartId);
            SmsConfig smsConfig = SiteConfig.SmsConfig;

            if ((smsConfig.IsAutoSendMessage && !string.IsNullOrEmpty(smsConfig.AdminPhoneNumber)) && !string.IsNullOrEmpty(smsConfig.OrderMessage))
            {
                AbstractMessageOfOrder order = new SmsOfOrder("", SendType.SendToAdmin, smsConfig.AdminPhoneNumber);
                order.Implementor = new OrderFlow(orderInfo, "");
                order.Send();
            }
            return(0x63);
        }
예제 #3
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);
        }