示例#1
0
        public ActionResult Edit(long id = 0)
        {
            if (id == 0)
            {
                return(View(new PeriodRoom()
                {
                    HotelId = UserContext.CurrentUser.HotelId
                }));
            }
            var info = PeriodRoomBll.GetById(id);

            return(View(info));
        }
        public string GetNewRoomPrice(int type, long fnid, long roomId)
        {
            var now = DateTime.Now;

            var room     = RoomBll.GetById(roomId);
            var roomType = RoomTypeBll.GetById(room.RoomTypeId);

            if (type == (int)KaifangFangshiEnum.钟点房)
            {
                //钟点房
                var hourRoomList = HourRoomBll.GetList(UserContext.CurrentUser.HotelId);
                if (hourRoomList == null || hourRoomList.Count == 0)
                {
                    return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无钟点房方案" }));
                }
                var hourRoom = hourRoomList[0];//默认选择第一个
                if (fnid != 0 && hourRoomList.Any(a => a.Id == fnid))
                {
                    hourRoom = hourRoomList.FirstOrDefault(a => a.Id == fnid);
                }
                var yltime = now.AddMinutes(hourRoom.Minute).ToString("yyyy-MM-dd HH:mm:ss");


                return(JsonConvert.SerializeObject(new { Ret = 0, Id = hourRoom.Id, RoomPrice = hourRoom.Price }));
            }
            else if (type == (int)KaifangFangshiEnum.时段房)
            {
                //时段房
                var periodRoomList = PeriodRoomBll.GetList(UserContext.CurrentUser.HotelId);
                if (periodRoomList == null || periodRoomList.Count == 0)
                {
                    return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无时段房方案" }));
                }

                if (fnid != 0 && periodRoomList.Any(a => a.Id == fnid))
                {
                    var periodRoom  = periodRoomList.FirstOrDefault(a => a.Id == fnid);
                    var CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss");
                    var YlTime      = now.ToShortDateString() + $" {periodRoom.EndPoint}:00:00";
                    return(JsonConvert.SerializeObject(new { Ret = 0, Id = periodRoom.Id, RoomPrice = periodRoom.Price }));
                }

                return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无匹配的时段房方案,请手动选择" }));
            }
            return("");
        }
示例#3
0
        public ActionResult Delete(long id)
        {
            var apiResult = new APIResult();

            try
            {
                PeriodRoomBll.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));
        }
示例#4
0
        public JsonResult Edit(PeriodRoom model)
        {
            var apiResult = new APIResult();

            try
            {
                PeriodRoomBll.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));
        }
        /// <summary>
        /// 根据开房方式获取预离时间,同时绑定钟点房方案id或时段房方案id
        /// 20190828同时绑定价格
        /// </summary>
        /// <returns></returns>
        public string GetYlTimeByKffs(long roomRegId, int type, int rzDays, long fnid = 0, long roomId = 0)
        {
            var roomReg = RoomRegBll.GetById(roomRegId);
            var now     = DateTime.Now;

            if (roomReg != null)
            {
                now = TypeConvert.IntToDateTime(roomReg.RegTime);
            }

            var room     = RoomBll.GetById(roomId);
            var roomType = RoomTypeBll.GetById(room.RoomTypeId);

            if (type == (int)KaifangFangshiEnum.全天房 || type == (int)KaifangFangshiEnum.长包房 || type == (int)KaifangFangshiEnum.免费房)
            {
                var globalFeeSet = GlobalFeeSetBll.GetByHotelId(UserContext.CurrentUser.HotelId);
                if (globalFeeSet == null)
                {
                    return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"), YlTime = "" }));
                }

                var yltime = now;
                //如果是6点,那么当天6点之后开的房间就是第二天中午退房,0点到6点开房就是当天中午退房
                if (now.Hour >= 0 && now.Hour <= globalFeeSet.QTAfterPointToNextDay)
                {
                    //当天中午退房
                    yltime = now.Date.AddDays(rzDays - 1).AddHours(globalFeeSet.QTExitPoint);
                }
                else
                {
                    //第二天中午退房
                    yltime = now.Date.AddDays(1 + (rzDays - 1)).AddHours(globalFeeSet.QTExitPoint);
                }

                if (type != (int)KaifangFangshiEnum.免费房)
                {
                    return(JsonConvert.SerializeObject(new {
                        Ret = 0,
                        CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"),
                        YlTime = yltime.ToString("yyyy-MM-dd HH:mm:ss"),
                        RoomPrice = roomType.Price
                    }));
                }

                return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"), YlTime = yltime.ToString("yyyy-MM-dd HH:mm:ss") }));
            }
            else if (type == (int)KaifangFangshiEnum.钟点房)
            {
                //钟点房
                var hourRoomList = HourRoomBll.GetList(UserContext.CurrentUser.HotelId);
                if (hourRoomList == null || hourRoomList.Count == 0)
                {
                    return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无钟点房方案" }));
                }
                var hourRoom = hourRoomList[0];//默认选择第一个
                if (fnid != 0 && hourRoomList.Any(a => a.Id == fnid))
                {
                    hourRoom = hourRoomList.FirstOrDefault(a => a.Id == fnid);
                }
                var yltime = now.AddMinutes(hourRoom.Minute).ToString("yyyy-MM-dd HH:mm:ss");


                return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss"), YlTime = yltime, Id = hourRoom.Id, RoomPrice = hourRoom.Price }));
            }
            else if (type == (int)KaifangFangshiEnum.时段房)
            {
                //时段房
                var periodRoomList = PeriodRoomBll.GetList(UserContext.CurrentUser.HotelId);
                if (periodRoomList == null || periodRoomList.Count == 0)
                {
                    return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无时段房方案" }));
                }

                if (fnid != 0 && periodRoomList.Any(a => a.Id == fnid))
                {
                    var periodRoom  = periodRoomList.FirstOrDefault(a => a.Id == fnid);
                    var CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss");
                    var YlTime      = now.ToShortDateString() + $" {periodRoom.EndPoint}:00:00";
                    return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = CurrentTime, YlTime = YlTime, Id = periodRoom.Id, RoomPrice = periodRoom.Price }));
                }
                else
                {
                    foreach (var periodRoom in periodRoomList)
                    {
                        if (now.Hour >= periodRoom.StartPoint && now.Hour <= periodRoom.EndPoint)
                        {
                            var CurrentTime = now.ToString("yyyy-MM-dd HH:mm:ss");
                            var YlTime      = now.ToShortDateString() + $" {periodRoom.EndPoint}:00:00";
                            return(JsonConvert.SerializeObject(new { Ret = 0, CurrentTime = CurrentTime, YlTime = YlTime, Id = periodRoom.Id, RoomPrice = periodRoom.Price }));
                        }
                    }
                }

                return(JsonConvert.SerializeObject(new { Ret = -1, Msg = "无匹配的时段房方案,请手动选择" }));
            }
            return("");
        }
示例#6
0
        public string GetPager(int page, int rows)
        {
            var pager = PeriodRoomBll.GetPager(page, rows, UserContext.CurrentUser.HotelId);

            return(JsonConvert.SerializeObject(pager));
        }
示例#7
0
        public string GetPeriodRoomList()
        {
            var list = PeriodRoomBll.GetList(UserContext.CurrentUser.HotelId);

            return(JsonConvert.SerializeObject(list));
        }