public static List <RateXzByRmType> GetRateCodexzByRoomtype(yudingEntities db, string starttimeStr, string endtimeStr, string roomtype, string hotelcode, int type) { db = new yudingEntities(); var time = DateTime.Parse(starttimeStr); var week = (int)time.DayOfWeek; var end = DateTimeHelper.GetTimeStamp(DateTime.Parse(endtimeStr)); var XzList = db.GetRcListByRoomType(roomtype, hotelcode, DateTime.Parse(starttimeStr)).ToList().GroupBy(x => x.xz_code).OrderByDescending(x => x.FirstOrDefault().px); var yuanjia = db.newroom_t.Where(x => x.roomtype == roomtype).FirstOrDefault(); var list = new List <RateXzByRmType>(); var d = db.ratecode_t.Where(x => x.hotelid == hotelcode && x.scenario == 1 && x.flag == 0 && x.type == type).FirstOrDefault().ratecode; string URL = Config.WxAPIUrl + "/API/GetWX.ashx?action=GetGZHxx"; var postData = "hotelcode=" + hotelcode; var result = HttpHepler.SendPost(URL, postData); HotelInfoJson info = JsonConvert.DeserializeObject <HotelInfoJson>(result); var data = info.data[0]; GetRoomAvailResult room = null; if (info.data[0].LvyunHotelgroupId != "" && info.data[0].LvyunHotelgroupId != null) { //var data = info.data[0]; room = PmsAPI.GetRoomAvail(data.orderUrl, data.LvyunHotelgroupId, data.LvyunHotelId, time.ToString("yyyy-MM-dd"), time.ToString("yyyy-MM-dd"), yuanjia.pms); } foreach (var item in XzList) { var xzcode = item.FirstOrDefault().xz_code; var rate = db.rateroom_xz.Where(x => x.xz_code == xzcode).FirstOrDefault(); var c = db.xztimestart_t.Where(x => x.startdate <= time && x.enddate >= time && x.xz_code == xzcode && x.flag == 0 && x.week == week.ToString()).FirstOrDefault(); //c.starttime // if (rate.ratecode == d && item.FirstOrDefault().price != 0) { if (c != null) { var m1 = c.starttime == "" ? "00:00" : c.starttime; var m2 = c.endtime == "" ? "23:59" : c.endtime; var t1 = DateTime.Parse(m1); var t2 = DateTime.Parse(m2); if (DateTime.Now >= t1 && DateTime.Now <= t2) { //if(DateTime.Now>=DateTime.Parse(c.starttime)&&DateTime.Now<=DateTime.Parse(c.endtime)) Nullable <int> sum = 0; foreach (var item1 in XzList) { sum += item1.FirstOrDefault().ordernum; } var price = db.everydate_price_t.Where(x => x.xz_code == xzcode && x.everydate == time).FirstOrDefault(); if (price != null) { var num = price.num; var ordernum = price.ordernum; var miaosha = db.miaosha_t.Where(x => x.xz_code == xzcode).FirstOrDefault(); var starttime = ""; var endtime = ""; if (miaosha != null) { starttime = DateTimeHelper.GetTimeStamp(DateTime.Parse(miaosha.starttime)).ToString(); endtime = DateTimeHelper.GetTimeStamp(DateTime.Parse(miaosha.endtime)).ToString(); } var ass = db.associateds.Where(x => x.xz_code == xzcode).FirstOrDefault(); var baojia = db.baojia_t.Where(x => x.xz_code == xzcode).FirstOrDefault(); var baojiaid = ""; if (baojia != null) { baojiaid = baojia.formulaid.ToString(); } object rules = null; object rulesname = null; if (ass != null) { if (ass.rules == "early") { var id = int.Parse(ass.codeid); rulesname = "early"; var early = db.earlies.Where(x => x.id == id).FirstOrDefault(); rules = early.code; } if (ass.rules == "live") { var id = int.Parse(ass.codeid); rulesname = "live"; var live = db.lives.Where(x => x.id == id).FirstOrDefault(); rules = live.code; } } var activty = db.activity_link.Where(x => x.xz_code == xzcode).FirstOrDefault(); var dis = ""; var aStarttime = ""; var aEndtime = ""; if (activty != null) { var act = db.Activities.Where(x => x.Code == activty.activitycode).FirstOrDefault(); if (act.starttime != null && act.endtime != null) { aStarttime = DateTimeHelper.GetTimeStamp(act.starttime).ToString(); aEndtime = DateTimeHelper.GetTimeStamp(act.endtime).ToString(); } dis = db.Activities.Where(x => x.Code == activty.activitycode).FirstOrDefault().discount; } var formula = db.price_formulaid.Where(x => x.xz_code == xzcode).ToList(); List <System.String> listS = new List <System.String>(); string str = ""; if (formula.Count > 0) { foreach (var item1 in formula) { listS.Add(item1.formulaid + ":" + item1.categoryid + ":" + item1.type); } listS.ToArray(); } str = string.Join(",", listS); Nullable <int> physicalnum = item.FirstOrDefault().pnum; var a = new RateXzByRmType { onsalecode = rate.onsalecode, chaifen = item.FirstOrDefault().chaifen.Value, xzcode = xzcode, islock = item.FirstOrDefault().islock, package = item.FirstOrDefault().package, payway = item.FirstOrDefault().payway, pay = item.FirstOrDefault().pay.ToString(), xzname = item.FirstOrDefault().xz_name, yuanjia = item.FirstOrDefault().yuanjia, ordersum = sum, ordernum = ordernum, pnum = physicalnum, num = num, baojia = baojiaid, price = item.FirstOrDefault().price, starttime = starttime, endtime = endtime, startdate = DateTimeHelper.GetTimeStamp(time).ToString(), enddate = end, rulesname = rulesname == null ? "" : rulesname, rules = rules == null ? "" : rules, activty = dis, formula = str, roomtype = roomtype, lvyunnum = room, activtyStarttime = aStarttime, activtyEndtime = aEndtime, }; list.Add(a); } } } } } return(list); //throw new NotImplementedException(); }
public List <RateXzByRmType> CrsGetRateCodexzByRoomtype(string starttimeStr, string endtimeStr, string roomtype, string hotelcode, int type) { db = new yudingEntities(); var time = DateTime.Parse(starttimeStr); var end = DateTimeHelper.GetTimeStamp(DateTime.Parse(endtimeStr)); var XzList = db.GetRcListByRoomType(roomtype, hotelcode, DateTime.Parse(starttimeStr)).ToList().GroupBy(x => x.xz_code).OrderByDescending(x => x.FirstOrDefault().px); var yuanjia = db.newroom_t.Where(x => x.roomtype == roomtype).FirstOrDefault().yuanjia; var list = new List <RateXzByRmType>(); var d = db.ratecode_t.Where(x => x.hotelid == hotelcode && x.scenario == 1 && x.flag == 0 && x.type == type).FirstOrDefault().ratecode; foreach (var item in XzList) { var xzcode = item.FirstOrDefault().xz_code; var rate = db.rateroom_xz.Where(x => x.xz_code == xzcode).FirstOrDefault(); var c = db.xztimestart_t.Where(x => x.startdate <= time && x.enddate >= time && x.xz_code == xzcode && x.flag == 0).FirstOrDefault(); if (rate.ratecode == d) { if (c != null) { Nullable <int> sum = 0; foreach (var item1 in XzList) { sum += item1.FirstOrDefault().ordernum; } var price = db.everydate_price_t.Where(x => x.xz_code == xzcode && x.everydate == time).FirstOrDefault(); if (price != null) { var num = price.num; var ordernum = price.ordernum; var miaosha = db.miaosha_t.Where(x => x.xz_code == xzcode).FirstOrDefault(); var starttime = ""; var endtime = ""; if (miaosha != null) { starttime = DateTimeHelper.GetTimeStamp(DateTime.Parse(miaosha.starttime)).ToString(); endtime = DateTimeHelper.GetTimeStamp(DateTime.Parse(miaosha.endtime)).ToString(); } var ass = db.associateds.Where(x => x.xz_code == xzcode).FirstOrDefault(); var baojia = db.baojia_t.Where(x => x.xz_code == xzcode).FirstOrDefault(); var baojiaid = ""; if (baojia != null) { baojiaid = baojia.formulaid.ToString(); } object rules = null; object rulesname = null; if (ass != null) { if (ass.rules == "early") { var id = int.Parse(ass.codeid); rulesname = "early"; var early = db.earlies.Where(x => x.id == id).FirstOrDefault(); rules = early.code; } if (ass.rules == "live") { var id = int.Parse(ass.codeid); rulesname = "live"; var live = db.lives.Where(x => x.id == id).FirstOrDefault(); rules = live.code; } } var activty = db.activity_link.Where(x => x.xz_code == xzcode).FirstOrDefault(); var dis = ""; if (activty != null) { dis = db.Activities.Where(x => x.Code == activty.activitycode).FirstOrDefault().discount; } var formula = db.price_formulaid.Where(x => x.xz_code == xzcode).ToList(); List <System.String> listS = new List <System.String>(); string str = ""; if (formula.Count > 0) { foreach (var item1 in formula) { listS.Add(item1.formulaid + ":" + item1.categoryid); } listS.ToArray(); } str = string.Join(",", listS); Nullable <int> physicalnum = item.FirstOrDefault().pnum; var a = new RateXzByRmType { xzcode = xzcode, islock = item.FirstOrDefault().islock, package = item.FirstOrDefault().package, payway = item.FirstOrDefault().payway, pay = item.FirstOrDefault().pay.ToString(), xzname = item.FirstOrDefault().xz_name, yuanjia = item.FirstOrDefault().yuanjia, ordersum = sum, ordernum = ordernum, pnum = physicalnum, num = num, baojia = baojiaid, price = item.FirstOrDefault().price, starttime = starttime, endtime = endtime, startdate = DateTimeHelper.GetTimeStamp(time).ToString(), enddate = end, rulesname = rulesname, rules = rules, activty = dis, formula = str, roomtype = roomtype, }; list.Add(a); } } } } return(list); //throw new NotImplementedException(); }