public JsonResult GetParkFeeRuleData() { JsonResult json = new JsonResult(); try { if (string.IsNullOrEmpty(Request.Params["parkingId"])) { return(json); } string parkingId = Request.Params["parkingId"].ToString(); List <ParkCarType> carTypes = ParkCarTypeServices.QueryParkCarTypeByParkingId(parkingId); List <ParkCarModel> carModels = ParkCarModelServices.QueryByParkingId(parkingId); List <ParkFeeRule> rules = ParkFeeRuleServices.QueryParkFeeRuleByParkingId(parkingId); List <ParkArea> areas = ParkAreaServices.GetParkAreaByParkingId(parkingId); List <ParkFeeRuleView> models = new List <ParkFeeRuleView>(); foreach (var item in rules) { ParkFeeRuleView view = new ParkFeeRuleView().ToParkFeeRuleView(item, areas, carTypes, carModels); view.ParkingID = parkingId; models.Add(view); } json.Data = models; } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "获取收费规则集合失败"); } return(json); }
public JsonResult TestCalculateFee(DateTime StartTime, DateTime EndTime, string FeeRuleId) { try { decimal fee = ParkFeeRuleServices.TestCalculateFee(StartTime, EndTime, FeeRuleId); return(Json(MyResult.Success("成功", fee))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "测试算费失败"); return(Json(MyResult.Error("算费失败"))); } }
public JsonResult Delete(string feeRuleId) { try { bool result = ParkFeeRuleServices.Delete(feeRuleId); if (!result) { throw new MyException("删除收费规则失败"); } return(Json(MyResult.Success())); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "删除收费规则失败"); return(Json(MyResult.Error("删除收费规则失败"))); } }
public JsonResult SaveEdit(ParkFeeRuleView model) { try { ParkFeeRule ruleModel = model.ToParkFeeRule(); bool result = false; if (string.IsNullOrWhiteSpace(model.FeeRuleID)) { var parkingFeeRules = ParkFeeRuleServices.QueryFeeRules(model.ParkingID, model.CarTypeID, model.CarModelID); if (parkingFeeRules != null && parkingFeeRules.Count > 0 && parkingFeeRules.Exists(p => p.AreaID == model.AreaID)) { throw new MyException("该区域已经存在相同的收费规则了"); } result = ParkFeeRuleServices.Add(ruleModel); if (!result) { throw new MyException("添加收费规则失败"); } } else { var parkingFeeRules = ParkFeeRuleServices.QueryFeeRules(model.ParkingID, model.CarTypeID, model.CarModelID); if (parkingFeeRules != null && parkingFeeRules.Count > 0 && parkingFeeRules.Exists(p => p.AreaID == model.AreaID && p.FeeRuleID != model.FeeRuleID)) { throw new MyException("该区域已经存在相同的收费规则了!"); } result = ParkFeeRuleServices.Update(ruleModel); if (!result) { throw new MyException("修改收费规则失败"); } } return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "收费规则管理设置收费规则失败"); return(Json(MyResult.Error("设置收费规则失败"))); } }
public JsonResult GetParkFeeRuleTreeData() { JsonResult json = new JsonResult(); if (string.IsNullOrEmpty(Request.Params["sellerId"])) { return(json); } string sellerId = Request.Params["sellerId"].ToString(); ParkSeller seller = ParkSellerServices.QueryBySellerId(sellerId); if (seller == null) { throw new MyException("获取商家信息失败"); } List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageId(seller.VID); if (parkings.Count == 0) { return(json); } List <ParkFeeRule> rules = new List <ParkFeeRule>(); foreach (var item in parkings) { List <ParkFeeRule> rule = ParkFeeRuleServices.QueryParkFeeRuleByParkingId(item.PKID); if (rule.Count > 0) { rules.AddRange(rule); } } json.Data = rules; return(json); }