public ActionResult TollRelease(decimal waitPay, string recordId, string carModelId) { try { string errorMsg = string.Empty; ParkIORecord model = ParkIORecordServices.GetIORecord(recordId, out errorMsg); if (!string.IsNullOrWhiteSpace(errorMsg)) { throw new MyException("获取该入场记录失败"); } if (model == null) { throw new MyException("找不到该入场记录"); } if (model.IsExit) { throw new MyException("该车辆已经出场"); } DateTime outTime = DateTime.Now; List <ParkGate> parkGates = ParkGateServices.QueryByParkAreaRecordIds(new List <string>() { model.AreaID }); ParkGate outGate = parkGates.FirstOrDefault(p => p.IoState == IoState.GoOut); if (outGate == null) { throw new MyException("获取出口通道失败"); } ResultAgs billResult = RateProcesser.GetRateResult(model, outGate, outTime, carModelId); if (!string.IsNullOrWhiteSpace(billResult.ValidFailMsg)) { throw new MyException(billResult.ValidFailMsg); } if (billResult.Rate == null) { throw new MyException("计算停车费失败"); } if (waitPay != billResult.Rate.UnPayAmount) { throw new MyException("缴费金额与实际金额不匹配,请重新选择入场记录"); } bool result = CentralFeeServices.Payment(recordId, model.ParkingID, billResult, GetLoginUser.RecordID); 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 ActionResult QueryWaitPayDetail(string recordId, string carModelId) { try { string errorMsg = string.Empty; ParkIORecord model = ParkIORecordServices.GetIORecord(recordId, out errorMsg); if (!string.IsNullOrWhiteSpace(errorMsg)) { throw new MyException("获取该入场记录失败"); } if (model == null) { throw new MyException("找不到该入场记录"); } if (model.IsExit) { throw new MyException("该车辆已经出场"); } DateTime outTime = DateTime.Now; List <ParkGate> parkGates = ParkGateServices.QueryByParkAreaRecordIds(new List <string>() { model.AreaID }); ParkGate outGate = parkGates.FirstOrDefault(p => p.IoState == IoState.GoOut); if (outGate == null) { throw new MyException("获取出口通道失败"); } ResultAgs billResult = RateProcesser.GetRateResult(model, outGate, outTime, carModelId); if (!string.IsNullOrWhiteSpace(billResult.ValidFailMsg)) { throw new MyException(billResult.ValidFailMsg); } if (billResult.Rate == null) { throw new MyException("计算停车费失败"); } List <ParkIORecord> records = new List <ParkIORecord>() { model }; var result = from p in records select new { RecordID = p.RecordID, EntranceImageUrl = GetImagePath(p.EntranceImage, true, false), EntrancePlateImageUrl = GetImagePath(p.EntranceImage, false, false), PlateNumber = p.PlateNumber, EntranceTime = p.EntranceTime.ToString("yyyy-MM-dd HH:mm:ss"), OutTime = outTime.ToString("yyyy-MM-dd HH:mm:ss"), TotalDuration = p.EntranceTime.GetParkingDuration(outTime), TotalFee = billResult.Rate.Amount.ToString("0.0"), PaySuccess = billResult.Rate.OnlinePayAmount.ToString("0.0"), WaitPay = billResult.Rate.UnPayAmount.ToString("0.0"), DiscountAmount = billResult.Rate.DiscountAmount.ToString("0.0") }; return(Json(MyResult.Success(string.Empty, result))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "中央缴费获取待支付记录失败"); return(Json(MyResult.Error("取待支付记录失败"))); } }