public ResultModel Close(UserModel user, int payApplyId) { ResultModel result = new ResultModel(); try { PayApplyDAL payApplyDAL = new PayApplyDAL(); ApplyDAL applyDAL = new ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证付款申请 result = payApplyDAL.Get(user, payApplyId); if (result.ResultStatus != 0) return result; PayApply payApply = result.ReturnValue as PayApply; if (payApply == null || payApply.PayApplyId <= 0) { result.ResultStatus = -1; result.Message = "付款申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, payApply.ApplyId); if (result.ResultStatus != 0) return result; Apply apply = result.ReturnValue as Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //关闭主申请 result = applyDAL.Close(user, apply); if (result.ResultStatus != 0) return result; //关闭明细申请 if (payApply.PayApplySource == (int)FundsStyleEnum.ContractPayApply) { //获取付款申请下合约申请明细 ContractPayApplyDAL payApplyContractDAL = new ContractPayApplyDAL(); result = payApplyContractDAL.GetByPayApplyId(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; ContractPayApply payApplyContract = result.ReturnValue as ContractPayApply; if (payApplyContract == null || payApplyContract.RefId <= 0) { result.ResultStatus = -1; result.Message = "获取明细失败"; return result; } //完成撤销明细 result = payApplyContractDAL.Close(user, payApplyContract); if (result.ResultStatus != 0) return result; } else if (payApply.PayApplySource == (int)FundsStyleEnum.StockPayApply) { //获取付款申请下库存申请明细 StockPayApplyDAL payApplyStockDAL = new StockPayApplyDAL(); result = payApplyStockDAL.Load(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; List<StockPayApply> payApplyStocks = result.ReturnValue as List<StockPayApply>; if (payApplyStocks == null) { result.ResultStatus = -1; result.Message = "获取付款申请库存明细失败"; return result; } foreach (StockPayApply payApplyStock in payApplyStocks) { //明细完成撤销 result = payApplyStockDAL.Close(user, payApplyStock); if (result.ResultStatus != 0) return result; } } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel PayApplyStockUpdate(UserModel user, PayApply payApply, List<StockPayApply> stockPayApplies, string memo, int deptId, int corpId) { ResultModel result = new ResultModel(); try { StockPayApplyDAL stockPayApplyDAL = new StockPayApplyDAL(); ContractPayApplyDAL contractPayApplyDAL = new ContractPayApplyDAL(); ApplyDAL applyDAL = new ApplyDAL(); PayApplyDAL payApplyDAL = new PayApplyDAL(); StockLogDAL stockLogDAL = new StockLogDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证可申请金额 //NFMT.Data.Model.FuturesPrice futuresPrice = NFMT.Data.BasicDataProvider.FuturesPrices[0]; //获取付款申请 result = payapplyDAL.Get(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; PayApply resultObj = result.ReturnValue as PayApply; if (resultObj == null || resultObj.PayApplyId <= 0) { result.ResultStatus = -1; result.Message = "付款申请不存在"; return result; } //获取申请主表 result = applyDAL.Get(user, resultObj.ApplyId); if (result.ResultStatus != 0) return result; Apply apply = result.ReturnValue as Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "申请主表获取失败"; return result; } //获取库存明细列表 result = stockPayApplyDAL.Load(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; List<StockPayApply> readyStockPayApplies = result.ReturnValue as List<StockPayApply>; if (readyStockPayApplies == null) { result.ResultStatus = -1; result.Message = "库存申请明细获取失败"; return result; } //更新申请主表 Department dept = UserProvider.Departments.FirstOrDefault(temp => temp.DeptId == deptId); if (dept == null || dept.DeptId < 0) { result.ResultStatus = -1; result.Message = "申请部门不存在"; return result; } apply.ApplyDept = dept.DeptId; apply.ApplyCorp = corpId; apply.ApplyDesc = memo; apply.ApplyType = ApplyType.付款申请; apply.EmpId = user.EmpId; result = applyDAL.Update(user, apply); if (result.ResultStatus != 0) return result; //更新付款申请表 resultObj.RecCorpId = payApply.RecCorpId; resultObj.RecBankId = payApply.RecBankId; resultObj.RecBankAccountId = payApply.RecBankAccountId; resultObj.RecBankAccount = payApply.RecBankAccount; resultObj.ApplyBala = payApply.ApplyBala; resultObj.CurrencyId = payApply.CurrencyId; resultObj.PayMode = payApply.PayMode; resultObj.PayDeadline = payApply.PayDeadline; resultObj.PayMatter = payApply.PayMatter; resultObj.SpecialDesc = payApply.SpecialDesc; result = payapplyDAL.Update(user, resultObj); if (result.ResultStatus != 0) return result; //作废现有已生效库存分配明细 foreach (StockPayApply stockPayApply in readyStockPayApplies) { stockPayApply.RefStatus = StatusEnum.已录入; result = stockPayApplyDAL.Invalid(user, stockPayApply); if (result.ResultStatus != 0) return result; } //获取合约付款申请 result = contractPayApplyDAL.GetByPayApplyId(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; ContractPayApply contractPayApply = result.ReturnValue as ContractPayApply; if (contractPayApply == null || contractPayApply.RefId <= 0) { result.ResultStatus = -1; result.Message = "获取对应合约付款失败"; return result; } //验证库存流水是否在同一子合约中 int subId = 0; int contractId = 0; foreach (StockPayApply stockPayApply in stockPayApplies) { result = stockLogDAL.Get(user, stockPayApply.StockLogId); if (result.ResultStatus != 0) return result; StockLog stockLog = result.ReturnValue as StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "库存流水不存在"; return result; } if (subId == 0) { subId = stockLog.SubContractId; contractId = stockLog.ContractId; } if (stockLog.SubContractId != subId) { result.ResultStatus = -1; result.Message = "不能同时申请不同子合约中的库存付款"; return result; } } //更新合约付款 contractPayApply.ApplyBala = stockPayApplies.Sum(temp => temp.ApplyBala); contractPayApply.ContractId = contractId; contractPayApply.ContractSubId = subId; result = contractPayApplyDAL.Update(user, contractPayApply); if (result.ResultStatus != 0) return result; //新增dbo.Fun_StockPayApply_Ref库存付款申请 foreach (StockPayApply stockPayApply in stockPayApplies) { stockPayApply.ContractId = contractPayApply.ContractId; stockPayApply.ContractRefId = contractPayApply.RefId; stockPayApply.SubId = contractPayApply.ContractSubId; stockPayApply.PayApplyId = contractPayApply.PayApplyId; stockPayApply.RefStatus = StatusEnum.已生效; result = stockPayApplyDAL.Insert(user, stockPayApply); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel PayApplyUpdate(UserModel user, Apply apply, PayApply payApply, List<StockPayApply> stockDetails) { ResultModel result = new ResultModel(); try { ApplyDAL applyDAL = new ApplyDAL(); ContractPayApplyDAL contractPayApplyDAL = new ContractPayApplyDAL(); StockPayApplyDAL stockPayApplyDAL = new StockPayApplyDAL(); StockDAL stockDAL = new StockDAL(); StockLogDAL stockLogDAL = new StockLogDAL(); ContractSubDAL subDAL = new ContractSubDAL(); using (TransactionScope scope = new TransactionScope()) { //获取主申请 result = applyDAL.Get(user, apply.ApplyId); if (result.ResultStatus != 0) return result; Apply resultApply = result.ReturnValue as Apply; if (resultApply == null || resultApply.ApplyId <= 0) { result.Message = "主申请获取失败"; result.ResultStatus = -1; return result; } resultApply.EmpId = user.EmpId; resultApply.ApplyDept = apply.ApplyDept; resultApply.ApplyCorp = apply.ApplyCorp; resultApply.ApplyDesc = apply.ApplyDesc; resultApply.ApplyTime = apply.ApplyTime; result = applyDAL.Update(user, resultApply); if (result.ResultStatus != 0) return result; //获取付款申请 result = this.payapplyDAL.Get(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; PayApply resultPayApply = result.ReturnValue as PayApply; if (resultPayApply == null || resultPayApply.PayApplyId <= 0) { result.Message = "付款申请获取失败"; result.ResultStatus = -1; return result; } if (resultPayApply.ApplyId != resultApply.ApplyId) { result.Message = "付款申请与主申请不一致,更新失败"; result.ResultStatus = -1; return result; } resultPayApply.RecCorpId = payApply.RecCorpId; resultPayApply.RecBankId = payApply.RecBankId; resultPayApply.RecBankAccountId = payApply.RecBankAccountId; resultPayApply.RecBankAccount = payApply.RecBankAccount; resultPayApply.ApplyBala = payApply.ApplyBala; resultPayApply.CurrencyId = payApply.CurrencyId; resultPayApply.PayMode = payApply.PayMode; resultPayApply.PayDeadline = payApply.PayDeadline; resultPayApply.PayMatter = payApply.PayMatter; resultPayApply.SpecialDesc = payApply.SpecialDesc; if (stockDetails.Count > 0) resultPayApply.PayApplySource = (int)FundsStyleEnum.StockPayApply; else resultPayApply.PayApplySource = (int)FundsStyleEnum.ContractPayApply; result = this.payapplyDAL.Update(user, resultPayApply); if (result.ResultStatus != 0) return result; //获取合约关联付款申请 result = contractPayApplyDAL.GetByPayApplyId(user, resultPayApply.PayApplyId); if (result.ResultStatus != 0) return result; ContractPayApply contractPayApply = result.ReturnValue as ContractPayApply; if (contractPayApply == null || contractPayApply.RefId <= 0) { result.Message = "合约关联付款申请获取失败"; result.ResultStatus = -1; return result; } contractPayApply.ApplyBala = resultPayApply.ApplyBala; result = contractPayApplyDAL.Update(user, contractPayApply); if (result.ResultStatus != 0) return result; //获取现有库存明细 result = stockPayApplyDAL.Load(user, resultPayApply.PayApplyId); if (result.ResultStatus != 0) return result; List<StockPayApply> resultDetails = result.ReturnValue as List<StockPayApply>; if (resultDetails == null) { result.Message = "库存付款申请获取失败"; result.ResultStatus = -1; return result; } //作废现有库存明细 foreach (StockPayApply stockPayApply in resultDetails) { stockPayApply.RefStatus = StatusEnum.已录入; result = stockPayApplyDAL.Invalid(user, stockPayApply); if (result.ResultStatus != 0) return result; } //新增库存付款申请 if (stockDetails != null && stockDetails.Count > 0) { foreach (StockPayApply detail in stockDetails) { detail.ContractId = contractPayApply.ContractId; detail.ContractRefId = contractPayApply.RefId; detail.PayApplyId = contractPayApply.PayApplyId; detail.RefStatus = StatusEnum.已生效; detail.SubId = contractPayApply.ContractSubId; result = stockPayApplyDAL.Insert(user, detail); if (result.ResultStatus != 0) return result; } } if (result.ResultStatus == 0) result.ReturnValue = payApply.PayApplyId; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel Confirm(UserModel user, int payApplyId) { ResultModel result = new ResultModel(); try { PayApplyDAL payApplyDAL = new PayApplyDAL(); ApplyDAL applyDAL = new ApplyDAL(); PaymentDAL paymentDAL = new PaymentDAL(); StockPayApplyDAL payApplyStockDAL = new StockPayApplyDAL(); ContractPayApplyDAL payApplyContractDAL = new ContractPayApplyDAL(); PaymentStockDetailDAL paymentStockDetailDAL = new PaymentStockDetailDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证付款申请 result = payApplyDAL.Get(user, payApplyId); if (result.ResultStatus != 0) return result; PayApply payApply = result.ReturnValue as PayApply; if (payApply == null || payApply.PayApplyId <= 0) { result.ResultStatus = -1; result.Message = "付款申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, payApply.ApplyId); if (result.ResultStatus != 0) return result; Apply apply = result.ReturnValue as Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //验证当前付款申请下是否有已录入至已生效状态下的关联付款 //如果存在,则不能进行执行完成确认 result = paymentDAL.GetCountByPayApplyId(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; if (result == null || result.AffectCount > 0) { result.ResultStatus = -1; result.Message = "付款申请存在未完成的关联付款,不能进行执行完成确认"; return result; } //验证当前付款申请的申请金额与已执行完成的关联付款的付款金额是否相等 //如果不相等则不能进行执行完成确认 result = paymentDAL.Load(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; List<Payment> payments = result.ReturnValue as List<Payment>; if (payments == null) { result.ResultStatus = -1; result.Message = "获取关联付款失败"; return result; } decimal sumPayBala = payments.Sum(temp => temp.PayBala); if (sumPayBala != payApply.ApplyBala) { result.ResultStatus = -1; result.Message = "付款申请金额与付款执行金额不相等,不能进行付款申请执行完成确认"; return result; } //验证库存付款申请明细的申请金额与付款执行的付款金额是否相等 //如果不相等则不能进行执行完成确认 if (payApply.PayApplySource == (int)FundsStyleEnum.ContractPayApply) { //获取付款申请下合约申请明细 result = payApplyContractDAL.GetByPayApplyId(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; ContractPayApply payApplyContract = result.ReturnValue as ContractPayApply; if (payApplyContract == null || payApplyContract.RefId <= 0) { result.ResultStatus = -1; result.Message = "获取明细失败"; return result; } //完成明细 //result = payApplyContractDAL.Confirm(user, payApplyContract); //if (result.ResultStatus != 0) // return result; } else if (payApply.PayApplySource == (int)FundsStyleEnum.StockPayApply) { //获取付款申请下库存申请明细 result = payApplyStockDAL.Load(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; List<StockPayApply> payApplyStocks = result.ReturnValue as List<StockPayApply>; if (payApplyStocks == null) { result.ResultStatus = -1; result.Message = "获取付款申请库存明细失败"; return result; } foreach (StockPayApply payApplyStock in payApplyStocks) { //获取付款申请库存明细关联的付款库存明细 result = paymentStockDetailDAL.LoadByStockPayApplyId(user, payApplyStock.RefId); if (result.ResultStatus != 0) return result; List<PaymentStockDetail> details = result.ReturnValue as List<PaymentStockDetail>; decimal sumStockPayBala = details.Sum(temp => temp.PayBala); if (sumStockPayBala != payApplyStock.ApplyBala) { result.ResultStatus = -1; result.Message = "付款申请存在未付完的金额,不能进行执行确认完成"; return result; } //明细完成 result = payApplyStockDAL.Confirm(user, payApplyStock); if (result.ResultStatus != 0) return result; } } //付款申请完成确认 //因付款执行不进行部分关闭,因此不存在部分完成状态 result = applyDAL.Confirm(user, apply); if (result.ResultStatus != 0) return result; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel PayApplyInvoiceUpdate(UserModel user, Apply apply, PayApply payApply, List<InvoicePayApply> details) { ResultModel result = new ResultModel(); try { InvoicePayApplyDAL invoicePayApplyDAL = new InvoicePayApplyDAL(); ApplyDAL applyDAL = new ApplyDAL(); PayApplyDAL payApplyDAL = new PayApplyDAL(); InvoiceDAL invoiceDAL = new InvoiceDAL(); SIDAL sIDAL = new SIDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { if (details == null || details.Count == 0) { result.ResultStatus = -1; result.Message = "未选中任务发票"; return result; } //验证总额 decimal sumApplyBala = details.Sum(temp => temp.ApplyBala); if (sumApplyBala != payApply.ApplyBala) { result.ResultStatus = -1; result.Message = "申请总额与分项总额不相等"; return result; } //获取付款申请 result = this.payapplyDAL.Get(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; PayApply resultPayApply = result.ReturnValue as PayApply; if (resultPayApply == null || resultPayApply.PayApplyId <= 0) { result.ResultStatus = -1; result.Message = "付款申请不存在"; return result; } //获取发票申请列表 result = invoicePayApplyDAL.Load(user, resultPayApply.PayApplyId); if (result.ResultStatus != 0) return result; List<InvoicePayApply> resultDetails = result.ReturnValue as List<InvoicePayApply>; if (resultDetails == null) { result.ResultStatus = -1; result.Message = "付款申请发票明细列表获取失败"; return result; } //作废原有发票申请明细 foreach (InvoicePayApply detail in resultDetails) { detail.DetailStatus = StatusEnum.已录入; result = invoicePayApplyDAL.Invalid(user, detail); if (result.ResultStatus != 0) return result; } //验证发票 int payDept = 0; int outCorpId = 0; foreach (InvoicePayApply detail in details) { //获取价外票 result = sIDAL.Get(user, detail.SIId); if (result.ResultStatus != 0) return result; SI sI = result.ReturnValue as SI; if (sI == null || sI.SIId <= 0) { result.ResultStatus = -1; result.Message = "价外票不存在"; return result; } //获取发票 result = invoiceDAL.Get(user, detail.InvoiceId); if (result.ResultStatus != 0) return result; Operate.Model.Invoice invoice = result.ReturnValue as Operate.Model.Invoice; if (invoice == null || invoice.InvoiceId <= 0) { result.ResultStatus = -1; result.Message = "发票不存在"; return result; } //验证币种 if (payApply.CurrencyId != invoice.CurrencyId) { result.ResultStatus = -1; result.Message = "发票币种不一致"; return result; } //验证开票抬头 if (outCorpId == 0) { outCorpId = invoice.OutCorpId; } if (outCorpId != invoice.OutCorpId) { result.ResultStatus = -1; result.Message = "发票开票公司不一致"; return result; } //验证成本部门 if (payDept == 0) { payDept = sI.PayDept; } if (payDept != sI.PayDept) { result.ResultStatus = -1; result.Message = "发票成本部门不一致"; return result; } //验证可申请余额 result = invoicePayApplyDAL.LoadByInvoice(user, detail.InvoiceId); if (result.ResultStatus != 0) return result; resultDetails = result.ReturnValue as List<InvoicePayApply>; if (resultDetails == null) { result.ResultStatus = -1; result.Message = "获取发票已申请列表失败"; return result; } decimal applyBala = resultDetails.Sum(temp => temp.ApplyBala); if (applyBala >= invoice.InvoiceBala) { result.ResultStatus = -1; result.Message = string.Format("发票{0}款项已全部申请", invoice.InvoiceNo); return result; } if (invoice.InvoiceBala - applyBala < detail.ApplyBala) { result.ResultStatus = -1; result.Message = string.Format("发票{0}申请金额超过可申请余额,申请失败", invoice.InvoiceNo); return result; } } //更新申请主表 Department dept = UserProvider.Departments.FirstOrDefault(temp => temp.DeptId == apply.ApplyDept); if (dept == null || dept.DeptId < 0) { result.ResultStatus = -1; result.Message = "申请部门不存在"; return result; } //获取主申请 result = applyDAL.Get(user, resultPayApply.ApplyId); if (result.ResultStatus != 0) return result; Apply resultApply = result.ReturnValue as Apply; if (resultApply == null || resultApply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请获取失败"; return result; } resultApply.ApplyDept = dept.DeptId; resultApply.ApplyCorp = apply.ApplyCorp; resultApply.ApplyDesc = apply.ApplyDesc; resultApply.ApplyTime = apply.ApplyTime; resultApply.EmpId = user.EmpId; result = applyDAL.Update(user, resultApply); if (result.ResultStatus != 0) return result; //更新付款申请表 resultPayApply.RecCorpId = payApply.RecCorpId; resultPayApply.RecBankId = payApply.RecBankId; resultPayApply.RecBankAccountId = payApply.RecBankAccountId; resultPayApply.RecBankAccount = payApply.RecBankAccount; resultPayApply.CurrencyId = payApply.CurrencyId; resultPayApply.ApplyBala = sumApplyBala; resultPayApply.PayMode = payApply.PayMode; resultPayApply.PayDeadline = payApply.PayDeadline; resultPayApply.PayMatter = payApply.PayMatter; resultPayApply.SpecialDesc = payApply.SpecialDesc; result = payapplyDAL.Update(user, resultPayApply); if (result.ResultStatus != 0) return result; //新增发票付款申请关联表 foreach (InvoicePayApply detail in details) { detail.DetailStatus = StatusEnum.已生效; detail.PayApplyId = resultPayApply.PayApplyId; result = invoicePayApplyDAL.Insert(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel PayApplyContractUpdate(UserModel user, PayApply payApply, string memo, int deptId, int corpId) { ResultModel result = new ResultModel(); try { ContractSubDAL subDAL = new ContractSubDAL(); ApplyDAL applyDAL = new ApplyDAL(); PayApplyDAL payApplyDAL = new PayApplyDAL(); ContractPayApplyDAL contractPayApplyDAL = new ContractPayApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证付款申请 result = payApplyDAL.Get(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; PayApply resultObj = result.ReturnValue as PayApply; if (resultObj == null || resultObj.PayApplyId <= 0) { result.ResultStatus = -1; result.Message = "付款申请不存在"; return result; } //验证申请主表 result = applyDAL.Get(user, resultObj.ApplyId); if (result.ResultStatus != 0) return result; Apply apply = result.ReturnValue as Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "申请主表不存在"; return result; } //验证合约付款申请关联表 result = contractPayApplyDAL.GetByPayApplyId(user, resultObj.PayApplyId); if (result.ResultStatus != 0) return result; ContractPayApply contractPayApply = result.ReturnValue as ContractPayApply; if (contractPayApply == null || contractPayApply.RefId <= 0) { result.ResultStatus = -1; result.Message = "与合约关联错误"; return result; } //验证子合约信息 result = subDAL.Get(user, contractPayApply.ContractSubId); if (result.ResultStatus != 0) return result; ContractSub sub = result.ReturnValue as ContractSub; if (sub == null || sub.SubId <= 0) { result.ResultStatus = -1; result.Message = "子合约不存在"; return result; } //验证可申请金额 //NFMT.Data.Model.FuturesPrice futuresPrice = NFMT.Data.BasicDataProvider.FuturesPrices[0]; //更新申请主表 Department dept = UserProvider.Departments.FirstOrDefault(temp => temp.DeptId == deptId); if (dept == null || dept.DeptId < 0) { result.ResultStatus = -1; result.Message = "申请部门不存在"; return result; } apply.ApplyDept = dept.DeptId; apply.ApplyCorp = corpId; apply.ApplyDesc = memo; apply.ApplyType = ApplyType.付款申请; apply.EmpId = user.EmpId; result = applyDAL.Update(user, apply); if (result.ResultStatus != 0) return result; //更新付款申请表 resultObj.PayApplySource = (int)FundsStyleEnum.ContractPayApply; resultObj.RecCorpId = payApply.RecCorpId; resultObj.RecBankId = payApply.RecBankId; resultObj.RecBankAccountId = payApply.RecBankAccountId; resultObj.RecBankAccount = payApply.RecBankAccount; resultObj.ApplyBala = payApply.ApplyBala; resultObj.CurrencyId = payApply.CurrencyId; resultObj.PayMode = payApply.PayMode; resultObj.PayDeadline = payApply.PayDeadline; resultObj.PayMatter = payApply.PayMatter; resultObj.SpecialDesc = payApply.SpecialDesc; result = payapplyDAL.Update(user, resultObj); if (result.ResultStatus != 0) return result; //更新Fun_ContractPayApply_Ref合约付款申请 contractPayApply.ApplyBala = payApply.ApplyBala; result = contractPayApplyDAL.Update(user, contractPayApply); if (result.ResultStatus != 0) return result; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel Invalid(UserModel user, int payApplyId) { ResultModel result = new ResultModel(); try { PayApplyDAL payApplyDAL = new PayApplyDAL(); ApplyDAL applyDAL = new ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证付款申请 result = payApplyDAL.Get(user, payApplyId); if (result.ResultStatus != 0) return result; PayApply payApply = result.ReturnValue as PayApply; if (payApply == null || payApply.PayApplyId <= 0) { result.ResultStatus = -1; result.Message = "付款申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, payApply.ApplyId); if (result.ResultStatus != 0) return result; Apply apply = result.ReturnValue as Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //作废主申请 result = applyDAL.Invalid(user, apply); if (result.ResultStatus != 0) return result; //如果是库存付款申请,同时作废出库付款申请明细 if (payApply.PayApplySource == (int)FundsStyleEnum.StockPayApply) { StockPayApplyDAL stockPayApplyDAL = new StockPayApplyDAL(); result = stockPayApplyDAL.Load(user, payApply.PayApplyId); if (result.ResultStatus != 0) return result; List<StockPayApply> stockPayApplies = result.ReturnValue as List<StockPayApply>; if (stockPayApplies == null) { result.ResultStatus = -1; result.Message = "库存付款明细获取错误"; return result; } foreach (StockPayApply stockPayApply in stockPayApplies) { //作废明细 if (stockPayApply.Status == StatusEnum.已生效) stockPayApply.Status = StatusEnum.已录入; result = stockPayApplyDAL.Invalid(user, stockPayApply); if (result.ResultStatus != 0) return result; } } result.Message = "作废成功"; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel Goback(UserModel user, int payApplyId) { ResultModel result = new ResultModel(); try { PayApplyDAL payApplyDAL = new PayApplyDAL(); ApplyDAL applyDAL = new ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证付款申请 result = payApplyDAL.Get(user, payApplyId); if (result.ResultStatus != 0) return result; PayApply payApply = result.ReturnValue as PayApply; if (payApply == null || payApply.PayApplyId <= 0) { result.ResultStatus = -1; result.Message = "付款申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, payApply.ApplyId); if (result.ResultStatus != 0) return result; Apply apply = result.ReturnValue as Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //主申请状态修改至已撤返 result = applyDAL.Goback(user, apply); if (result.ResultStatus != 0) return result; //工作流任务关闭 DataSourceDAL sourceDAL = new DataSourceDAL(); result = sourceDAL.SynchronousStatus(user, apply); if (result.ResultStatus != 0) return result; result.Message = "撤返成功"; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }