public JsonResult Edit(long id, string saleName, decimal sale, long roomTypeId, DateTime startDate, DateTime endDate, string remark)
        {
            var apiResult = new APIResult();

            try
            {
                var model = new RoomPrice()
                {
                    Id         = id,
                    SaleName   = saleName,
                    Sale       = sale,
                    RoomTypeId = roomTypeId,
                    StartDate  = TypeConvert.DateTimeToInt(startDate),
                    EndDate    = TypeConvert.DateTimeToInt(endDate),
                    Remark     = remark,
                };
                RoomPriceBll.AddOrUpdate(model, UserContext.CurrentUser.HotelId);
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }

            return(Json(apiResult));
        }
        public ActionResult Edit(long id = 0)
        {
            if (id == 0)
            {
                return(View(new RoomPrice()
                {
                    HotelId = UserContext.CurrentUser.HotelId
                }));
            }
            var info = RoomPriceBll.GetById(id);

            return(View(info));
        }
        public string GetListForReg(long roomTypeId, string tip)
        {
            var models = RoomPriceBll.GetList(UserContext.CurrentUser.HotelId, roomTypeId);

            if (models == null)
            {
                models = new List <RoomPrice>();
            }
            models.Insert(0, new RoomPrice()
            {
                Id = 0, SaleName = tip
            });
            return(JsonConvert.SerializeObject(models));
        }
        /// <summary>
        /// 获取具体房间信息
        /// </summary>
        /// <param name="roomId"></param>
        /// <returns></returns>
        public string GetRoom(long roomId)
        {
            var model = RoomBll.GetById(roomId);
            List <RoomPrice> priceList = null;

            if (model != null)
            {
                //根据房型id获取房价方案
                priceList = RoomPriceBll.GetList(UserContext.CurrentUser.HotelId, model.RoomTypeId);
            }
            else
            {
                model = new Room();
            }
            return(JsonConvert.SerializeObject(new { Room = model, PriceList = priceList }));
        }
        public ActionResult Delete(long id)
        {
            var apiResult = new APIResult();

            try
            {
                RoomPriceBll.DeleteById(id);
            }
            catch (Exception ex)
            {
                apiResult.Ret = -1;
                apiResult.Msg = ex.Message;
                if (!(ex is OperationExceptionFacade))
                {
                    LogFactory.GetLogger().Log(LogLevel.Error, ex);
                }
            }
            return(Json(apiResult));
        }
