public JsonResult deleteOrder(string ouhid) { int ouhidInt = Convert.ToInt32(ouhid); OrdersUserHouse ouh = OrdersUserHouseService.LoadEntities(o => o.ouhid == ouhidInt).FirstOrDefault(); bool res = OrdersUserHouseService.DeleteEntity(ouh); return(Json(res, JsonRequestBehavior.AllowGet)); }
public JsonResult PlaceOrder(string id, string duration) { int hid = Convert.ToInt32(id); House house = HouseService.LoadEntities(h => h.hid == hid).FirstOrDefault(); // 服务费 DataDictionary servicePrice = DataDictionaryService.LoadEntities(t => t.dkey == "service").FirstOrDefault(); int rent = Convert.ToInt32(duration) * house.price + Convert.ToInt32(servicePrice.dvalue); DateTime df = DateTime.Now; string now = df.ToString(); Orders newOrder = OrdersService.AddEntity(new Orders { duration = Convert.ToInt32(duration), rent = rent, state = "0", time = now }); User user = Session["user"] as My.RentingSystem.Model.User; // OrdersUserHouse newOrderUserHouse = OrdersUserHouseService.AddEntity(new OrdersUserHouse { oid = newOrder.oid, uid = user.uid, hid = hid, pubTime = df.ToString("yyyyMMdd") }); // 更新房屋状态state=1 house.state = "1"; HouseService.EditEntity(house); Session["city"] = Session["rentCity"]; if (newOrder == null || newOrderUserHouse == null) { return(Json("error", JsonRequestBehavior.AllowGet)); } else { return(Json("success", JsonRequestBehavior.AllowGet)); } }
public ActionResult CancelOrder(string oid, string hid) { int oidInt = Convert.ToInt32(oid); int hidInt = Convert.ToInt32(hid); Orders order = OrdersService.LoadEntities(o => o.oid == oidInt).FirstOrDefault(); House house = HouseService.LoadEntities(h => h.hid == hidInt).FirstOrDefault(); house.state = "0"; OrdersUserHouse ordersUserHouse = OrdersUserHouseService.LoadEntities(o => o.oid == oidInt).FirstOrDefault(); OrdersService.DeleteEntity(order); HouseService.EditEntity(house); OrdersUserHouseService.DeleteEntity(ordersUserHouse); My.RentingSystem.Model.User user = Session["user"] as My.RentingSystem.Model.User; @ViewBag.uid = user.uid; return(View("MyOrder", new { id = user.uid })); }
public JsonResult editOrder(string ouhid, string oid, string community, string area, string unitType, string duration, string rent, string floor, string state ) { int oidInt = Convert.ToInt32(oid); Orders order = OrdersService.LoadEntities(o => o.oid == oidInt).FirstOrDefault(); int ouhidInt = Convert.ToInt32(ouhid); int hid = OrdersUserHouseService.LoadEntities(o => o.ouhid == ouhidInt).FirstOrDefault().hid; House house = HouseService.LoadEntities(h => h.hid == hid).FirstOrDefault(); // 如果时长不变 只变价格 if (Convert.ToInt32(duration) == order.duration) { order.rent = Convert.ToInt32(rent); order.state = state; } else { // 改变时长 重新计算价格 order.state = state; order.duration = Convert.ToInt32(duration); string service = DataDictionaryService.LoadEntities(d => d.remark == "服务费").FirstOrDefault().dvalue; order.rent = (Convert.ToInt32(duration) * house.price) + Convert.ToInt32(service); } bool res = OrdersService.EditEntity(order); return(Json(res, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 个人订单 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult MyOrderPartial(string id) { // userid = id int uid = Convert.ToInt32(id); //My.RentingSystem.Model.User user = Session["user"] as My.RentingSystem.Model.User; List <OrdersUserHouse> ouhList = OrdersUserHouseService.LoadEntities(o => o.uid == uid).ToList(); List <House> houseList = new List <House>(); List <Orders> ordersList = new List <Orders>(); foreach (OrdersUserHouse ouh in ouhList) { houseList.Add(HouseService.LoadEntities(h => h.hid == ouh.hid).FirstOrDefault()); ordersList.Add(OrdersService.LoadEntities(o => o.oid == ouh.oid).FirstOrDefault()); } List <HousePicture> hps = newHousePicture(houseList); ViewBag.hps = hps; ViewBag.orders = ordersList; return(View()); }
public JsonResult getMainData(string province) { int userToday = 0; int userMonth = 0; int userHis = 0; DateTime dt = DateTime.Now; string now = dt.ToString("yyyyMMdd"); // 用户 List <UserUserInfo> userList = UserUserInfoService.LoadEntities(u => true).ToList(); userToday = userList.Where(u => u.pubTime == now).ToList().Count; foreach (UserUserInfo item in userList) { DateTime itemDate = DateTime.ParseExact(item.pubTime, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); //DateTime _itemDate = itemDate.ToShortDateString(); DateTime startMonth = DateTime.ParseExact(dt.AddDays(1 - dt.Day).ToString("yyyyMMdd"), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); //本月月初 带分钟 //DateTime _startMonth = DateTime.ParseExact(startMonth.ToShortDateString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); //DateTime endMonth = startMonth.AddMonths(1).AddDays(-1); //本月月末 DateTime endMonth = DateTime.ParseExact(dt.AddDays(1 - dt.Day).AddMonths(1).AddDays(-1).ToString("yyyyMMdd"), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); //DateTime _endMonth = DateTime.ParseExact(startMonth.ToShortDateString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); if (itemDate >= startMonth && itemDate <= endMonth) { userMonth++; } } userHis = userList.Count; // 订单 int orderToday = 0; int orderMonth = 0; int orderHis = 0; int waitOrder = 0; int placedOrder = 0; List <OrdersUserHouse> ouhList = OrdersUserHouseService.LoadEntities(o => true).ToList(); orderToday = ouhList.Where(o => o.pubTime == now).ToList().Count; foreach (OrdersUserHouse ouh in ouhList) { Orders order = OrdersService.LoadEntities(o => o.oid == ouh.oid).FirstOrDefault(); DateTime itemDate = DateTime.ParseExact(ouh.pubTime, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); DateTime startMonth = dt.AddDays(1 - dt.Day); //本月月初 DateTime endMonth = startMonth.AddMonths(1).AddDays(-1); //本月月末 if (itemDate >= startMonth && itemDate <= endMonth) { orderMonth++; } if (order.state == "0") { waitOrder++; } if (order.state == "1") { placedOrder++; } } orderHis = ouhList.Count; // 房屋 int houseToday = 0; int houseMonth = 0; int houseHis = 0; List <House> houseList = HouseService.LoadEntities(h => true).ToList(); houseToday = houseList.Where(h => h.time == now).ToList().Count; foreach (House item in houseList) { DateTime itemDate = DateTime.ParseExact(item.time, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); DateTime startMonth = dt.AddDays(1 - dt.Day); //本月月初 DateTime endMonth = startMonth.AddMonths(1).AddDays(-1); //本月月末 if (itemDate >= startMonth && itemDate <= endMonth) { houseMonth++; } } houseHis = houseList.Count; Dictionary <string, int> userChart = new Dictionary <string, int>(); Dictionary <string, int> houseChart = new Dictionary <string, int>(); DateTime last7Day = DateTime.Now.AddDays(-6); for (int i = 0; i <= 6; i++) { string date = last7Day.ToString("yyyyMMdd"); //DateTime itemDate = DateTime.ParseExact(date, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); int count = UserUserInfoService.LoadEntities(u => u.pubTime == date).ToList().Count; int countHouse = HouseService.LoadEntities(h => h.time == date).ToList().Count; userChart.Add(date, count); houseChart.Add(date, countHouse); last7Day = last7Day.AddDays(1); } houseList = HouseService.LoadEntities(h => h.province == province).ToList(); Dictionary <string, int> houseDic = new Dictionary <string, int>(); foreach (House item in houseList) { if (!houseDic.ContainsKey(item.city)) { houseDic.Add(item.city, 1); } else { int count = houseDic[item.city] += 1; houseDic[item.city] = count; } } List <string> userChartX = userChart.Keys.ToList(); List <int> userChartY = userChart.Values.ToList(); //List<string> houseDicX = houseDic.Keys.ToList(); List <int> houseDicY = houseDic.Values.ToList(); List <HousePie> housePie = new List <HousePie>(); foreach (var item in houseDic) { housePie.Add(new HousePie { name = item.Key, value = item.Value.ToString() }); } List <string> provinces = new List <string>(); List <DataDictionary> datas = DataDictionaryService.LoadEntities(d => d.dkey == "region").ToList(); foreach (var item in datas) { if (!provinces.Contains(item.dvalue3)) { provinces.Add(item.dvalue3); } } AdminMainEntity entity = new AdminMainEntity { userToday = userToday, userMonth = userMonth, userHis = userHis, orderToday = orderToday, orderMonth = orderMonth, orderHis = orderHis, waitOrder = waitOrder, placedOrder = placedOrder, houseToday = houseToday, houseMonth = houseMonth, houseHis = houseHis, userChartX = userChartX, userChartY = userChartY, //houseDicX = houseDicX, houseDicY = houseChart.Values.ToList(), housePie = housePie, provinces = provinces }; return(Json(entity, JsonRequestBehavior.AllowGet)); }
public JsonResult getOrders(string pageSize, string page, string name, string oid, string community, string area, string unitType, string duration, string rent, string floor, string time, string state ) { List <OrdersUserHouse> ouhList = OrdersUserHouseService.LoadEntities(o => true).ToList(); List <OrdersUserHouseEntity> entity = new List <OrdersUserHouseEntity>(); foreach (OrdersUserHouse item in ouhList) { Orders orders = OrdersService.LoadEntities(o => o.oid == item.oid).FirstOrDefault(); User user = UserService.LoadEntities(o => o.uid == item.uid).FirstOrDefault(); int uiid = UserUserInfoService.LoadEntities(u => u.uid == user.uid).FirstOrDefault().uiid; UserInfo userInfo = UserInfoService.LoadEntities(u => u.uiid == uiid).FirstOrDefault(); House house = HouseService.LoadEntities(h => h.hid == item.hid).FirstOrDefault(); entity.Add(new OrdersUserHouseEntity() { name = userInfo.name, phone = userInfo.phone, duration = orders.duration, rent = orders.rent, state = orders.state, time = orders.time, ouhid = item.ouhid, hid = house.hid, community = house.community, unitType = house.unitType, area = house.area, oid = orders.oid, floor = house.floor }); } int pageInt = Convert.ToInt32(page); int pageSizeInt = Convert.ToInt32(pageSize); if (!string.IsNullOrWhiteSpace(state)) { //int oidInt = Convert.ToInt32(oid); entity = entity.Where(u => u.state == state).ToList(); } //time = time.Replace("-",""); // 20210326 if (!string.IsNullOrWhiteSpace(time)) { time = time.Substring(0, 10).Replace("-", ""); DateTime itemDate = DateTime.ParseExact(time, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture); itemDate = itemDate.AddDays(1); string formatDate = itemDate.ToString("yyyyMMdd"); //int oidInt = Convert.ToInt32(oid); entity = entity.Where(u => u.time == formatDate).ToList(); } if (!string.IsNullOrWhiteSpace(oid)) { int oidInt = Convert.ToInt32(oid); entity = entity.Where(u => u.oid == oidInt).ToList(); } if (!string.IsNullOrWhiteSpace(area)) { int areaInt = Convert.ToInt32(area); entity = entity.Where(u => u.area == areaInt).ToList(); } if (!string.IsNullOrWhiteSpace(duration)) { int durationInt = Convert.ToInt32(duration); entity = entity.Where(u => u.duration == durationInt).ToList(); } if (!string.IsNullOrWhiteSpace(rent)) { int rentInt = Convert.ToInt32(rent); entity = entity.Where(u => u.rent == rentInt).ToList(); } if (!string.IsNullOrWhiteSpace(name)) { entity = entity.Where(u => u.name.Contains(name)).ToList(); } if (!string.IsNullOrWhiteSpace(community)) { entity = entity.Where(u => u.community.Contains(community)).ToList(); } if (!string.IsNullOrWhiteSpace(unitType)) { entity = entity.Where(u => u.unitType.Contains(unitType)).ToList(); } if (!string.IsNullOrWhiteSpace(floor)) { entity = entity.Where(u => u.floor.Contains(floor)).ToList(); } int total = entity.Count; entity = entity.Skip((pageInt - 1) * pageSizeInt).Take(pageSizeInt).ToList(); return(Json(new { entity = entity, total = total }, JsonRequestBehavior.AllowGet)); }