Example #1
0
        public ActionResult GetUserRatePlan(string id)
        {
            int    status = -1;
            string msg    = string.Empty;

            double price     = 0;
            int    available = 0;

            WeiXin.Models.Home.RatePlan ratePlan = new WeiXin.Models.Home.RatePlan();

            try
            {
                string key           = HCRequest.GetString("key");
                string hotelweixinId = key.Split('@')[0];
                string userweixinId  = key.Split('@')[1];

                int    hid        = Convert.ToInt32(RouteData.Values["Id"]);
                string roomId     = HCRequest.GetString("roomId");
                string rateplanId = HCRequest.GetString("rateplanId");

                string roomTypeId = roomId + "_" + rateplanId;

                DateTime indate  = Convert.ToDateTime(HCRequest.GetString("indate")).Date;
                DateTime outdate = Convert.ToDateTime(HCRequest.GetString("outdate")).Date;

                int days     = (outdate - indate).Days;
                int hourRoom = Convert.ToInt32(HCRequest.GetString("ishourRoom"));


                string MemberCardRuleJson = ActionController.getMemberCardIntegralRule(userweixinId, hotelweixinId);
                ViewData["MemberCardRuleJson"] = MemberCardRuleJson;
                Hashtable MemberCardRuleJsonobj = Newtonsoft.Json.JsonConvert.DeserializeObject <Hashtable>(MemberCardRuleJson);
                Hashtable ruletable             = Newtonsoft.Json.JsonConvert.DeserializeObject <Hashtable>(MemberCardRuleJsonobj["rule"].ToString());
                double    graderate             = WeiXinPublic.ConvertHelper.ToDouble(ruletable["GradeRate"]);
                ViewData["graderate"] = graderate;


                double reduce = WeiXinPublic.ConvertHelper.ToDouble(ruletable["Reduce"]);
                ViewData["reduce"] = reduce;

                int couponType = WeiXinPublic.ConvertHelper.ToInt(ruletable["CouponType"]);
                ViewData["couponType"] = couponType;

                string firstimgurl = null;
                string ratejson    = ActionController.getratejson(hid, indate, outdate, hotelweixinId, graderate, out firstimgurl, reduce, couponType);

                Hashtable ratejsonobj = Newtonsoft.Json.JsonConvert.DeserializeObject <Hashtable>(ratejson);
                List <WeiXin.Models.Home.Room> roomlist      = Newtonsoft.Json.JsonConvert.DeserializeObject <List <WeiXin.Models.Home.Room> >(ratejsonobj["roomlist"].ToString());
                Dictionary <string, Hashtable> hourroomRates = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, Hashtable> >(ratejsonobj["hourroomRates"].ToString());
                Dictionary <string, Hashtable> roomRates     = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, Hashtable> >(ratejsonobj["roomRates"].ToString());

                if (hourRoom == 1)
                {
                    price     = Convert.ToDouble(hourroomRates[roomTypeId]["Price"]);
                    available = Convert.ToInt32(hourroomRates[roomTypeId]["Available"]);
                    ratePlan  = roomlist.Where(c => c.ID.ToString() == roomId).FirstOrDefault().RateplanList.Where(c => c.ID.ToString() == rateplanId).FirstOrDefault();
                }


                else
                {
                    price     = Convert.ToDouble(roomRates[roomTypeId]["Price"]) * days;
                    available = Convert.ToInt32(roomRates[roomTypeId]["Available"]);
                    ratePlan  = roomlist.Where(c => c.ID.ToString() == roomId).FirstOrDefault().RateplanList.Where(c => c.ID.ToString() == rateplanId).FirstOrDefault();
                }

                if (price > 0 && available > 0 && ratePlan.RateList.Count > 0)
                {
                    status = 0;
                }
            }


            catch
            {
            }


            return(Json(new
            {
                Price = price,
                Rateplanjson = Newtonsoft.Json.JsonConvert.SerializeObject(ratePlan),
                Status = status,
                Mess = msg
            }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult GetRoomPriceList(string id)
        {
            string orderjson = HCRequest.GetString("orderjson");
            string key       = HotelCloud.Common.HCRequest.GetString("key");


            int roomId     = HCRequest.getInt("roomId");
            int rateplanId = HCRequest.getInt("rateplanId");

            string    sql = "select ratejson,updatetime from hotelratejson with (nolock) where hotelid=@hotelid";
            DataTable db  = SQLHelper.Get_DataTable(sql, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
            {
                { "hotelid", new DBParam()
                  {
                      ParamValue = id.ToString()
                  } }
            });

            string ratejson = db.Rows[0]["ratejson"].ToString();
            var    roomlist = Newtonsoft.Json.JsonConvert.DeserializeObject <List <WeiXin.Models.Home.Room> >(ratejson);

            List <WeiXin.Models.Home.RatePlan> rateplanList = new List <WeiXin.Models.Home.RatePlan>();

            roomlist.ForEach(r => { rateplanList.AddRange(r.RateplanList); });
            WeiXin.Models.Home.RatePlan rateplan = rateplanList.Where(c => c.ID == rateplanId).FirstOrDefault();

            if (rateplan == null)
            {
                rateplan          = new WeiXin.Models.Home.RatePlan();
                rateplan.RateList = new List <WeiXin.Models.Home.Rate>();
            }

            rateplan.RateList = rateplan.RateList.Where(c => Convert.ToDateTime(c.Dates).Date >= DateTime.Now.Date && c.Price > 0 && c.Available == 1).ToList();

            sql = "select stockdate, rid, quantity,actualqty,havesale  from roomstock with (nolock) where hid=@hotelid  and   stockdate>= CONVERT(date,GETDATE())";
            DataTable tb = SQLHelper.Get_DataTable(sql, SQLHelper.GetCon(), new Dictionary <string, DBParam>()
            {
                { "hotelid", new DBParam()
                  {
                      ParamValue = id.ToString()
                  } }
            });

            var list_RoomStock = WeiXin.Common.DataTableToEntity.GetEntities <WeiXin.Models.Home.RoomStock>(tb).ToList();



            rateplan.RateList.ForEach(r =>
            {
                var curr_stock = list_RoomStock.Where(c => c.Rid == rateplan.RoomID && c.StockDate == Convert.ToDateTime(r.Dates)).FirstOrDefault();
                r.RoomStock    = curr_stock == null ? 19 : (curr_stock.Quantity - curr_stock.HaveSale > 0 ? curr_stock.Quantity - curr_stock.HaveSale : 0);
            });

            if (rateplan.IsOverBook == 1)
            {
                rateplan.RateList.ForEach(c => { c.RoomStock = 99; });
            }

            rateplan.RateList = rateplan.RateList.Where(c => c.RoomStock > 0).ToList();

            return(Json(new
            {
                Data = Newtonsoft.Json.JsonConvert.SerializeObject(rateplan.RateList)
            }, JsonRequestBehavior.AllowGet));
        }