Beispiel #1
0
        public static int CreatOrder(OrderInfo orderInfo, bool isUseBalance, decimal remainingMondy)
        {
            int num = 0;

            if (orderInfo.GetTotal() <= 0M)
            {
                orderInfo.OrderStatus = OrderStatus.BuyerAlreadyPaid;
                orderInfo.PayDate     = new DateTime?(DateTime.Now);
            }
            if ((orderInfo.PaymentType == null) && (orderInfo.PointExchange > 0))
            {
                orderInfo.PaymentType   = "积分抵现";
                orderInfo.Gateway       = "hishop.plugins.payment.pointtocach";
                orderInfo.PaymentTypeId = 0x4d;
            }
            else if (((orderInfo.PaymentType == null) && orderInfo.RedPagerID.HasValue) && (orderInfo.RedPagerID.Value > 0))
            {
                orderInfo.PaymentType   = "优惠券抵扣";
                orderInfo.Gateway       = "hishop.plugins.payment.coupontocach";
                orderInfo.PaymentTypeId = 0x37;
            }
            MemberInfo currentMember = MemberProcessor.GetCurrentMember();
            Database   database      = DatabaseFactory.CreateDatabase();
            int        quantity      = orderInfo.LineItems.Sum <KeyValuePair <string, LineItemInfo> >((Func <KeyValuePair <string, LineItemInfo>, int>)(item => item.Value.Quantity));

            lock (createOrderLocker)
            {
                if (orderInfo.GroupBuyId > 0)
                {
                    checkCanGroupBuy(quantity, orderInfo.GroupBuyId);
                }
                using (DbConnection connection = database.CreateConnection())
                {
                    connection.Open();
                    DbTransaction dbTran = connection.BeginTransaction();
                    try
                    {
                        orderInfo.ClientShortType = (ClientShortType)Globals.GetClientShortType();
                        if (!new OrderDao().CreatOrder(orderInfo, dbTran))
                        {
                            dbTran.Rollback();
                            return(0);
                        }
                        if (orderInfo.LineItems.Count > 0)
                        {
                            if (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)
                            {
                                foreach (LineItemInfo info2 in orderInfo.LineItems.Values)
                                {
                                    info2.OrderItemsStatus = OrderStatus.BuyerAlreadyPaid;
                                }
                            }
                            if (!new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTran))
                            {
                                dbTran.Rollback();
                                return(0);
                            }
                        }
                        if (!string.IsNullOrEmpty(orderInfo.CouponCode) && !new CouponDao().AddCouponUseRecord(orderInfo, dbTran))
                        {
                            dbTran.Rollback();
                            return(0);
                        }
                        foreach (LineItemInfo info3 in orderInfo.LineItems.Values)
                        {
                            if ((info3.Type == 1) && (info3.ExchangeId > 0))
                            {
                                PointExchangeChangedInfo info4 = new PointExchangeChangedInfo();
                                info4 = new PointExchangeChangedInfo {
                                    exChangeId   = info3.ExchangeId,
                                    exChangeName = new OrderDao().GetexChangeName(info4.exChangeId),
                                    ProductId    = info3.ProductId,
                                    PointNumber  = info3.PointNumber,
                                    MemberID     = orderInfo.UserId,
                                    Date         = DateTime.Now,
                                    MemberGrades = currentMember.GradeId
                                };
                                if (!new OrderDao().InsertPointExchange_Changed(info4, dbTran, info3.Quantity))
                                {
                                    dbTran.Rollback();
                                    return(0);
                                }
                                IntegralDetailInfo point = new IntegralDetailInfo {
                                    IntegralChange     = -info3.PointNumber,
                                    IntegralSource     = "积分兑换商品-订单号:" + orderInfo.OrderMarking,
                                    IntegralSourceType = 2,
                                    Remark             = "积分兑换商品",
                                    Userid             = orderInfo.UserId,
                                    GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId,
                                    IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.IntegralExchange)
                                };
                                if (!new IntegralDetailDao().AddIntegralDetail(point, dbTran))
                                {
                                    dbTran.Rollback();
                                    return(0);
                                }
                            }
                        }
                        if (orderInfo.PointExchange > 0)
                        {
                            IntegralDetailInfo info6 = new IntegralDetailInfo {
                                IntegralChange     = -orderInfo.PointExchange,
                                IntegralSource     = "积分抵现,订单号:" + orderInfo.OrderId,
                                IntegralSourceType = 2,
                                Remark             = "",
                                Userid             = orderInfo.UserId,
                                GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId,
                                IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.NowArrived)
                            };
                            if (!new IntegralDetailDao().AddIntegralDetail(info6, dbTran))
                            {
                                dbTran.Rollback();
                                return(0);
                            }
                        }
                        if ((orderInfo.RedPagerID > 0) && !new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTran))
                        {
                            dbTran.Rollback();
                            return(0);
                        }
                        dbTran.Commit();
                        num = 1;
                        if (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)
                        {
                            num = 2;
                        }
                    }
                    catch
                    {
                        dbTran.Rollback();
                        throw;
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
            }
            if (isUseBalance && (num == 1))
            {
                OrderDao dao = new OrderDao();
                orderInfo = dao.GetOrderInfo(orderInfo.OrderId);
                lock (BalanceUpdateLock)
                {
                    num = OrderBalanceUpdate(orderInfo, currentMember.UserId, remainingMondy);
                    if (num != 2)
                    {
                        return(num);
                    }
                    dao.UpdatePayOrderStock(orderInfo);
                    string str = "";
                    foreach (LineItemInfo info7 in orderInfo.LineItems.Values)
                    {
                        ProductDao dao2 = new ProductDao();
                        str = str + "'" + info7.SkuId + "',";
                        ProductInfo productDetails = dao2.GetProductDetails(info7.ProductId);
                        productDetails.SaleCounts     += info7.Quantity;
                        productDetails.ShowSaleCounts += info7.Quantity;
                        dao2.UpdateProduct(productDetails, null);
                    }
                }
            }
            return(num);
        }
