Пример #1
0
        public ActionResult LockRoom(AppointRq rq)
        {
            if (MemberInfo.Role != (int)MemberRole.管理员)
            {
                return(Content("没有权限"));
            }

            var model = new Order
            {
                MemberId    = MemberInfo.Uid,
                CustomName  = "",
                CustomPhone = "",
                Room        = rq.Room,
                Status      = (int)OrderStatus.已锁定,
                CreateOn    = DateTime.Now.ToUnixStamp(),
                StartTime   = rq.Start.ToUnixStamp(),
                EndTime     = rq.Start.AddMinutes(WeispaConfig.ServiceMinutes).ToUnixStamp(),
                Remark      = rq.Remark
            };

            var isExist = OrderDal.Exists(string.Format("{0} and Room={1} and (Status={2} or Status={3})",
                                                        WeispaUtil.GetOccurredSql(model.StartTime, model.EndTime),
                                                        model.Room, (int)OrderStatus.已确认, (int)OrderStatus.已锁定));

            if (isExist)
            {
                return(ReturnJson(false, "改房间已被预订,请先取消预订才可锁定"));
            }

            var orderId = OrderDal.Add(model);

            return(ReturnJson(true, new { status = 2, opts = 2, orderId }));
        }
Пример #2
0
        public ActionResult AppointPost(AppointRq rq)
        {
            var now       = DateTime.Now;
            var today     = now.Date;
            var limitDate = today.AddDays(WeispaConfig.LimitDays);

            if (string.IsNullOrEmpty(rq.CustomName))
            {
                return(ReturnJson(false, "请填写客户名称"));
            }
            if (string.IsNullOrEmpty(rq.CustomPhone))
            {
                return(ReturnJson(false, "请填写客户电话"));
            }
            if (rq.Room > 1 || rq.Room < 0)
            {
                return(ReturnJson(false, "请选择房间"));
            }

            if (rq.Start > limitDate)
            {
                return(ReturnJson(false, string.Format("只能预订{0}天内", WeispaConfig.LimitDays)));
            }
            if (rq.Start < now)
            {
                return(ReturnJson(false, "已过时间不可预订"));
            }

            //未确认,已确认的订单数
            var weekCount = OrderDal.GetCount(string.Format("MemberId={0} and StartTime>={1} and StartTime<{2} and Status<2", MemberInfo.Uid, now.ToUnixStamp(), limitDate.ToUnixStamp()));

            if (weekCount >= WeispaConfig.LimitOrderCount && MemberInfo.Role != (int)MemberRole.管理员)
            {
                return(ReturnJson(false, string.Format("{0}天内只能预订{1}次", WeispaConfig.LimitDays, WeispaConfig.LimitOrderCount)));
            }

            var model = new Order
            {
                MemberId    = MemberInfo.Uid,
                CustomName  = rq.CustomName,
                CustomPhone = rq.CustomPhone,
                Room        = rq.Room,
                Status      = 0,
                CreateOn    = now.ToUnixStamp(),
                StartTime   = rq.Start.ToUnixStamp(),
                EndTime     = rq.Start.AddMinutes(WeispaConfig.ServiceMinutes).ToUnixStamp(),
                Remark      = rq.Remark
            };

            //查找有冲突的订单
            var isExist = OrderDal.Exists(string.Format("{0} and Room={1} and (Status={2} or Status={3})",
                                                        WeispaUtil.GetOccurredSql(model.StartTime, model.EndTime),
                                                        model.Room, (int)OrderStatus.已确认, (int)OrderStatus.已锁定));

            if (isExist)
            {
                return(ReturnJson(false, "该房间已被其他人预订"));
            }

            OrderDal.Add(model);

            return(ReturnJson(true, "已成功提交预订,待系统确认"));
        }
Пример #3
0
 public int Add(Order order)
 {
     return(dal.Add(order));
 }