예제 #6
0
        public ActionResult Edit(long id = 0)
        {
            var hotelId = UserContext.CurrentUser.HotelId;
            //获取房型
            var roomTypeList = RoomTypeBll.GetList(hotelId);

            if (roomTypeList == null)
            {
                roomTypeList = new List <RoomType>();
            }
            //获取所有房价方案
            var roomPriceList = RoomPriceBll.GetList(hotelId);

            if (roomPriceList == null)
            {
                roomPriceList = new List <RoomPrice>();
            }
            //循环房型获取房型对应的房价方案
            foreach (var roomtype in roomTypeList)
            {
                var roomPriceArr = roomPriceList.Where(m => m.RoomTypeId == roomtype.Id || m.RoomTypeId == 0);
                roomtype.RoomPriceList = roomPriceArr.ToList();
            }
            if (id == 0)
            {
                ViewBag.RoomPriceList = roomPriceList;
                ViewBag.RoomTypeList  = roomTypeList;
                return(View(new RoomYd()
                {
                    HotelId = hotelId
                }));
            }
            else
            {
                //获取所有预订的房间
                var roomYdRoomList = RoomYdRoomBll.GetLIst(id);
                if (roomYdRoomList != null && roomYdRoomList.Count > 0)
                {
                    //循环获取房间
                    foreach (var roomtype in roomTypeList)
                    {
                        var roomList = roomYdRoomList.Where(m => m.RoomTypeId == roomtype.Id);
                        if (roomList != null && roomList.Count() > 0)
                        {
                            roomtype.YdRoomList = new List <RoomYdRoom>();
                            foreach (var room in roomList)
                            {
                                if (room.RoomId != 0)
                                {
                                    roomtype.YdRoomList.Add(room);
                                }
                            }
                            roomtype.RoomCount     = roomList.ElementAt(0).RoomCount;
                            roomtype.RoomPriceId   = roomList.ElementAt(0).RoomPriceIdTip;
                            roomtype.RoomPrice     = roomList.ElementAt(0).PriceTip;
                            roomtype.RoomSale      = roomList.ElementAt(0).SaleTip;
                            roomtype.RoomSalePrice = roomList.ElementAt(0).SalePriceTip;
                        }
                        else
                        {
                            roomtype.YdRoomList    = new List <RoomYdRoom>();
                            roomtype.RoomCount     = 0;
                            roomtype.RoomPrice     = roomtype.Price;
                            roomtype.RoomSale      = decimal.Parse("1.00");
                            roomtype.RoomSalePrice = roomtype.Price;
                        }
                    }
                }

                var info = RoomYdBll.GetById(id);
                ViewBag.RoomPriceList = roomPriceList;
                ViewBag.RoomTypeList  = roomTypeList;
                return(View(info));
            }
        }
        public string GetRoomInfo(long roomId)
        {
            var model = RoomBll.GetById(roomId);
            List <RoomPrice> priceList = null;

            if (model != null)
            {
                //根据房型id获取房价方案
                priceList = RoomPriceBll.GetList(UserContext.CurrentUser.HotelId, model.RoomTypeId);
            }
            else
            {
                model = new Room();
            }

            Hotel.Model.RoomReg reg = null;

            if (model.RoomRegId != 0)
            {
                reg = RoomRegBll.GetById(model.RoomRegId);
            }

            var roomType   = RoomTypeBll.GetById(model.RoomTypeId);
            var HolidaySet = HolidaySetBll.GetList(UserContext.CurrentUser.HotelId);
            var WeekendSet = WeekendSetBll.GetByHotelId(UserContext.CurrentUser.HotelId);

            var    SalePrice = model.Price;  //价
            double SaleRate  = 1.0;          //折扣率

            if (roomType.IsAllowWeekendRoom) //周末价判断
            {
                if (WeekendSet.IsMonday && DateTime.Now.DayOfWeek == DayOfWeek.Monday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsTuesday && DateTime.Now.DayOfWeek == DayOfWeek.Tuesday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsWednesday && DateTime.Now.DayOfWeek == DayOfWeek.Wednesday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsThursday && DateTime.Now.DayOfWeek == DayOfWeek.Thursday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsFriday && DateTime.Now.DayOfWeek == DayOfWeek.Friday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsSaturday && DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
                if (WeekendSet.IsSunday && DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
                {
                    SalePrice = roomType.WeekendPrice;
                }
            }
            if (roomType.IsAllowHolidayRoom) //假日价
            {
                foreach (var h in HolidaySet)
                {
                    var start = TypeConvert.IntToDateTime(h.StartDate);
                    var end   = TypeConvert.IntToDateTime(h.EndDate).AddDays(1).AddSeconds(-1); //定位在这天最后一秒
                    if (DateTime.Now > start && DateTime.Now < end)
                    {
                        SalePrice = roomType.HolidayPrice;
                    }
                }
            }



            SaleRate = Convert.ToDouble(SalePrice) / Convert.ToDouble(model.Price);


            return(JsonConvert.SerializeObject(new
            {
                Room = model,
                RoomPrice = roomType.Price,
                SalePrice = SalePrice,
                SaleRate = SaleRate,
                PriceList = priceList,
                RoomReg = reg
            }));
        }
        public string GetSingle(long id)
        {
            var model = RoomPriceBll.GetById(id);

            return(JsonConvert.SerializeObject(model));
        }
        public string GetAllList()
        {
            var models = RoomPriceBll.GetAllList(UserContext.CurrentUser.HotelId);

            return(JsonConvert.SerializeObject(models));
        }
        public string GetList(long roomTypeId = 0)
        {
            var models = RoomPriceBll.GetList(UserContext.CurrentUser.HotelId, roomTypeId);

            return(JsonConvert.SerializeObject(models));
        }
        public string GetPager(int page, int rows, long roomTypeId = 0)
        {
            var pager = RoomPriceBll.GetPager(page, rows, UserContext.CurrentUser.HotelId, roomTypeId);

            return(JsonConvert.SerializeObject(pager));
        }