Beispiel #2
0
        public static int CreatOrder(OrderInfo orderInfo, bool isUseBalance, decimal remainingMondy)
        {
            int num = 0;

            if (orderInfo.GetTotal() <= 0m)
            {
                orderInfo.OrderStatus = OrderStatus.BuyerAlreadyPaid;
                orderInfo.PayDate     = new DateTime?(DateTime.Now);
            }
            if (orderInfo.PaymentType == null && orderInfo.PointExchange > 0)
            {
                orderInfo.PaymentType   = "积分抵现";
                orderInfo.Gateway       = "hishop.plugins.payment.pointtocach";
                orderInfo.PaymentTypeId = 77;
            }
            else if (orderInfo.PaymentType == null && orderInfo.RedPagerID.HasValue && orderInfo.RedPagerID.Value > 0)
            {
                orderInfo.PaymentType   = "优惠券抵扣";
                orderInfo.Gateway       = "hishop.plugins.payment.coupontocach";
                orderInfo.PaymentTypeId = 55;
            }
            MemberInfo currentMember = MemberProcessor.GetCurrentMember();
            Database   database      = DatabaseFactory.CreateDatabase();
            int        quantity      = orderInfo.LineItems.Sum((KeyValuePair <string, LineItemInfo> item) => item.Value.Quantity);
            int        result;

            lock (ShoppingProcessor.createOrderLocker)
            {
                if (orderInfo.GroupBuyId > 0)
                {
                    ShoppingProcessor.checkCanGroupBuy(quantity, orderInfo.GroupBuyId);
                }
                using (System.Data.Common.DbConnection dbConnection = database.CreateConnection())
                {
                    dbConnection.Open();
                    System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                    try
                    {
                        orderInfo.ClientShortType = (ClientShortType)Globals.GetClientShortType();
                        if (!new OrderDao().CreatOrder(orderInfo, dbTransaction))
                        {
                            dbTransaction.Rollback();
                            result = 0;
                            return(result);
                        }
                        if (orderInfo.LineItems.Count > 0)
                        {
                            if (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)
                            {
                                foreach (LineItemInfo lineItemInfo in orderInfo.LineItems.Values)
                                {
                                    lineItemInfo.OrderItemsStatus = OrderStatus.BuyerAlreadyPaid;
                                }
                            }
                            if (!new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = 0;
                                return(result);
                            }
                        }
                        if (!string.IsNullOrEmpty(orderInfo.CouponCode))
                        {
                            if (!new CouponDao().AddCouponUseRecord(orderInfo, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = 0;
                                return(result);
                            }
                        }


                        ICollection values = orderInfo.LineItems.Values;
                        foreach (LineItemInfo lineItemInfo in values)
                        {
                            if (lineItemInfo.Type == 1)
                            {
                                if (lineItemInfo.ExchangeId > 0)
                                {
                                    PointExchangeChangedInfo pointExchangeChangedInfo = new PointExchangeChangedInfo();
                                    pointExchangeChangedInfo.exChangeId   = lineItemInfo.ExchangeId;
                                    pointExchangeChangedInfo.exChangeName = new OrderDao().GetexChangeName(pointExchangeChangedInfo.exChangeId);
                                    pointExchangeChangedInfo.ProductId    = lineItemInfo.ProductId;
                                    pointExchangeChangedInfo.PointNumber  = lineItemInfo.PointNumber;
                                    pointExchangeChangedInfo.MemberID     = orderInfo.UserId;
                                    pointExchangeChangedInfo.Date         = DateTime.Now;
                                    pointExchangeChangedInfo.MemberGrades = currentMember.GradeId;
                                    if (!new OrderDao().InsertPointExchange_Changed(pointExchangeChangedInfo, dbTransaction, lineItemInfo.Quantity))
                                    {
                                        dbTransaction.Rollback();
                                        result = 0;
                                        return(result);
                                    }
                                    IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo();
                                    integralDetailInfo.IntegralChange     = -lineItemInfo.PointNumber;
                                    integralDetailInfo.IntegralSource     = "积分兑换商品-订单号:" + orderInfo.OrderMarking;
                                    integralDetailInfo.IntegralSourceType = 2;
                                    integralDetailInfo.Remark             = "积分兑换商品";
                                    integralDetailInfo.Userid             = orderInfo.UserId;
                                    integralDetailInfo.GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId;
                                    integralDetailInfo.IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.IntegralExchange);
                                    if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction))
                                    {
                                        dbTransaction.Rollback();
                                        result = 0;
                                        return(result);
                                    }
                                }
                            }
                        }
                        if (orderInfo.PointExchange > 0)
                        {
                            IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo();
                            integralDetailInfo.IntegralChange     = -orderInfo.PointExchange;
                            integralDetailInfo.IntegralSource     = "积分抵现,订单号:" + orderInfo.OrderId;
                            integralDetailInfo.IntegralSourceType = 2;
                            integralDetailInfo.Remark             = "";
                            integralDetailInfo.Userid             = orderInfo.UserId;
                            integralDetailInfo.GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId;
                            integralDetailInfo.IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.NowArrived);
                            if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = 0;
                                return(result);
                            }
                        }
                        if (orderInfo.RedPagerID > 0)
                        {
                            if (!new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = 0;
                                return(result);
                            }
                        }
                        dbTransaction.Commit();
                        num = 1;
                        if (orderInfo.OrderStatus == OrderStatus.BuyerAlreadyPaid)
                        {
                            num = 2;
                        }
                    }
                    catch
                    {
                        dbTransaction.Rollback();
                        throw;
                    }
                    finally
                    {
                        dbConnection.Close();
                    }
                }
            }
            if (isUseBalance && num == 1)
            {
                orderInfo = new OrderDao().GetOrderInfo(orderInfo.OrderId);
                lock (ShoppingProcessor.BalanceUpdateLock)
                {
                    num = ShoppingProcessor.OrderBalanceUpdate(orderInfo, currentMember.UserId, remainingMondy);
                }
            }
            result = num;
            return(result);
        }
