/// <summary> /// 绑定手机号 /// </summary> /// <param name="openid"></param> /// <param name="mobile"></param> /// <returns></returns> public JsonResult GetRandom(string openid, string mobile) { bool success = true; string msg = ""; var bus = new Bus(this.DataSource); string code = Bus.RandomCode(4, false); var obilecode = new Tb_Wx_Mobilecode(this.DataSource); var oobilecode = obilecode.FindFirst <Tb_Wx_Mobilecode>(string.Format("fld_mobile='{0}' order by fld_operate_time desc", mobile)); if (oobilecode != null && oobilecode.FldOperateTime.AddMinutes(1).CompareTo(DateTime.Now) > 0) { msg = "一分钟内不得重复发送!"; } else { obilecode.Id = obilecode.Create(); obilecode.FldCode = code; obilecode.FldOperateTime = DateTime.Now; obilecode.FldExpiredTime = obilecode.FldOperateTime.AddMinutes(15); obilecode.FldMobile = mobile; obilecode.Store(); //api发短信 string returncode = bus.sendCode_miao(code, mobile); bus.saveSendCodelog(openid, mobile, code, returncode, 2); //if (!returncode.iEqualsArr("0"))//if (!returncode.iEqualsArr("ok,0,59,640,isv.business_limit")) //{ // returncode = bus.sendCodebyqq(code, mobile); // bus.saveSendCodelog(openid, mobile, code, returncode, 1); //} } return(Json(new { success = success, msg = msg }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 绑定手机号 /// </summary> /// <param name="openid"></param> /// <param name="mobile"></param> /// <param name="code"></param> /// <returns></returns> public JsonResult BindMobile(string openid, string mobile, string code, string nickname, string city) { bool result = false, needCheck = (ConfigurationManager.AppSettings["RNameNeedCheck"] == "1")?true:false; string msg = string.Empty; var bus = new Bus(this.DataSource); var user = bus.GetEntrustinfo(openid, WxPayConfig.APPID(city), WxPayConfig.getMCHID(city)); var wxuser = bus.GetUserInfo(openid, WxPayConfig.APPID(city)); var isSign = bus.isSign(openid, WxPayConfig.APPID(city), city); exterData exdata = null; var dc = new Tb_Wx_Mobilecode(this.DataSource); var obilecode = dc.FindFirst <Tb_Wx_Mobilecode>(string.Format("lower(FLD_Code)='{0}' and fld_mobile='{1}' and USED=0 order by id desc", code.ToLower(), mobile)); if (obilecode != null) { obilecode.Used = 1; obilecode.DataDriver = this.DataSource; obilecode.Store(); if (obilecode.FldExpiredTime.CompareTo(DateTime.Now) < 0) { result = false; msg = "验证码过期!"; } else { exdata = bus.Sign(openid, nickname, Request.UserHostAddress, city); user.DataDriver = this.DataSource; user.FldMobile = mobile; user.Store(); wxuser.DataDriver = this.DataSource; wxuser.Mobile = mobile; wxuser.Store(); result = true; } } else { msg = "无效验证码!"; } if (!string.IsNullOrEmpty(wxuser.Mobile) && needCheck == false) { needCheck = (wxuser.Mobile.iEqualsArr(ConfigurationManager.AppSettings["RNameCheckPhones"])) ? true : false; } return(Json(new { result = result, msg = msg, exdata = exdata, isSign = isSign, needCheck = needCheck, RNameChecked = wxuser.RNameChecked }, JsonRequestBehavior.AllowGet)); }