Example #1
0
        public ResultModel PaymentInvoiceCreate(UserModel user, Model.Payment payment, List<Model.PaymentInvioceDetail> paymentInvoiceDetails, int payApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PayApplyDAL payApplyDAL = new PayApplyDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new NFMT.Operate.DAL.ApplyDAL();
                DAL.InvoicePayApplyDAL invoicePayApplyDAL = new InvoicePayApplyDAL();
                DAL.PaymentInvioceDetailDAL paymentInvoiceDetailDAL = new PaymentInvioceDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    foreach (Model.PaymentInvioceDetail d in paymentInvoiceDetails)
                    {
                        d.PayBala = d.FundsBala + d.VirtualBala;
                    }

                    //验证付款总额是否等于财务付款金额+虚拟付款金额
                    if (payment.PayBala != payment.FundsBala + payment.VirtualBala)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款总额必须等于财务付款金额+虚拟付款金额";
                        return result;
                    }

                    //验证付款申请
                    result = payApplyDAL.Get(user, payApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    Model.PayApply payApply = result.ReturnValue as Model.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;
                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款主申请不存在";
                        return result;
                    }

                    //判断申请状态是否已生效
                    if (apply.ApplyStatus != NFMT.Common.StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款申请非已生效状态,不能进行付款";
                        return result;
                    }

                    //获取当前付款申请中的所有付款
                    result = paymentDAL.Load(user, payApply.PayApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.Payment> payments = result.ReturnValue as List<Model.Payment>;
                    if (payments == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取当前付款申请的付款执行失败";
                        return result;
                    }

                    //判断付款申请可付余额
                    decimal payedBala = payments.Sum(temp => temp.PayBala);
                    if (payApply.ApplyBala - payedBala < 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "当前付款申请已无余款可付";
                        return result;
                    }

                    if (payApply.ApplyBala - payedBala - payment.PayBala < 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "当前付款金额大于可付余额";
                        return result;
                    }

                    //获取付款申请对应发票明细列表
                    result = invoicePayApplyDAL.Load(user, payApply.PayApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.InvoicePayApply> invoicePayApplies = result.ReturnValue as List<Model.InvoicePayApply>;
                    if (invoicePayApplies == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款申请明细失败";
                        return result;
                    }

                    foreach (Model.PaymentInvioceDetail d in paymentInvoiceDetails)
                    {
                        if (d.PayBala > 0)
                        {
                            //获取当前发票付款明细列表
                            result = paymentInvoiceDetailDAL.LoadByInvoicePayApplyId(user, d.PayApplyDetailId);
                            if (result.ResultStatus != 0)
                                return result;

                            List<Model.PaymentInvioceDetail> details = result.ReturnValue as List<Model.PaymentInvioceDetail>;
                            decimal detailPayedBala = details.Sum(temp => temp.PayBala);

                            var ls = paymentInvoiceDetails.Where(temp => temp.PayApplyDetailId == d.PayApplyDetailId);
                            decimal detailPayingBala = ls.Sum(temp => temp.PayBala);

                            //获取对应的申请明细
                            result = invoicePayApplyDAL.Get(user, d.PayApplyDetailId);
                            if (result.ResultStatus != 0)
                                return result;

                            InvoicePayApply invoicePayApply = result.ReturnValue as InvoicePayApply;
                            if (invoicePayApply == null || invoicePayApply.RefId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = string.Format("发票申请明细获取失败");
                                return result;
                            }

                            if (invoicePayApply.ApplyBala - detailPayedBala - detailPayingBala < 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = string.Format("发票申请明细付款超额");
                                return result;
                            }
                        }
                    }

                    decimal sumPayBala = paymentInvoiceDetails.Sum(temp => temp.PayBala);
                    decimal sumFundsBala = paymentInvoiceDetails.Sum(temp => temp.FundsBala);
                    decimal sumVirtualBala = paymentInvoiceDetails.Sum(temp => temp.VirtualBala);

                    //添加付款表
                    payment.PayEmpId = user.EmpId;
                    payment.PayDept = apply.ApplyDept;
                    payment.PayApplyId = payApply.PayApplyId;
                    payment.PayBala = sumPayBala;
                    payment.FundsBala = sumFundsBala;
                    payment.VirtualBala = sumVirtualBala;
                    payment.PaymentStatus = StatusEnum.已录入;

                    result = paymentDAL.Insert(user, payment);
                    if (result.ResultStatus != 0)
                        return result;

                    int paymentId = 0;
                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out paymentId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款新增失败";
                        return result;
                    }
                    payment.PaymentId = paymentId;

                    //添加付款发票明细表
                    foreach (PaymentInvioceDetail d in paymentInvoiceDetails)
                    {
                        if (d.PayBala > 0)
                        {
                            //获取发票付款申请
                            result = invoicePayApplyDAL.Get(user, d.PayApplyDetailId);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.InvoicePayApply dp = result.ReturnValue as Model.InvoicePayApply;
                            if (dp == null || dp.RefId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "对应付款申请获取失败";
                                return result;
                            }

                            d.DetailStatus = Common.StatusEnum.已生效;
                            d.PaymentId = paymentId;
                            d.InvoiceId = dp.InvoiceId;
                            d.PayApplyId = dp.PayApplyId;
                            d.PayApplyDetailId = dp.RefId;

                            result = paymentInvoiceDetailDAL.Insert(user, d);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    //添加虚拟收付款
                    if (payment.VirtualBala > 0)
                    {
                        if (payment.VirtualBala > payment.PayBala)
                        {
                            result.ResultStatus = -1;
                            result.Message = "虚拟付款金额不能大于付款总额";
                            return result;
                        }

                        DAL.PaymentVirtualDAL virtualDAL = new PaymentVirtualDAL();
                        Model.PaymentVirtual paymentVirtual = new PaymentVirtual();
                        paymentVirtual.PayApplyId = payApply.PayApplyId;
                        paymentVirtual.PayBala = payment.VirtualBala;
                        paymentVirtual.PaymentId = paymentId;
                        paymentVirtual.DetailStatus = StatusEnum.已录入;

                        result = virtualDAL.Insert(user, paymentVirtual);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Example #2
0
        public ResultModel PaymentInvoiceUpdate(UserModel user, Model.Payment payment, List<Model.PaymentInvioceDetail> paymentInvoiceDetails)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PayApplyDAL payApplyDAL = new PayApplyDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new NFMT.Operate.DAL.ApplyDAL();
                DAL.InvoicePayApplyDAL invoicePayApplyDAL = new InvoicePayApplyDAL();
                DAL.PaymentInvioceDetailDAL paymentInvoiceDetailDAL = new PaymentInvioceDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (paymentInvoiceDetails == null || paymentInvoiceDetails.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "未填写任何发票明细";
                        return result;
                    }

                    foreach (Model.PaymentInvioceDetail d in paymentInvoiceDetails)
                    {
                        d.PayBala = d.FundsBala + d.VirtualBala;
                    }

                    //验证付款总额是否等于财务付款金额+虚拟付款金额
                    if (payment.PayBala != payment.FundsBala + payment.VirtualBala)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款总额必须等于财务付款金额+虚拟付款金额";
                        return result;
                    }

                    //获取财务付款
                    result = this.paymentDAL.Get(user, payment.PaymentId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.Payment resultPayment = result.ReturnValue as Model.Payment;
                    if (resultPayment == null || resultPayment.PaymentId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务付款不存在,不能进行修改";
                        return result;
                    }

                    //验证付款申请
                    result = payApplyDAL.Get(user, resultPayment.PayApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    Model.PayApply payApply = result.ReturnValue as Model.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;
                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款主申请不存在";
                        return result;
                    }

                    //判断申请状态是否已生效
                    if (apply.ApplyStatus != NFMT.Common.StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款申请非已生效状态,不能进行付款";
                        return result;
                    }

                    //获取当前付款申请中的所有付款
                    result = paymentDAL.Load(user, payApply.PayApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.Payment> payments = result.ReturnValue as List<Model.Payment>;
                    if (payments == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取当前付款申请的付款执行失败";
                        return result;
                    }

                    //判断付款申请可付余额
                    decimal payedBala = payments.Sum(temp => temp.PayBala);
                    if (payApply.ApplyBala - payedBala < 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "当前付款申请已无余款可付";
                        return result;
                    }

                    if (payApply.ApplyBala - payedBala - payment.PayBala + resultPayment.PayBala < 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "当前付款金额大于可付余额";
                        return result;
                    }

                    //获取付款申请对应发票明细列表
                    result = invoicePayApplyDAL.Load(user, payApply.PayApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.InvoicePayApply> invoicePayApplies = result.ReturnValue as List<Model.InvoicePayApply>;
                    if (invoicePayApplies == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "付款申请明细失败";
                        return result;
                    }

                    //作废原有财务付款发票明细
                    result = paymentInvoiceDetailDAL.Load(user, payment.PaymentId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.PaymentInvioceDetail> resultDetails = result.ReturnValue as List<Model.PaymentInvioceDetail>;
                    if (resultDetails == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取财务付款明细失败";
                        return result;
                    }

                    foreach (PaymentInvioceDetail d in resultDetails)
                    {
                        d.Status = StatusEnum.已录入;
                        result = paymentInvoiceDetailDAL.Invalid(user, d);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    foreach (Model.PaymentInvioceDetail d in paymentInvoiceDetails)
                    {
                        if (d.PayBala > 0)
                        {
                            //获取当前发票付款明细列表
                            result = paymentInvoiceDetailDAL.LoadByInvoicePayApplyId(user, d.PayApplyDetailId);
                            if (result.ResultStatus != 0)
                                return result;

                            List<Model.PaymentInvioceDetail> details = result.ReturnValue as List<Model.PaymentInvioceDetail>;
                            decimal detailPayedBala = details.Sum(temp => temp.PayBala);

                            var ls = paymentInvoiceDetails.Where(temp => temp.PayApplyDetailId == d.PayApplyDetailId);
                            decimal detailPayingBala = ls.Sum(temp => temp.PayBala);

                            //获取对应的申请明细
                            result = invoicePayApplyDAL.Get(user, d.PayApplyDetailId);
                            if (result.ResultStatus != 0)
                                return result;

                            InvoicePayApply invoicePayApply = result.ReturnValue as InvoicePayApply;
                            if (invoicePayApply == null || invoicePayApply.RefId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = string.Format("发票申请明细获取失败");
                                return result;
                            }

                            if (invoicePayApply.ApplyBala - detailPayedBala - detailPayingBala < 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = string.Format("发票申请明细付款超额");
                                return result;
                            }
                        }
                    }

                    decimal sumPayBala = paymentInvoiceDetails.Sum(temp => temp.PayBala);
                    decimal sumFundsBala = paymentInvoiceDetails.Sum(temp => temp.FundsBala);
                    decimal sumVirtualBala = paymentInvoiceDetails.Sum(temp => temp.VirtualBala);

                    //添加付款表
                    resultPayment.PayEmpId = user.EmpId;
                    resultPayment.PayDept = apply.ApplyDept;
                    resultPayment.PayApplyId = payApply.PayApplyId;
                    resultPayment.PayBala = sumPayBala;
                    resultPayment.FundsBala = sumFundsBala;
                    resultPayment.VirtualBala = sumVirtualBala;
                    resultPayment.CurrencyId = payment.CurrencyId;
                    resultPayment.PayStyle = payment.PayStyle;
                    resultPayment.PayBankId = payment.PayBankId;
                    resultPayment.PayBankAccountId = payment.PayBankAccountId;
                    resultPayment.PayCorp = payment.PayCorp;
                    resultPayment.PayDatetime = payment.PayDatetime;
                    resultPayment.RecevableCorp = payment.RecevableCorp;
                    resultPayment.ReceBankId = payment.ReceBankId;
                    resultPayment.ReceBankAccountId = payment.ReceBankAccountId;
                    resultPayment.ReceBankAccount = payment.ReceBankAccount;
                    resultPayment.FlowName = payment.FlowName;
                    resultPayment.Memo = payment.Memo;

                    result = paymentDAL.Update(user, resultPayment);
                    if (result.ResultStatus != 0)
                        return result;

                    //添加付款发票明细表
                    foreach (PaymentInvioceDetail d in paymentInvoiceDetails)
                    {
                        if (d.PayBala > 0)
                        {
                            //获取发票付款申请
                            result = invoicePayApplyDAL.Get(user, d.PayApplyDetailId);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.InvoicePayApply dp = result.ReturnValue as Model.InvoicePayApply;
                            if (dp == null || dp.RefId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "对应付款申请获取失败";
                                return result;
                            }

                            d.DetailStatus = Common.StatusEnum.已生效;
                            d.PaymentId = resultPayment.PaymentId;
                            d.InvoiceId = dp.InvoiceId;
                            d.PayApplyId = dp.PayApplyId;
                            d.PayApplyDetailId = dp.RefId;

                            result = paymentInvoiceDetailDAL.Insert(user, d);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    //虚拟收付款
                    //获取虚拟收付款明细
                    DAL.PaymentVirtualDAL paymentVirtualDAL = new PaymentVirtualDAL();

                    result = paymentVirtualDAL.GetByPaymentId(user, payment.PaymentId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.PaymentVirtual paymentVirtual = result.ReturnValue as Model.PaymentVirtual;
                    if (paymentVirtual == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取虚拟收付款信息失败";
                        return result;
                    }
                    if (payment.VirtualBala == 0)
                    {
                        if (paymentVirtual.VirtualId > 0)
                        {
                            //作废原有虚拟收付款
                            result = paymentVirtualDAL.Invalid(user, paymentVirtual);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }
                    else
                    {
                        if (payment.VirtualBala > payment.PayBala)
                        {
                            result.ResultStatus = -1;
                            result.Message = "虚拟付款金额不能大于付款总额";
                            return result;
                        }

                        if (paymentVirtual.VirtualId > 0)
                        {
                            //更新虚拟收付款
                            paymentVirtual.PayBala = payment.VirtualBala;
                            result = paymentVirtualDAL.Update(user, paymentVirtual);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                        else
                        {
                            //新增虚拟收付款
                            paymentVirtual.PayApplyId = resultPayment.PayApplyId;
                            paymentVirtual.PayBala = payment.VirtualBala;
                            paymentVirtual.PaymentId = resultPayment.PaymentId;
                            paymentVirtual.DetailStatus = StatusEnum.已录入;

                            result = paymentVirtualDAL.Insert(user, paymentVirtual);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Example #3
0
        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;
        }