Beispiel #3
0
        public static bool CreatOrder(OrderInfo orderInfo)//添加订单记录
        {
            bool flag = false;

            if (orderInfo.GetTotal() == 0M)
            {
                orderInfo.OrderStatus = OrderStatus.BuyerAlreadyPaid;
            }
            Database database = DatabaseFactory.CreateDatabase();
            //if (CS$<>9__CachedAnonymousMethodDelegate2 == null)
            //{
            //    CS$<>9__CachedAnonymousMethodDelegate2 = new Func<KeyValuePair<string, LineItemInfo>, int>(null, (IntPtr) <CreatOrder>b__1);
            //}
            //int quantity = Enumerable.Sum<KeyValuePair<string, LineItemInfo>>(orderInfo.LineItems, CS$<>9__CachedAnonymousMethodDelegate2);
            int quantity = orderInfo.LineItems.Sum <KeyValuePair <string, LineItemInfo> >((Func <KeyValuePair <string, LineItemInfo>, int>)(item => item.Value.Quantity));

            lock (createOrderLocker)
            {
                if (orderInfo.GroupBuyId > 0)
                {
                    checkCanGroupBuy(quantity, orderInfo.GroupBuyId);
                }
                using (DbConnection connection = database.CreateConnection())
                {
                    connection.Open();
                    DbTransaction dbTran = connection.BeginTransaction();
                    try
                    {
                        try
                        {
                            IntegralDetailInfo info4;
                            orderInfo.ClientShortType = (ClientShortType)Globals.GetClientShortType();
                            if (!new OrderDao().CreatOrder(orderInfo, dbTran))//添加订单记录
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            if ((orderInfo.LineItems.Count > 0) && !new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTran))
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            if (!string.IsNullOrEmpty(orderInfo.CouponCode) && !new CouponDao().AddCouponUseRecord(orderInfo, dbTran))
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            ICollection values        = orderInfo.LineItems.Values;
                            MemberInfo  currentMember = MemberProcessor.GetCurrentMember();
                            foreach (LineItemInfo info2 in values)
                            {
                                if ((info2.Type == 1) && (info2.ExchangeId > 0))
                                {
                                    PointExchangeChangedInfo info3;
                                    info3 = new PointExchangeChangedInfo {
                                        exChangeId   = info2.ExchangeId,
                                        exChangeName = new OrderDao().GetexChangeName(info2.ExchangeId),
                                        ProductId    = info2.ProductId,
                                        PointNumber  = info2.PointNumber,
                                        MemberID     = orderInfo.UserId,
                                        Date         = DateTime.Now,
                                        MemberGrades = currentMember.GradeId
                                    };
                                    if (!new OrderDao().InsertPointExchange_Changed(info3, dbTran, info2.Quantity))
                                    {
                                        dbTran.Rollback();
                                        return(false);
                                    }
                                    info4 = new IntegralDetailInfo {
                                        IntegralChange     = -info2.PointNumber,
                                        IntegralSource     = "积分兑换商品-订单号:" + orderInfo.OrderMarking,
                                        IntegralSourceType = 2,
                                        Remark             = "积分兑换商品",
                                        Userid             = orderInfo.UserId,
                                        GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId,
                                        IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.IntegralExchange)
                                    };
                                    if (!new IntegralDetailDao().AddIntegralDetail(info4, dbTran))
                                    {
                                        dbTran.Rollback();
                                        return(false);
                                    }
                                }
                            }
                            if (orderInfo.PointExchange > 0)
                            {
                                info4 = new IntegralDetailInfo {
                                    IntegralChange     = -orderInfo.PointExchange,
                                    IntegralSource     = "积分抵现-订单号:" + orderInfo.OrderMarking,
                                    IntegralSourceType = 2,
                                    Remark             = "积分抵现",
                                    Userid             = orderInfo.UserId,
                                    GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId,
                                    IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.NowArrived)
                                };
                                if (!new IntegralDetailDao().AddIntegralDetail(info4, dbTran))
                                {
                                    dbTran.Rollback();
                                    return(false);
                                }
                            }
                            if ((orderInfo.RedPagerID > 0) && !new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTran))
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            dbTran.Commit();
                            flag = true;
                        }
                        catch
                        {
                            dbTran.Rollback();
                            throw;
                        }
                        return(flag);
                    }
                    finally
                    {
                        connection.Close();
                    }
                }
            }
            return(flag);
        }
