public ActionResult GongzhiBaoApplyProvide(Loan loan) { string message = string.Empty; //用户最近的一笔贷款申请[未撤销] Loan loan2 = _loanService.GetNewestLoanApplyByMpUserId(MpUserID); //有未过期的贷款申请 if (loan2 != null && DateTime.Now < loan2.CreateDate.AddMonths(1)) { return(JsonMessage(false, "您当前已经申请过贷款")); } try { _loanService.BeginTransaction(); //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); //进行手机验证 if (mpUser.IsAuth == 0) { int useCount = _mobileCodeService.GetMobileCodeCount(this.MpUserID, 2);//当天使用次数 if (useCount <= 5) { MobileCode lastCode = _mobileCodeService.GetMobileCode(this.MpUserID, 2);//是否存在未使用的证码 if (lastCode != null) { //验证 MobileCode mobileCode = _mobileCodeService.GetMobileCode(loan.Phone, RQuery["Code"], MpUserID, 2); if (mobileCode != null) { TimeSpan ts = DateTime.Now.Subtract(mobileCode.CreateDate).Duration(); if (ts.Minutes > 10) { return(JsonMessage(false, "验证码已经失效,请重新获取")); } mpUser.Name = loan.LoanName; mpUser.MobilePhone = loan.Phone; mpUser.IsAuth = 1; _mpUserService.Update(mpUser); } else { lastCode.Time += 1; _mobileCodeService.Update(lastCode); return(JsonMessage(false, "对不起,验证码有误,请检查!")); } } else { return(JsonMessage(false, "对不起,您还未点击发送验证码!")); } } else { return(JsonMessage(false, "对不起,您今天最多只能发起5次验证码")); } } //处理贷款业务 loan.MpUserId = MpUserID; loan.Status = loan.AssignStatus = loan.ProcessStatus = 0; _loanService.Insert(loan); } catch (Exception ex) { _loanService.Rollback(); throw new OceanException(string.Format("对不起,{0}!", ex.Message)); } finally { _loanService.Commit(); } return(JsonMessage(true, "提交成功,等待管理员审核")); }