Example #1
0
 public void CreateOrderDetails(OrderDetails orderDetails)
 {
     try
     {
         _daoManager.OpenConnection();
         _orderDetailsDao.CreateOrderDetails(orderDetails);
     }
     catch (Exception exception)
     {
         LogHelper.GetInstance().Error(string.Format("[CreateOrderDetails]参数:orderDetails_{0}", JsonConvert.SerializeObject(orderDetails)), exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
 }
Example #2
0
        public Int32 CreateSalesOrder(SalesOrder salesOrder)
        {
            Int32 tranSequence = 0;

            _daoManager.BeginTransaction();
            try
            {
                //日结号
                string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo();
                if (!string.IsNullOrEmpty(dailyStatementNo))
                {
                    Order order = salesOrder.order;
                    order.DailyStatementNo = dailyStatementNo;
                    //分单号
                    Int32 curSubOrderNo = _orderDao.GetCurrentSubOrderNo(order.DeskName);
                    if (curSubOrderNo > 0)
                    {
                        curSubOrderNo++;
                    }
                    else
                    {
                        curSubOrderNo = 1;
                    }
                    order.SubOrderNo = curSubOrderNo;
                    //流水号
                    order.TranSequence = tranSequence = _sysDictionary.GetCurrentTranSequence();
                    string orderNo = _orderDao.CreateOrder(order);
                    order.OrderNo = orderNo;
                    //菜单品项序号
                    int seqNumber = _orderDetailsDao.GetSequenceNum(order.OrderID);
                    foreach (OrderDetails item in salesOrder.orderDetailsList)
                    {
                        item.DailyStatementNo = dailyStatementNo;
                        item.OrderBy          = seqNumber;
                        _orderDetailsDao.CreateOrderDetails(item);
                        seqNumber++;
                    }
                    //折扣信息
                    if (salesOrder.orderDiscountList != null && salesOrder.orderDiscountList.Count > 0)
                    {
                        foreach (OrderDiscount item in salesOrder.orderDiscountList)
                        {
                            item.DailyStatementNo = dailyStatementNo;
                            _orderDiscountDao.CreateOrderDiscount(item);
                        }
                    }
                    //添加打印任务
                    SystemConfig systemConfig = _sysConfigDao.GetSystemConfigInfo();
                    if (systemConfig.IncludeKitchenPrint)
                    {
                        IList <PrintTask> printTaskList = PrintTaskService.GetInstance().GetPrintTaskList(salesOrder, systemConfig.PrintStyle, systemConfig.FollowStyle, systemConfig.PrintType, 1, string.Empty);
                        foreach (PrintTask printTask in printTaskList)
                        {
                            _printTaskDao.InsertPrintTask(printTask);
                        }
                    }
                }
                _daoManager.CommitTransaction();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[CreateSalesOrder]参数:salesOrder_{0}", JsonConvert.SerializeObject(salesOrder)), exception);
                tranSequence = 0;
                _daoManager.RollBackTransaction();
            }
            return(tranSequence);
        }