Beispiel #4
0
        public static bool CreatOrder(OrderInfo orderInfo)
        {
            bool flag = false;

            if (orderInfo.GetTotal() == 0m)
            {
                orderInfo.OrderStatus = OrderStatus.BuyerAlreadyPaid;
            }
            Database database = DatabaseFactory.CreateDatabase();
            int      quantity = orderInfo.LineItems.Sum((KeyValuePair <string, LineItemInfo> item) => item.Value.Quantity);
            bool     result;

            lock (ShoppingProcessor.createOrderLocker)
            {
                if (orderInfo.GroupBuyId > 0)
                {
                    ShoppingProcessor.checkCanGroupBuy(quantity, orderInfo.GroupBuyId);
                }
                using (System.Data.Common.DbConnection dbConnection = database.CreateConnection())
                {
                    dbConnection.Open();
                    System.Data.Common.DbTransaction dbTransaction = dbConnection.BeginTransaction();
                    try
                    {
                        orderInfo.ClientShortType = (ClientShortType)Globals.GetClientShortType();
                        if (!new OrderDao().CreatOrder(orderInfo, dbTransaction))
                        {
                            dbTransaction.Rollback();
                            result = false;
                            return(result);
                        }
                        if (orderInfo.LineItems.Count > 0)
                        {
                            if (!new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = false;
                                return(result);
                            }
                        }
                        if (!string.IsNullOrEmpty(orderInfo.CouponCode))
                        {
                            if (!new CouponDao().AddCouponUseRecord(orderInfo, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = false;
                                return(result);
                            }
                        }
                        ICollection values        = orderInfo.LineItems.Values;
                        MemberInfo  currentMember = MemberProcessor.GetCurrentMember();
                        foreach (LineItemInfo lineItemInfo in values)
                        {
                            if (lineItemInfo.Type == 1)
                            {
                                if (lineItemInfo.ExchangeId > 0)
                                {
                                    PointExchangeChangedInfo pointExchangeChangedInfo = new PointExchangeChangedInfo();
                                    pointExchangeChangedInfo.exChangeId   = lineItemInfo.ExchangeId;
                                    pointExchangeChangedInfo.exChangeName = new OrderDao().GetexChangeName(pointExchangeChangedInfo.exChangeId);
                                    pointExchangeChangedInfo.ProductId    = lineItemInfo.ProductId;
                                    pointExchangeChangedInfo.PointNumber  = lineItemInfo.PointNumber;
                                    pointExchangeChangedInfo.MemberID     = orderInfo.UserId;
                                    pointExchangeChangedInfo.Date         = DateTime.Now;
                                    pointExchangeChangedInfo.MemberGrades = currentMember.GradeId;
                                    if (!new OrderDao().InsertPointExchange_Changed(pointExchangeChangedInfo, dbTransaction, lineItemInfo.Quantity))
                                    {
                                        dbTransaction.Rollback();
                                        result = false;
                                        return(result);
                                    }
                                    IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo();
                                    integralDetailInfo.IntegralChange     = -lineItemInfo.PointNumber;
                                    integralDetailInfo.IntegralSource     = "积分兑换商品-订单号:" + orderInfo.OrderMarking;
                                    integralDetailInfo.IntegralSourceType = 2;
                                    integralDetailInfo.Remark             = "积分兑换商品";
                                    integralDetailInfo.Userid             = orderInfo.UserId;
                                    integralDetailInfo.GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId;
                                    integralDetailInfo.IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.IntegralExchange);
                                    if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction))
                                    {
                                        dbTransaction.Rollback();
                                        result = false;
                                        return(result);
                                    }
                                }
                            }
                        }
                        if (orderInfo.PointExchange > 0)
                        {
                            IntegralDetailInfo integralDetailInfo = new IntegralDetailInfo();
                            integralDetailInfo.IntegralChange     = -orderInfo.PointExchange;
                            integralDetailInfo.IntegralSource     = "积分抵现-订单号:" + orderInfo.OrderMarking;
                            integralDetailInfo.IntegralSourceType = 2;
                            integralDetailInfo.Remark             = "积分抵现";
                            integralDetailInfo.Userid             = orderInfo.UserId;
                            integralDetailInfo.GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId;
                            integralDetailInfo.IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.NowArrived);
                            if (!new IntegralDetailDao().AddIntegralDetail(integralDetailInfo, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = false;
                                return(result);
                            }
                        }
                        if (orderInfo.RedPagerID > 0)
                        {
                            if (!new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTransaction))
                            {
                                dbTransaction.Rollback();
                                result = false;
                                return(result);
                            }
                        }
                        dbTransaction.Commit();
                        flag = true;
                    }
                    catch
                    {
                        dbTransaction.Rollback();
                        throw;
                    }
                    finally
                    {
                        dbConnection.Close();
                    }
                }
            }
            result = flag;
            return(result);
        }
