public ResultModel Confirm(UserModel user, int stopLossApplyId) { ResultModel result = new ResultModel(); try { Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); DAL.StopLossApplyDetailDAL stopLossApplyDetailDAL = new StopLossApplyDetailDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证止损申请 result = stoplossapplyDAL.Get(user, stopLossApplyId); if (result.ResultStatus != 0) return result; Model.StopLossApply stopLossApply = result.ReturnValue as Model.StopLossApply; if (stopLossApply == null || stopLossApply.StopLossApplyId <= 0) { result.ResultStatus = -1; result.Message = "止损申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, stopLossApply.ApplyId); if (result.ResultStatus != 0) return result; Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //验证是否执行完成 result = stoplossapplyDAL.CheckStopLossCanConfirm(user, stopLossApplyId); if (result.ResultStatus != 0) return result; Common.StatusEnum status = (Common.StatusEnum)result.ReturnValue; //获取已生效止损申请明细 result = stopLossApplyDetailDAL.Load(user, stopLossApplyId); if (result.ResultStatus != 0) return result; List<Model.StopLossApplyDetail> details = result.ReturnValue as List<Model.StopLossApplyDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取止损申请明细失败"; return result; } //主申请更新状态至已完成 if (status == StatusEnum.已完成) result = applyDAL.Confirm(user, apply); else if (status == StatusEnum.部分完成) result = applyDAL.PartiallyConfirm(user, apply); else { result.ResultStatus = -1; result.Message = "更新主申请状态失败"; return result; } if (result.ResultStatus != 0) return result; //止损申请明细更新状态至已完成 foreach (Model.StopLossApplyDetail detail in details) { //止损申请明细更新状态至已完成 result = stopLossApplyDetailDAL.Confirm(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel ConfirmCancel(UserModel user, int stopLossApplyId) { ResultModel result = new ResultModel(); try { DAL.StopLossApplyDetailDAL stopLossApplyDetailDAL = new StopLossApplyDetailDAL(); Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证止损申请 result = stoplossapplyDAL.Get(user, stopLossApplyId); if (result.ResultStatus != 0) return result; Model.StopLossApply stopLossApply = result.ReturnValue as Model.StopLossApply; if (stopLossApply == null || stopLossApply.StopLossApplyId <= 0) { result.ResultStatus = -1; result.Message = "止损申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, stopLossApply.ApplyId); if (result.ResultStatus != 0) return result; Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //主申请状态更新至已生效 result = applyDAL.ConfirmCancel(user, apply); if (result.ResultStatus != 0) return result; //止损申请明细,在已完成状态下的更新至已生效 //获取已关闭的明细 result = stopLossApplyDetailDAL.Load(user, stopLossApply.StopLossApplyId, Common.StatusEnum.已完成); if (result.ResultStatus != 0) return result; List<Model.StopLossApplyDetail> details = result.ReturnValue as List<Model.StopLossApplyDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取申请明细失败"; return result; } foreach (Model.StopLossApplyDetail detail in details) { result = stopLossApplyDetailDAL.ConfirmCancel(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }