Exemplo n.º 1
0
        public async Task <ActionResult> SubmitMortgage(PublicMortgageViewModel model)
        {
            var response = new BaseResponse <string>();

            var baseAuditDal = new BaseAuditDAL();
            var entity       = baseAuditDal.GetAuthorizeAndSelf(model.ID, CurrentUser);

            if (entity == null)
            {
                response.Status  = "Failed";
                response.Message = new ErrorMessage[] { new ErrorMessage("权限", "权限不足")
                                                        {
                                                        } };
                return(Json(response));
            }
            var publicMortgage = new PublicMortgage();

            #region 验证

            var validator = new MortgageValidator();

            var result = validator.Validate(model);
            if (result.IsNotValid())
            {
                response.Status  = StatusEnum.Failed.ToString();
                response.Message = result.GetErrors().ToArray();
                return(Json(response));
            }

            #endregion 验证

            // 更新baseaudit

            var auditCase = _auditBll.QueryLeatest(model.CaseNum);

            if (auditCase.IsNull() && auditCase.CaseStatus == CaseStatus.PublicMortgage)
            {
                response.Status  = StatusEnum.Failed.ToString();
                response.Message = new[] { new ErrorMessage("", "案件已变更"), };
                return(Json(response));
            }

            // 更新BaseAudit基础信息
            auditCase.OpeningBank = model.OpeningBank;
            auditCase.OpeningSite = model.OpeningSite;
            auditCase.BankCard    = model.BankCard;
            auditCase.LenderName  = model.LenderName; //出借人
                                                      //auditCase.ServiceCharge = model.ServiceCharge;
                                                      //auditCase.ServiceChargeRate = model.ServiceChargeRate;
            auditCase.Deposit          = model.Deposit;
            auditCase.DepositDate      = model.DepositDate;
            auditCase.Description      = model.Description;
            auditCase.IsActivitieRate  = model.IsActivitieRate;
            auditCase.RejectReason     = model.RejectReason;//签约失败理由
            auditCase.LenderName       = model.LenderName;
            auditCase.IntroducerAudits = new List <IntroducerAudit>();

            model.Introducer.IfNotNull(t =>
            {
                model.Introducer.ForEach(item =>
                {
                    if (item.ID.Contains("TEMP"))
                    {
                        item.ID = Guid.NewGuid().ToString();
                    }
                    auditCase.IntroducerAudits.Add(item.MaptoIntroducerAudit());
                });
            });

            publicMortgage = model.CastDB(model);

            //合同文件
            publicMortgage.ContractFile = SaveFiles(model.ContractFile, model.ID, model.ID);
            // 四条
            publicMortgage.FourFile = SaveFiles(model.FourFile, model.ID, model.ID);
            //收据
            publicMortgage.OtherFile = SaveFiles(model.OtherFile, model.ID, model.ID);

            ////借条
            //publicMortgage.NoteFile = SaveFiles(model.NoteFile, model.ID, model.ID);
            ////他证
            //publicMortgage.ReceiptFile = SaveFiles(model.ReceiptFile, model.ID, model.ID);
            ////承诺书
            //publicMortgage.UndertakingFile = SaveFiles(model.UndertakingFile, model.ID, model.ID);
            ////联系方式确认书
            //publicMortgage.ContactConfirmFile = SaveFiles(model.ContactConfirmFile, model.ID, model.ID);

            //还款委托书
            publicMortgage.RepaymentAttorneyFile = SaveFiles(model.RepaymentAttorneyFile, model.ID, model.ID);
            //授权委托书
            publicMortgage.PowerAttorneyFile = SaveFiles(model.PowerAttorneyFile, model.ID, model.ID);
            //收件收据
            publicMortgage.CollectionFile = SaveFiles(model.CollectionFile, model.ID, model.ID);
            publicMortgage.CreateUser     = CurrentUser.UserName;
            publicMortgage.CreateTime     = DateTime.Now;

            // 推送到Hats  20160909 修改,推送在确认签约要件之后

            var isSuccess = _mortgageBll.SubmitCase(publicMortgage, auditCase, CurrentUser.UserName);

            //_mortgageDal.SubmitCase(publicMortgage, model.Description, CurrentUser.UserName);
            //_mortgageDal.AcceptAllChange();
            if (isSuccess)
            {
                response.Status = StatusEnum.Success.ToString();
            }
            else
            {
                response.Status  = StatusEnum.Failed.ToString();
                response.Message = new[] { new ErrorMessage("", "更新出错") };
            }

            /*
             * var publicMortgageDto = new PublicMortgageDto();
             *
             * Infrastructure.ExtendTools.ObjectExtend.CopyTo(model, publicMortgageDto);
             * if (model.Introducer != null && model.Introducer.Any())
             * {
             *  foreach (var r in model.Introducer)
             *  {
             *      var newIntro = new IntroducerAudit();
             *      Infrastructure.ExtendTools.ObjectExtend.CopyTo(r, newIntro);
             *      publicMortgageDto.Introducer.Add(newIntro);
             *  }
             * }
             *
             * UserDAL ud = new UserDAL();
             * var contr = await ud.FindById(publicMortgageDto.ContractPerson);
             * publicMortgageDto.ContractPersonText = contr.DisplayName;
             * var pushResult = _mortgagePush.PushToHats(publicMortgageDto);
             * if (pushResult.IsSuccess)
             * {
             *  bool isSuccess = _mortgageBll.SubmitCase(publicMortgage, auditCase, CurrentUser.UserName);
             *
             *  //_mortgageDal.SubmitCase(publicMortgage, model.Description, CurrentUser.UserName);
             *  //_mortgageDal.AcceptAllChange();
             *  if (isSuccess)
             *  {
             *      response.Status = StatusEnum.Success.ToString();
             *  }
             *  else
             *  {
             *      response.Status = StatusEnum.Failed.ToString();
             *      response.Message = new[] { new ErrorMessage("", "更新出错") };
             *  }
             * }
             * else
             * {
             *  response.Status = StatusEnum.Failed.ToString();
             *  response.Message = new[] { new ErrorMessage("", pushResult.Message) };
             * }   */

            return(Json(response));
        }
