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, "提交成功,等待管理员审核")); }
public ActionResult PosApplyProvide(string isEdit) { string message = string.Empty; bool isSuccess = true; if (!ValidatorPos(ref message)) { return(JsonMessage(false, message)); } //用户最近的一笔申请[未撤销] PosApply apply2 = _posApplyService.GetUnique(pos => pos.MpUserId == MpUserID && pos.Status == 0, "CreateDate", false); //有未过期的贷款申请 if (apply2 != null && !(isEdit == "1" && (DateTime.Now - apply2.CreateDate).Hours <= 24)) { return(RedirectToAction("PosMessage", new { })); } try { _posApplyService.BeginTransaction(); //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); PosAuth posAuth = _posAuthService.GetUnique(pos => pos.MpUserId == mpUser.Id); ViewBag.IsAuth = false; if (posAuth != null) { ViewBag.IsAuth = posAuth.IsAuth > 0; } //进行手机验证 if (!ViewBag.IsAuth) { int useCount = _mobileCodeService.GetMobileCodeCount(this.MpUserID, 3);//当天使用次数 if (useCount <= 5) { MobileCode lastCode = _mobileCodeService.GetMobileCode(this.MpUserID, 3);//是否存在未使用的证码 if (lastCode != null) { //验证 MobileCode mobileCode = _mobileCodeService.GetMobileCode(RQuery["MobilePhone"], RQuery["Code"], MpUserID, 3); if (mobileCode != null) { TimeSpan ts = DateTime.Now.Subtract(mobileCode.CreateDate).Duration(); if (ts.Minutes > 10) { ViewBag.CodeError = "验证码已经失效,请重新获取"; isSuccess = false; } PosAuth auth = new PosAuth(); auth.MpUserId = MpUserID; auth.Name = RQuery["Name"]; auth.MobilePhone = RQuery["MobilePhone"]; auth.IsAuth = 1; _posAuthService.Insert(auth); } else { lastCode.Time += 1; _mobileCodeService.Update(lastCode); ViewBag.CodeError = "对不起,验证码有误,请检查!"; isSuccess = false; } } else { ViewBag.CodeError = "对不起,您还未点击发送验证码!"; isSuccess = false; } } else { ViewBag.CodeError = "对不起,您今天最多只能发起5次验证码!"; isSuccess = false; } } //处理贷款业务 if (isEdit == "1") { if (apply2 != null) { TryUpdateModel <PosApply>(apply2); if (isSuccess) { _posApplyService.Update(apply2); } } else { throw new OceanException("对不起,您的参数有误,请联系客服!"); } } else { apply2 = new PosApply(); TryUpdateModel <PosApply>(apply2); apply2.MpUserId = MpUserID; apply2.Status = apply2.AssignStatus = apply2.ProcessStatus = 0; if (isSuccess) { _posApplyService.Insert(apply2); } } } catch (Exception ex) { _posApplyService.Rollback(); throw new OceanException(string.Format("对不起,{0}!", ex.Message)); } finally { _posApplyService.Commit(); } if (isSuccess) { return(RedirectToAction("PosApply")); } else { return(View("PosApply", apply2)); } }
public ActionResult Index() { if (!string.IsNullOrEmpty(this.OpenID)) { Funongbao fnb = _funongbaoService.GetFunongbaoByOpenid(this.OpenID); if (fnb != null) { return(new RedirectResult("/funongbao/apply")); } } Funongbao funongbao = new Funongbao(); if (WebHelper.IsPost()) { ViewBag.AuthStatus = 0; TryUpdateModel <Funongbao>(funongbao); int useCount = _mobileCodeService.GetMobileCodeCount(this.MpUserID, 1);//当天使用次数 if (useCount <= 5) { MobileCode lastCode = _mobileCodeService.GetMobileCode(this.MpUserID, 1);//是否存在未使用的证码 if (lastCode != null) { MobileCode checkCode = _mobileCodeService.GetMobileCode(funongbao.MobilePhone, WebHelper.GetString("Code"), this.MpUserID, 1);//检查验证码 if (checkCode != null) { TimeSpan ts = DateTime.Now.Subtract(checkCode.CreateDate).Duration(); if (ts.Minutes > 10) { checkCode.Time += 1; checkCode.Status = 1; _mobileCodeService.Update(lastCode); ViewBag.CodeError = "验证码已经失效,请重新获取!"; } else { Funongbao authFnb = null; int authStatus = _funongbaoService.IdentAuth2(funongbao, out authFnb); if (authStatus == -1) { ViewBag.CodeError = "对不起,该客户已经被绑定了,您无法再次绑定!"; } else { if (authStatus == 1) { //更新用户认证并更新cookie MpUser user = _mpUserservice.GetById(this.MpUserID); user.Name = funongbao.Name; user.PassportNO = funongbao.PassportNO; user.MobilePhone = funongbao.MobilePhone; user.IsAuth = 1; //更新当前验证码失败 checkCode.Status = 1;//已用 //更新福农保信息 authFnb.IsAuth = 1; authFnb.IsSignAgreement = WebHelper.GetInt("IsSignAgreement", 1); authFnb.MpUserId = this.MpUserID; authFnb.OpenId = this.OpenID; try { Log4NetImpl.Write("测试事务写入"); _funongbaoService.BeginTransaction(); _mpUserservice.Update(user); _mobileCodeService.Update(checkCode); _funongbaoService.Update(authFnb); _funongbaoService.Commit(); WriteMpUserCookie(user); Log4NetImpl.Write("测试获取cookie"); var a = MpUserArr; if (!string.IsNullOrEmpty(WebHelper.GetString("refUrl"))) { return(Redirect(WebHelper.GetString("refUrl"))); } else { return(RedirectToAction("index", "funongbao")); } } catch (Exception ex) { _funongbaoService.Rollback(); Log4NetImpl.Write(ex.ToString()); throw new OceanException("对不起,系统异常,身份认证失败!", ex); } } else { ViewBag.AuthStatus = authStatus; } } } } else { lastCode.Time += 1; _mobileCodeService.Update(lastCode); ViewBag.CodeError = "对不起,验证码有误,请检查!"; } } else { ViewBag.CodeError = "对不起,您还未点击发送验证码!"; } } else { ViewBag.CodeError = "对不起,您今天最多只能发起5次验证码"; } } return(View(funongbao)); }