public ActionResult SettlementOrder(RepairSettlementModel model) { try { RepairOrderService.Settlement(model); return(new BetterJsonResult()); } catch (Exception ex) { return(new BetterJsonResult(ex.Message)); } }
/// <summary> /// 结算维修单 /// </summary> /// <param name="model"></param> public void Settlement(RepairSettlementModel model) { if (model == null) { return; } if (model.SettlementAmount <= 0) { throw new Exception("请输入结算金额。"); } var order = Get(model.RepairOrderId); if (order == null) { throw new Exception("维修单不存在。"); } if (order.Status != EnumRepairOrderStatus.Completed) { throw new Exception("只能结算已完工的维修单。"); } if (order.SettlementStatus == EnumSettlementStatus.Completed) { throw new Exception("只能结算未结算的维修单。"); } order.SettlementStatus = model.SettlementStatus; order.SettlementAmount = order.SettlementAmount + model.SettlementAmount; if (order.SettlementAmount >= order.Amount && order.SettlementStatus == EnumSettlementStatus.PartCompleted) { throw new Exception("结算金额已超过维修单总金额,不允许部分结算。"); } var financeOrder = new FinanceOrder(); financeOrder.Code = this.FinanceOrderRepository.GetSequenceNextCode(); financeOrder.Amount = model.SettlementAmount; financeOrder.Remark = model.SettlementRemark; this.RepairOrderRepository.Settlement(order, financeOrder); }