示例#1
0
        public ActionResult GetOpenChoseTables(TableSearchDTO req)
        {
            Response res = new Response();

            res.Data = TableRepository.GetOpenTableChoseList(req);
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        /// <summary>
        /// 根据条件获取台号列表
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public ActionResult GetOpenChoseTables(TableSearchDTO req)
        {
            Response res         = new Response();
            var      currentUser = OperatorProvider.Provider.GetCurrent();

            req.CompanyId = currentUser.CompanyId.ToInt();
            res.Data      = TableServices.GetTableList(req);
            //res.Data = TableRepository.GetOpenTableChoseList(req);
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult GetTables(TableSearchDTO req)
        {
            if (req.ListType == 1)
            {
                req.offset = (req.offset - 1) * req.limit;
            }

            var list = _tableRepository.GetList(out int total, req);

            return(Json(new { rows = list, total = total, code = 0, msg = "" }, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public ActionResult InitAllChangeTableInfo(int restaurantId, OperatorModel user)
        {
            //获取当前餐厅下的区域
            var areas = _areaRepository.GetList(restaurantId);
            //获取当前餐厅下所有台号
            TableSearchDTO req = new TableSearchDTO()
            {
                RestaurantId = restaurantId,
                CythStatus   = CythStatus.在用
            };
            var tables          = _tableHandlerSers.GetTableListForApi(req);
            var customerSources = _extendItemRepository
                                  .GetModelList(user.CompanyId.ToInt(), 10002);
            var orderTypes = _extendItemRepository
                             .GetModelList(user.CompanyId.ToInt(), 10001);
            var customerList = _oldCustRepository.GetListByStatusSimple(null);
            var markets      = _marketRepository.GetList(restaurantId);

            if (markets.Where(x => x.IsDefault).Count() > 1)
            {
                int firstId = markets.Where(x => x.IsDefault).Select(x => x.Id).FirstOrDefault();
                markets.ForEach(x =>
                {
                    if (x.Id != firstId)
                    {
                        x.IsDefault = false;
                    }
                });
            }
            var info = new
            {
                Areas           = areas,
                Tables          = tables,
                CustomerList    = customerList,
                CustomerSources = customerSources,
                Markets         = markets,
                OrderTypes      = orderTypes
            };

            //return new ContentResult
            //{
            //    Content = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }.Serialize(info),
            //    ContentType = "application/json",
            //};
            return(Json(info));
        }
示例#5
0
        public ActionResult InitAllChangeTableInfo(TableSearchDTO req)
        {
            //获取当前餐厅下的区域
            var areas = _areaRepository.GetList(req.RestaurantId);
            //获取当前餐厅下所有区域的空置台号
            var currentUser = OperatorProvider.Provider.GetCurrent();

            req.CompanyId     = currentUser.CompanyId.ToInt();
            req.CythStatus    = CythStatus.空置;
            req.InCludVirtual = false;
            var tables         = _tableServices.GetTableList(req);
            var orderAndTables = _orderRepository.GetOrderAndTablesByOrderTableId(req.OrderTableId);
            var info           = new
            {
                Areas          = areas,
                Tables         = tables,
                OrderAndTables = orderAndTables
            };

            return(Json(info));
        }
示例#6
0
        /// <returns></returns>
        public ActionResult InitChangeTableInfo(int orderTableId, int restaurantId)
        {
            //获取当前台号已点菜品列表
            var orderTableProjects = _orderRepository.GetOrderTableProjects(orderTableId).Where(p => p.CyddMxStatus != CyddMxStatus.保存).ToList() ?? new List <OrderDetailDTO>();//已点菜品,除保存状态的
            //获取当前餐厅下其他开台状态的列表
            var req = new TableSearchDTO()
            {
                CompanyId    = OperatorProvider.Provider.GetCurrent().CompanyId.ToInt(),
                RestaurantId = restaurantId,
                CythStatus   = CythStatus.在用,
                OrderTableId = orderTableId
            };
            var areas  = _areaRepository.GetList(req.RestaurantId);
            var tables = _tableServices.GetTableList(req);
            var info   = new
            {
                Areas = areas,
                OrderTableProjects = orderTableProjects,
                Tables             = tables
            };

            return(Json(info));
        }
示例#7
0
        public List <TableListDTO> GetList(out int total, TableSearchDTO req)
        {
            using (var db = new SqlSugarClient(Connection))
            {
                int    totalCount        = 0;
                string order             = "Id desc";
                List <TableListDTO> list = new List <TableListDTO>();

                if (!string.IsNullOrEmpty(req.Sort))
                {
                    if (req.Sort.Equals("id", StringComparison.OrdinalIgnoreCase))
                    {
                        order = "Id desc";
                    }
                    else
                    {
                        order = string.Format("{0} {1}", req.Sort, req.Order);
                    }
                }
                var sql = db.Queryable <R_Table>()
                          .JoinTable <R_Restaurant>((s1, s2) => s1.R_Restaurant_Id == s2.Id && s2.IsDelete == false)
                          .JoinTable <R_Area>((s1, s3) => s1.R_Area_Id == s3.Id && s3.IsDelete == false)
                          .JoinTable <R_BoxTable>((s1, s4) => s1.Id == s4.R_Table_Id)
                          .JoinTable <R_BoxTable, R_Box>((s1, s4, s5) => s4.R_Box_Id == s5.Id)
                          .Select("s1.*,Restaurant=s2.Name,Area=s3.Name,Box=s5.Name").Where(" s1.IsDelete = 0 ");
                if (req.Restaurant > 0)
                {
                    sql.Where(" s1.R_Restaurant_Id=" + req.Restaurant);
                }
                var data = sql.ToDataTable();

                //根据餐厅查询
                //if (req.Restaurant > 0)
                //{
                //    DataRow[] dr = data.Select(" R_Restaurant_Id=" + req.Restaurant);
                //    DataTable dtNew = data.Clone();
                //    for (int i = 0; i < dr.Length; i++)
                //    {
                //        dtNew.ImportRow(dr[i]);
                //    }
                //    data = dtNew;//重新赋值
                //}

                if (data != null && data.Rows.Count > 0)
                {
                    DataView dtv = data.DefaultView;
                    dtv.Sort   = order;
                    data       = dtv.ToTable();
                    totalCount = data.Rows.Count;
                    var rows    = data.Rows.Cast <DataRow>();
                    var curRows = rows.Skip(req.offset).Take(req.limit).ToArray();

                    foreach (DataRow item in curRows)
                    {
                        list.Add(new TableListDTO()
                        {
                            Id          = Convert.ToInt32(item["id"]),
                            Name        = item["Name"].ToString(),
                            Description = item["Describe"].ToString(),
                            Restaurant  = item["Restaurant"].ToString(),
                            ServerRate  = item.IsNull("ServerRate") ? 0 : Convert.ToDecimal(item["ServerRate"]),
                            Area        = item["Area"].ToString(),
                            SeatNum     = Convert.ToInt32(item["SeatNum"]),
                            Box         = item["Box"].ToString(),
                            Sorted      = Convert.ToInt32(item["Sorted"])
                        });
                    }
                }

                total = totalCount;
                return(list);
            }
        }
示例#8
0
        public List <TableListIndexDTO> GetList(TableSearchDTO req)
        {
            using (var db = new SqlSugarClient(Connection))
            {
                List <TableListIndexDTO> list = new List <TableListIndexDTO>();
                var data = db.Queryable <R_Table>();
                data = data.Where(p => p.IsDelete == false);
                if (req.RestaurantId > 0)
                {
                    data = data.Where(p => p.R_Restaurant_Id == req.RestaurantId);
                }

                if (req.AreaId > 0)
                {
                    data = data.Where(p => p.R_Area_Id == req.AreaId);
                }

                if ((int)req.CythStatus > 0)
                {
                    data = data.Where("CythStatus =" + (int)req.CythStatus);
                }
                data = data.OrderBy(p => p.Sorted);
                if (data.Any())
                {
                    list = data.Select <TableListIndexDTO>(s1 =>
                                                           new TableListIndexDTO()
                    {
                        Id          = s1.Id,
                        Name        = s1.Name,
                        CythStatus  = s1.CythStatus,
                        Description = s1.Describe,
                        SeatNum     = s1.SeatNum,
                        ServerRate  = s1.ServerRate,
                        Restaurant  = s1.R_Restaurant_Id,
                        AreaId      = s1.R_Area_Id,
                        IsVirtual   = s1.IsVirtual,
                        Sorted      = s1.Sorted
                    }).ToList();

                    if (list.Any())
                    {
                        var    tabIds    = list.Select(p => p.Id).ToArray();
                        string tabIdsStr = string.Join(",", tabIds);

                        var orderTabList = db.Queryable <R_OrderTable>()
                                           .JoinTable <R_Order>((s1, s2) => s1.R_Order_Id == s2.Id, JoinType.Left)
                                           .Where <R_Order>((s1, s2) => tabIds.Contains(s1.R_Table_Id) && s2.IsDelete == false &&
                                                            (s2.CyddStatus == CyddStatus.开台 || s2.CyddStatus == CyddStatus.点餐 ||
                                                             s2.CyddStatus == CyddStatus.送厨 || s2.CyddStatus == CyddStatus.用餐中 || s2.CyddStatus == CyddStatus.反结))
                                           .Select <R_Order, TableLinkOrderDTO>((s1, s2) =>
                                                                                new TableLinkOrderDTO()
                        {
                            Id               = s1.Id,
                            CreateDate       = s1.CreateDate,
                            IsCheckOut       = s1.IsCheckOut,
                            IsOpen           = s1.IsOpen,
                            OrderCallType    = s2.CyddCallType,
                            OrderNo          = s2.OrderNo,
                            OrderPersonNum   = s2.PersonNum,
                            OrderStatus      = s2.CyddStatus,
                            OrderCreatedTime = s2.CreateDate,
                            PersonNum        = s1.PersonNum,
                            R_Order_Id       = s1.R_Order_Id,
                            R_Table_Id       = s1.R_Table_Id,
                            IsControl        = s1.IsControl,
                            IsLock           = s1.IsLock,
                            MemberCardId     = s2.MemberCardId,
                            ContactPerson    = s2.ContactPerson,
                            ContactTel       = s2.ContactTel
                        }
                                                                                ).ToList();

                        #region 预定列表

                        var orderTabReverList = db.SqlQuery <BookingTableDTO>($@" 
                                    SELECT OT.Id AS OrderTableId, OT.R_Table_Id AS TableId, 
                                        O.Id AS OrderId, O.ReserveDate AS BookingDate, O.PersonNum, O.ContactPerson, O.ContactTel,
                                        M.Id AS MarketId, M.Name AS MarketName 
                                    FROM dbo.R_OrderTable OT 
                                    INNER JOIN dbo.R_Order O ON O.Id = OT.R_Order_Id 
                                    INNER JOIN dbo.R_Market M ON M.Id = O.R_Market_Id 
                                    WHERE OT.R_Table_Id IN ({tabIdsStr}) AND O.IsDelete=0 AND O.CyddStatus = {(int)CyddStatus.预定} AND DATEDIFF(DAY, GETDATE(), O.ReserveDate)=0 ");

                        #endregion

                        var orderIds = (from od in orderTabList
                                        group od by od.R_Order_Id into g
                                        select g.Key).ToArray();

                        var mxList = db.Queryable <R_OrderDetail>()
                                     .JoinTable <R_OrderTable>((s1, s2) => s1.R_OrderTable_Id == s2.Id)
                                     .Where <R_OrderTable>((s1, s2) => orderIds.Contains(s2.R_Order_Id))
                                     .Select <R_OrderTable, OrderTableProjectDTO>((s1, s2) =>
                                                                                  new OrderTableProjectDTO()
                        {
                            MxId         = s1.Id,
                            OrderTableId = s2.Id,
                            TableId      = s2.R_Table_Id,
                            Price        = s1.Price,
                            Num          = s1.Num,
                            OrderId      = s2.R_Order_Id
                        }).ToList();

                        if (orderTabList.Any() || orderTabReverList.Any())
                        {
                            var mxIds = mxList.Select(p => p.MxId).ToArray();

                            #region 订单明细操作表
                            //var mxRecordList = db.Queryable<R_OrderDetailRecord>().Where(
                            //    p => mxIds.Contains(p.R_OrderDetail_Id) &&
                            //    (p.CyddMxCzType == CyddMxCzType.赠菜 || p.CyddMxCzType == CyddMxCzType.转出 || p.CyddMxCzType == CyddMxCzType.退菜)).ToList();
                            #endregion

                            var extendList = db.Queryable <R_OrderDetailExtend>()
                                             .Where(p => mxIds.Contains(p.R_OrderDetail_Id))
                                             .ToList();

                            foreach (var item in list)
                            {
                                item.OrderList = orderTabReverList.Where(p => p.TableId == item.Id).ToList();

                                //获取当前餐台已开台未结账的关联订单信息
                                var orderTableNows = orderTabList
                                                     .Where(p => p.R_Table_Id == item.Id && !p.IsCheckOut && p.IsOpen);

                                item.OrderNow = new List <OrderTableDTO>();

                                if (orderTableNows.Any())
                                {
                                    foreach (var otn in orderTableNows)
                                    {
                                        var otnModel = new OrderTableDTO()
                                        {
                                            Id              = otn.Id,
                                            OrderId         = otn.R_Order_Id,
                                            IsCheckOut      = otn.IsCheckOut,
                                            IsOpen          = otn.IsOpen,
                                            PersonNum       = otn.PersonNum,
                                            CreateDate      = otn.CreateDate, //订单台号表 记录的时间
                                            OrderNo         = otn.OrderNo,
                                            OrderStatusDesc = otn.OrderStatusDesc,
                                            IsControl       = otn.IsControl,
                                            IsLock          = otn.IsLock,
                                            IsWeiXin        = otn.MemberCardId > 0 ? true : false,
                                            TableId         = otn.R_Table_Id,
                                            ContactTel      = otn.ContactTel,
                                            ContactPerson   = otn.ContactPerson
                                        };

                                        var totalAmount = mxList.Where(
                                            p => p.OrderTableId == otn.Id && p.OrderId == otn.R_Order_Id)
                                                          .Sum(p => p.Price * p.Num);

                                        var totalAmountExtend =
                                            (from ext in extendList
                                             join mx in mxList on ext.R_OrderDetail_Id equals mx.MxId
                                             where mx.OrderTableId == otn.Id && mx.OrderId == otn.R_Order_Id &&
                                             mx.MxId == ext.R_OrderDetail_Id
                                             select new OrderTableDTO
                                        {
                                            TotalAmount = ext.Price * mx.Num
                                        }).ToList().Sum(p => p.TotalAmount);

                                        otnModel.TotalAmount = totalAmount + totalAmountExtend;
                                        item.OrderNow.Add(otnModel);
                                    }
                                }
                            }
                        }
                    }
                }

                return(list);
            }
        }
示例#9
0
        public List <TableListDTO> GetTableListForApi(TableSearchDTO conditionDto)
        {
            List <TableListDTO> list = new List <TableListDTO>();

            int[] resIds    = new int[] { conditionDto.RestaurantId };
            var   tableList = _tableRep.GetTables(resIds, conditionDto.AreaId);

            List <TableLinkOrderDTO> orderTableList = new List <TableLinkOrderDTO>();

            if (conditionDto.CythStatus == CythStatus.在用)
            {
                var statusArray = new int[] { (int)CyddStatus.开台, (int)CyddStatus.点餐,
                                              (int)CyddStatus.用餐中, (int)CyddStatus.送厨, (int)CyddStatus.订单菜品修改 };
                orderTableList = _orderRep.GetOrderTableListBy(
                    tableList.Select(x => x.Id).ToArray(), statusArray);
            }

            foreach (var item in tableList)
            {
                TableListDTO obj = new TableListDTO
                {
                    AreaId       = item.R_Area_Id,
                    Description  = item.Describe,
                    Id           = item.Id,
                    Name         = item.Name,
                    SeatNum      = item.SeatNum,
                    ServerRate   = item.ServerRate,
                    RestaurantId = conditionDto.RestaurantId,
                    CythStatus   = (int)item.CythStatus
                };

                if (conditionDto.CythStatus == CythStatus.在用)
                {
                    List <OrderTableDTO> orderDtoList = new List <OrderTableDTO>();
                    var filerByTableList = orderTableList.Where(x => x.R_Table_Id == item.Id).ToList();
                    //if (conditionDto.OrderTableId > 0)//菜品转台时,去除原来的订单台号
                    //{
                    //    filerByTableList = filerByTableList.Where(x => x.Id != conditionDto.OrderTableId).ToList();
                    //    if (filerByTableList.Count == 0)
                    //        continue;
                    //}
                    foreach (var orderTab in filerByTableList)
                    {
                        OrderTableDTO dto = new OrderTableDTO();
                        dto.Id            = orderTab.Id;
                        dto.IsCheckOut    = orderTab.IsCheckOut;
                        dto.IsOpen        = orderTab.IsOpen;
                        dto.CreateDate    = orderTab.CreateDate;
                        dto.TableId       = orderTab.R_Table_Id;
                        dto.OrderId       = orderTab.R_Order_Id;
                        dto.OrderNo       = orderTab.OrderNo;
                        dto.IsLock        = orderTab.IsLock;
                        dto.ContactPerson = orderTab.ContactPerson;
                        dto.ContactTel    = orderTab.ContactTel;
                        dto.IsControl     = orderTab.IsControl;
                        dto.PersonNum     = orderTab.PersonNum;
                        orderDtoList.Add(dto);
                    }
                    obj.CurrentOrderList = orderDtoList;
                }
                list.Add(obj);
            }

            return(list);
        }
示例#10
0
        public List <TableListDTO> GetTableList(TableSearchDTO conditionDto)
        {
            List <TableListDTO> list = new List <TableListDTO>();
            var resList = _resRep.GetList(conditionDto.CompanyId);//获取此公司(租户)下关联的餐厅信息

            var ids = resList.Select(x => x.Id).ToArray();

            if (conditionDto.RestaurantId > 0)//只取当前餐厅
            {
                ids = ids.Where(x => x == conditionDto.RestaurantId).ToArray();
            }

            var tableList = _tableRep.GetTables(ids, conditionDto.AreaId, conditionDto.CythStatus, conditionDto.InCludVirtual);

            List <TableLinkOrderDTO> orderTableList = new List <TableLinkOrderDTO>();

            if (conditionDto.CythStatus == CythStatus.在用)
            {
                var statusArray = new int[] { (int)CyddStatus.开台, (int)CyddStatus.点餐,
                                              (int)CyddStatus.用餐中, (int)CyddStatus.送厨, (int)CyddStatus.订单菜品修改, (int)CyddStatus.反结 };
                orderTableList = _orderRep.GetOrderTableListBy(
                    tableList.Select(x => x.Id).ToArray(), statusArray);
            }

            foreach (var item in tableList)
            {
                TableListDTO obj = new TableListDTO
                {
                    AreaId      = item.R_Area_Id,
                    Description = item.Describe,
                    Id          = item.Id,
                    Name        = item.Name,
                    SeatNum     = item.SeatNum,
                    ServerRate  = item.ServerRate,
                    Restaurant  = resList
                                  .Where(x => x.Id == item.R_Restaurant_Id)
                                  .Select(x => x.Name).FirstOrDefault(),
                    IsVirtual = item.IsVirtual
                };

                if (conditionDto.CythStatus == CythStatus.在用)
                {
                    List <OrderTableDTO> orderDtoList = new List <OrderTableDTO>();
                    var filerByTableList = orderTableList.Where(x => x.R_Table_Id == item.Id).ToList();
                    if (conditionDto.OrderTableId > 0)//菜品转台时,去除原来的订单台号
                    {
                        filerByTableList = filerByTableList.Where(x => x.Id != conditionDto.OrderTableId).ToList();
                        if (filerByTableList.Count == 0)
                        {
                            continue;
                        }
                    }
                    foreach (var orderTab in filerByTableList)
                    {
                        OrderTableDTO dto = new OrderTableDTO();
                        dto.Id         = orderTab.Id;
                        dto.IsCheckOut = orderTab.IsCheckOut;
                        dto.IsOpen     = orderTab.IsOpen;
                        dto.CreateDate = orderTab.CreateDate;
                        dto.TableId    = orderTab.R_Table_Id;
                        dto.OrderId    = orderTab.R_Order_Id;
                        dto.OrderNo    = orderTab.OrderNo;
                        dto.IsLock     = orderTab.IsLock;
                        dto.IsControl  = orderTab.IsControl;
                        dto.PersonNum  = orderTab.PersonNum;
                        orderDtoList.Add(dto);
                    }
                    obj.CurrentOrderList = orderDtoList;
                }
                list.Add(obj);
            }

            return(list);
        }