Beispiel #5
0
        public static bool CreatOrder(OrderInfo orderInfo)
        {
            bool     flag     = false;
            Database database = DatabaseFactory.CreateDatabase();
            int      quantity = orderInfo.LineItems.Sum <KeyValuePair <string, LineItemInfo> >((Func <KeyValuePair <string, LineItemInfo>, int>)(item => item.Value.Quantity));

            lock (createOrderLocker)
            {
                if (orderInfo.GroupBuyId > 0)
                {
                    checkCanGroupBuy(quantity, orderInfo.GroupBuyId);
                }
                using (DbConnection connection = database.CreateConnection())
                {
                    connection.Open();
                    DbTransaction dbTran = connection.BeginTransaction();
                    try
                    {
                        try
                        {
                            if (!new OrderDao().CreatOrder(orderInfo, dbTran))
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            if ((orderInfo.LineItems.Count > 0) && !new LineItemDao().AddOrderLineItems(orderInfo.OrderId, orderInfo.LineItems.Values, dbTran))
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            if (!string.IsNullOrEmpty(orderInfo.CouponCode) && !new CouponDao().AddCouponUseRecord(orderInfo, dbTran))
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            ICollection values        = orderInfo.LineItems.Values;
                            MemberInfo  currentMember = MemberProcessor.GetCurrentMember();
                            foreach (LineItemInfo info2 in values)
                            {
                                if ((info2.Type == 1) && (info2.ExchangeId > 0))
                                {
                                    PointExchangeChangedInfo info3 = new PointExchangeChangedInfo();
                                    info3.exChangeId   = info2.ExchangeId;
                                    info3.exChangeName = new OrderDao().GetexChangeName(info3.exChangeId);
                                    info3.ProductId    = info2.ProductId;
                                    info3.PointNumber  = info2.PointNumber;
                                    info3.MemberID     = orderInfo.UserId;
                                    info3.Date         = DateTime.Now;
                                    info3.MemberGrades = currentMember.GradeId;

                                    if (!new OrderDao().InsertPointExchange_Changed(info3, dbTran, info2.Quantity))
                                    {
                                        dbTran.Rollback();
                                        return(false);
                                    }
                                    IntegralDetailInfo point = new IntegralDetailInfo
                                    {
                                        IntegralChange     = -info2.PointNumber,
                                        IntegralSource     = "积分兑换商品-订单号:" + orderInfo.OrderMarking,
                                        IntegralSourceType = 2,
                                        Remark             = "积分兑换商品",
                                        Userid             = orderInfo.UserId,
                                        GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId,
                                        IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.IntegralExchange)
                                    };
                                    if (!new IntegralDetailDao().AddIntegralDetail(point, dbTran))
                                    {
                                        dbTran.Rollback();
                                        return(false);
                                    }
                                }
                            }
                            if (orderInfo.PointExchange > 0)
                            {
                                IntegralDetailInfo info5 = new IntegralDetailInfo
                                {
                                    IntegralChange     = -orderInfo.PointExchange,
                                    IntegralSource     = "积分抵现-订单号:" + orderInfo.OrderMarking,
                                    IntegralSourceType = 2,
                                    Remark             = "积分抵现",
                                    Userid             = orderInfo.UserId,
                                    GoToUrl            = Globals.ApplicationPath + "/Vshop/MemberOrderDetails.aspx?OrderId=" + orderInfo.OrderId,
                                    IntegralStatus     = Convert.ToInt32(IntegralDetailStatus.NowArrived)
                                };
                                if (!new IntegralDetailDao().AddIntegralDetail(info5, dbTran))
                                {
                                    dbTran.Rollback();
                                    return(false);
                                }
                            }
                            if ((orderInfo.RedPagerID > 0) && !new OrderDao().UpdateCoupon_MemberCoupons(orderInfo, dbTran))
                            {
                                dbTran.Rollback();
                                return(false);
                            }
                            if (orderInfo.GroupBuyId > 0)
                            {
                                GroupBuyDao  dao      = new GroupBuyDao();
                                GroupBuyInfo groupBuy = dao.GetGroupBuy(orderInfo.GroupBuyId, dbTran);
                                groupBuy.SoldCount += quantity;
                                dao.UpdateGroupBuy(groupBuy, dbTran);
                                dao.RefreshGroupBuyFinishState(orderInfo.GroupBuyId, dbTran);
                            }
                            dbTran.Commit();
                            flag = true;
                        }
                        catch
                        {
                            dbTran.Rollback();
                            throw;
                        }
                        return(flag);
                    }
                    finally
                    {
                        connection.Close();
                    }
                    return(flag);
                }
            }
            return(flag);
        }