Example #1
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);
        }
Example #2
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);
        }