/// <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));
        }
        public JsonResult EncryptedBindPhone(string code, string iv, string data, string nickname, string city)
        {
            var bus = new Bus(this.DataSource);
            var pay = new JsApiPay(this.Request);

            pay.GetOpenidAndSession(code, city);
            Phone     phone  = new Phone();
            bool      state  = false;
            exterData exdata = null;
            var       wxuser = bus.GetUserInfo(pay.openid, WxPayConfig.APPID(city));
            var       isSign = bus.isSign(pay.openid, WxPayConfig.APPID(city), city);

            if (!string.IsNullOrEmpty(pay.session_key))
            {
                string result = bus.AESDecrypt(iv, pay.session_key, data);
                phone             = Bus.JsonDeserialize <Phone>(result);
                state             = true;
                wxuser.Mobile     = phone.phoneNumber;
                wxuser.DataDriver = this.DataSource;
                wxuser.Store();
                exdata = bus.Sign(pay.openid, nickname, Request.UserHostAddress, city);
            }
            return(Json(new { exdata = exdata, isSign = isSign, state = state, phone = phone }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public exterData Sign(string openid, string nickname, string UserHostAddress, string city)
        {
            city = (city == null) ? "" : city;
            var Entrustinfo = this.GetEntrustinfo(openid, WxPayConfig.APPID(city), WxPayConfig.getMCHID(city));
            var wxuser      = this.GetUserInfo(openid, WxPayConfig.APPID(city));
            var wxpay       = new WxPayApi();
            var exdata      = new exterData();

            exdata.appid  = WxPayConfig.APPID(city);
            exdata.mch_id = WxPayConfig.getMCHID(city);

            exdata.contract_code  = WxPayConfig.getCityCode(city) + Convert.ToString(long.Parse("10000") + Entrustinfo.Id) + DateTime.Now.ToString("ssfff");
            exdata.request_serial = Entrustinfo.Id.ToString();
            string display_account = string.Empty;

            if (!string.IsNullOrEmpty(wxuser.Mobile) && wxuser.Mobile.Length == 11)
            {
                display_account = wxuser.Mobile.Substring(0, 3) + "****" + wxuser.Mobile.Substring(7, 4);
            }
            else
            {
                display_account = nickname;
            }
            exdata.contract_display_account = display_account;
            switch (city)
            {
            case "福州市":
                exdata.notify_url = "https://www.cmeeol.com/wechat/FZReceiveSign";
                break;

            case "杭州市":
                exdata.notify_url = "https://wx.hzgolong.com/wechat/HZReceiveSign";
                break;

            case "杭州市2":
                exdata.notify_url = "https://wx.hzgolong.com/wechat/wccReceiveSign";
                break;

            default:
                exdata.notify_url = "https://wx.hzgolong.com/wechat/ReceiveSign";
                break;
            }
            //exdata.notify_url = HttpUtility.UrlEncode(exdata.notify_url);
            exdata.plan_id   = WxPayConfig.getPlanID(city);
            exdata.openid    = openid;
            exdata.timestamp = WxPayApi.GenerateTimeStamp();
            exdata.clientip  = UserHostAddress;
            exdata.deviceid  = "";
            exdata.mobile    = "";
            exdata.email     = "";
            exdata.qq        = "";
            exdata.creid     = "";
            exdata.outerid   = "";
            WxPayData inputObj = new WxPayData(city);

            inputObj.SetValue("appid", WxPayConfig.APPID(city));
            inputObj.SetValue("contract_code", exdata.contract_code);
            inputObj.SetValue("contract_display_account", exdata.contract_display_account);
            inputObj.SetValue("mch_id", exdata.mch_id);
            inputObj.SetValue("notify_url", exdata.notify_url);
            inputObj.SetValue("plan_id", exdata.plan_id);
            inputObj.SetValue("request_serial", exdata.request_serial);
            inputObj.SetValue("timestamp", exdata.timestamp);
            inputObj.SetValue("clientip", exdata.clientip);
            inputObj.SetValue("deviceid", "");
            inputObj.SetValue("mobile", "");
            inputObj.SetValue("email", "");
            inputObj.SetValue("qq", "");
            inputObj.SetValue("openid", openid);
            inputObj.SetValue("creid", "");
            inputObj.SetValue("outerid", "");
            if (wxuser.Mobile == "13588861726")
            {
                Log.Write("luo sign inputObj json:", inputObj.ToJson());
            }
            exdata.sign = inputObj.MakeSign();
            return(exdata);
        }