public ActionResult MyPosNo() { //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); PosAuth posAuth = _posAuthService.GetUnique(pos => pos.MpUserId == mpUser.Id); //if (posAuth == null) //{ // return RedirectToAction("PosApply"); //} if (posAuth != null) { ViewBag.Name = posAuth.Name; } else { ViewBag.Name = mpUser.NickName; } if (mpUser.Sex == 1) { ViewBag.Sex = "先生"; } else if (mpUser.Sex == 2) { ViewBag.Sex = "女士"; } else { ViewBag.Sex = ""; } return(View()); }
public ActionResult PosApplyView(Guid id) { if (!base.HasPermission("PosApply", PermissionOperate.view)) { return(base.ShowNotPermissionTip("")); } PosApply apply = _posApplyService.GetById(id); PosAuth posAuth = _posAuthService.GetUnique(p => p.MpUserId == apply.MpUserId); ViewBag.PosAuth = posAuth; return(View(apply)); }
public ActionResult MyPosBind(Guid id) { //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); PosAuth posAuth = _posAuthService.GetUnique(p => p.MpUserId == mpUser.Id); //if (posAuth == null) //{ // return RedirectToAction("PosApply"); //} if (posAuth != null) { ViewBag.Name = posAuth.Name; } else { ViewBag.Name = mpUser.NickName; } if (mpUser.Sex == 1) { ViewBag.Sex = "先生"; } else if (mpUser.Sex == 2) { ViewBag.Sex = "女士"; } else { ViewBag.Sex = ""; } string mpuserId = MpUserID.ToString(); Pos pos = _posService.GetUnique(p => p.Id == id && p.MpUserIds.Contains(mpuserId)); if (pos == null) { throw new OceanException("对不起,参数有误,请检查!"); } return(View(pos)); }
public ActionResult MyPosUnbind(Guid id) { //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); PosAuth posAuth = _posAuthService.GetUnique(p => p.MpUserId == mpUser.Id); //if (posAuth == null) //{ // return JsonMessage(false, "对不起,您还未申请POS,请先申请!"); //} if (posAuth != null) { ViewBag.Name = posAuth.Name; } else { ViewBag.Name = mpUser.NickName; } if (mpUser.Sex == 1) { ViewBag.Sex = "先生"; } else if (mpUser.Sex == 2) { ViewBag.Sex = "女士"; } else { ViewBag.Sex = ""; } if (id != Guid.Empty) { _posService.ExcuteSql("update Pos set MpUserIds=replace(MpUserIds,'," + MpUserID.ToString() + "',''),MobilePhones=replace(MobilePhones,'," + posAuth.MobilePhone + "','') where id='" + id.ToString() + "'"); } else { _posService.ExcuteSql("update Pos set MpUserIds=replace(MpUserIds,'," + MpUserID.ToString() + "',''),MobilePhones=replace(MobilePhones,'," + posAuth.MobilePhone + "','') where MpUserIds like '%" + MpUserID.ToString() + "%'"); } return(JsonMessage(true)); }
public ActionResult MyPosBindList() { string mpuserid = MpUserID.ToString(); IList <Pos> pos = _posService.GetALL(p => p.MpUserIds.Contains(mpuserid)); if (pos == null || pos.Count == 0) { return(RedirectToAction("MyPos")); } //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); PosAuth posAuth = _posAuthService.GetUnique(p => p.MpUserId == mpUser.Id); //if (posAuth == null) //{ // return RedirectToAction("PosApply"); //} if (posAuth != null) { ViewBag.Name = posAuth.Name; } else { ViewBag.Name = mpUser.NickName; } if (mpUser.Sex == 1) { ViewBag.Sex = "先生"; } else if (mpUser.Sex == 2) { ViewBag.Sex = "女士"; } else { ViewBag.Sex = ""; } return(View(pos)); }
public ActionResult PosApply(string isEdit) { //当前登录用户 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; } ViewBag.Name = mpUser.Name; if (mpUser.Sex == 1) { ViewBag.Sex = "先生"; } else if (mpUser.Sex == 2) { ViewBag.Sex = "女士"; } else { ViewBag.Sex = ""; } //用户最近的一笔贷款申请[未撤销] PosApply posApply = _posApplyService.GetUnique(pos => pos.MpUserId == MpUserID && pos.Status == 0 && pos.ProcessStatus == 0, "CreateDate", false); //有未过期的贷款申请 if (posApply != null && !(isEdit == "1" && (DateTime.Now - posApply.CreateDate).Hours <= 24)) { return(RedirectToAction("PosMessage", new { })); } if (posApply == null) { posApply = new PosApply(); } return(View(posApply)); }
public ActionResult MyPos() { //int count=_posService.GetCount("sele count(*) from Pos where MpUserIds like '%"+MpUserID.ToString()+"%'"); //if (count > 0) //{ // return RedirectToAction("MyPosBindList"); //} //else //{ //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); PosAuth posAuth = _posAuthService.GetUnique(pos => pos.MpUserId == mpUser.Id); //if (posAuth == null) //{ // return RedirectToAction("PosApply"); //} if (posAuth != null) { ViewBag.Name = posAuth.Name; } else { ViewBag.Name = mpUser.NickName; } if (mpUser.Sex == 1) { ViewBag.Sex = "先生"; } else if (mpUser.Sex == 2) { ViewBag.Sex = "女士"; } else { ViewBag.Sex = ""; } return(View()); //} }
/// <summary> /// 把数据渲染到Excel /// </summary> private MemoryStream RenderToExcel(PosApply apply) { MemoryStream ms = new MemoryStream(); IWorkbook workbook = null; ISheet sheet = null; MpUser mpUser = _mpUserService.GetById(apply.MpUserId); PosAuth posAuth = _posAuthService.GetUnique(p => p.MpUserId == mpUser.Id); try { using (FileStream fileStream = System.IO.File.OpenRead(FileHelper.GetMapPath("/Content/ExcelTemplate/PosTemplate.xls"))) //打开xls文件 { workbook = new HSSFWorkbook(fileStream); sheet = workbook.GetSheetAt(0); sheet.GetRow(1).GetCell(1).SetCellValue(posAuth.Name); sheet.GetRow(1).GetCell(3).SetCellValue(posAuth.MobilePhone); sheet.GetRow(1).GetCell(5).SetCellValue(apply.VendorAddress); sheet.GetRow(2).GetCell(1).SetCellValue(base.LoginAdmin.PermissionOrganization.Name); sheet.GetRow(2).GetCell(3).SetCellValue(DateTime.Now.ToString("yyyy-MM-dd")); sheet.GetRow(3).GetCell(1).SetCellValue(apply.AssignSubbranch); sheet.GetRow(3).GetCell(3).SetCellValue(apply.AssignCustomerManager); sheet.GetRow(5).GetCell(0).SetCellValue(string.Format("请于{0}之前反馈处理结果", apply.CreateDate.AddDays(5).ToString("yyyy-MM-dd"))); workbook.Write(ms); ms.Flush(); ms.Position = 0; } return(ms); } finally { ms.Close(); workbook = null; sheet = null; } }
public ActionResult MyPos(Pos pos) { //当前登录用户 MpUser mpUser = _mpUserService.GetById(MpUserID); PosAuth posAuth = _posAuthService.GetUnique(p => p.MpUserId == mpUser.Id); //if (posAuth == null) //{ // return JsonMessage(false, "对不起,您还未申请POS,请先申请!"); //} if (posAuth != null) { ViewBag.Name = posAuth.Name; } else { ViewBag.Name = mpUser.NickName; } if (mpUser.Sex == 1) { ViewBag.Sex = "先生"; } else if (mpUser.Sex == 2) { ViewBag.Sex = "女士"; } else { ViewBag.Sex = ""; } int useCount = _mobileCodeService.GetMobileCodeCount(this.MpUserID, 4);//当天使用次数 if (useCount <= 5) { MobileCode lastCode = _mobileCodeService.GetMobileCode(this.MpUserID, 4);//是否存在未使用的证码 if (lastCode != null) { //验证 MobileCode mobileCode = _mobileCodeService.GetMobileCode(RQuery["MobilePhone"], RQuery["Code"], MpUserID, 4); if (mobileCode != null) { TimeSpan ts = DateTime.Now.Subtract(mobileCode.CreateDate).Duration(); mobileCode.Status = 1; if (ts.Minutes > 10) { return(JsonMessage(false, "验证码已经失效,请重新获取")); } _mobileCodeService.Update(mobileCode); if (_posService.PosBind(pos) == 1) { if (!string.IsNullOrEmpty(pos.MobilePhones) && pos.MobilePhones.Contains(RQuery["MobilePhone"])) { return(JsonMessage(false, "您已查询过当前POS信息,您可以点击我的POS查看详细!")); } else { _posService.ExcuteSql("update Pos set MobilePhones=isnull(MobilePhones,'')+'," + RQuery["MobilePhone"] + "',MpUserIds=isnull(MpUserIds,'')+'," + MpUserID.ToString() + "' where Id='" + pos.Id.ToString() + "'"); return(JsonMessage(true, pos.Id.ToString())); } } else { return(JsonMessage(false, "-1")); } } else { lastCode.Time += 1; _mobileCodeService.Update(lastCode); return(JsonMessage(false, "对不起,验证码有误,请检查!")); } } else { return(JsonMessage(false, "对不起,您还未点击发送验证码!")); } } else { return(JsonMessage(false, "对不起,您今天最多只能发起5次验证码")); } }
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)); } }