Exemplo n.º 2
0
        public ActionResult EditMortgage(PublicMortgageViewModel model)
        {
            var response = new BaseResponse <string>();

            var bad    = new BaseAuditDAL();
            var entity = bad.GetAuthorizeAndSelf(model.ID, CurrentUser);

            if (entity == null)
            {
                response.Status  = "Failed";
                response.Message = new ErrorMessage[] { new ErrorMessage("权限", "权限不足")
                                                        {
                                                        } };
                return(Json(response));
            }

            var auditCase = _auditBll.QueryLeatest(model.CaseNum);

            if (auditCase.IsNull() || auditCase.CaseStatus != CaseStatus.PublicMortgage)
            {
                response.Status  = StatusEnum.Failed.ToString();
                response.Message = new[] { new ErrorMessage("", "案件已变更"), };
                return(Json(response));
            }

            // 更新BaseAudit基础信息
            auditCase.OpeningBank = model.OpeningBank;
            auditCase.OpeningSite = model.OpeningSite;
            auditCase.BankCard    = model.BankCard;

            //auditCase.ServiceCharge = model.ServiceCharge;
            //auditCase.ServiceChargeRate = model.ServiceChargeRate;
            auditCase.Deposit         = model.Deposit;
            auditCase.DepositDate     = model.DepositDate;
            auditCase.IsActivitieRate = model.IsActivitieRate;
            auditCase.RejectReason    = model.RejectReason;
            auditCase.LenderName      = model.LenderName;

            //auditCase.IntroducerAudits = new List<IntroducerAudit>();
            //model.Introducer.IfNotNull(t =>
            //{
            //    model.Introducer.ForEach(item =>
            //    {
            //        if (item.ID.Contains("TEMP"))
            //        {
            //            item.ID = Guid.NewGuid().ToString();
            //        }

            //        auditCase.IntroducerAudits.Add(item.MaptoIntroducerAudit());
            //    });
            //});

            var mortgage = model.CastDB(model);

            // 合同文件
            mortgage.ContractFile = SaveFiles(model.ContractFile, model.ID, model.ID);
            // 四条
            mortgage.FourFile = SaveFiles(model.FourFile, model.ID, model.ID);
            // 收据
            mortgage.OtherFile = SaveFiles(model.OtherFile, model.ID, model.ID);

            //// 借条
            //mortgage.NoteFile = SaveFiles(model.NoteFile, model.ID, model.ID);
            //// 他证
            //mortgage.ReceiptFile = SaveFiles(model.ReceiptFile, model.ID, model.ID);
            //// 承诺书
            //mortgage.UndertakingFile = SaveFiles(model.UndertakingFile, model.ID, model.ID);
            //// 联系方式确认书
            //mortgage.ContactConfirmFile = SaveFiles(model.ContactConfirmFile, model.ID, model.ID);

            // 还款委托书
            mortgage.RepaymentAttorneyFile = SaveFiles(model.RepaymentAttorneyFile, model.ID, model.ID);
            // 授权委托书
            mortgage.PowerAttorneyFile = SaveFiles(model.PowerAttorneyFile, model.ID, model.ID);
            // 收件收据
            mortgage.CollectionFile = SaveFiles(model.CollectionFile, model.ID, model.ID);

            mortgage.CreateTime = DateTime.Now;
            mortgage.CreateUser = CurrentUser.UserName;

            //  _mortgageBll.Edit(mortgage, auditCase, CurrentUser.UserName);
            //_mortgageDal.Update(mortgage);

            _mortgageDal.Update(mortgage);
            _baseAuditDal.Update(auditCase);

            _mortgageDal.AcceptAllChange();
            return(base.GetBaseResponse <object>(true));
        }