Ejemplo n.º 1
0
        //获取中止转让验证码
        public void GetStopTranCode()
        {
            Guid              userid  = WebUserAuth.UserId.Value;
            UserBLL           userbll = new UserBLL();
            UserBasicInfoInfo model   = userbll.GetUserBasicInfoModelById(userid);

            if (model == null)
            {
                PrintJson("-1", "用户不存在");
            }

            //string random = StringUtilily.GetRandomString(6);
            string telNo = model.TelNo;
            string strIP = Tool.WebFormHandler.GetIP();

            //TuanDB.CodeRecord codeRecord = new TuanDB.CodeRecord();
            //codeRecord.Id = Guid.NewGuid();
            //codeRecord.UserId = userid;
            //codeRecord.Code = random;
            //codeRecord.AddDate = DateTime.Now;
            //codeRecord.Status = 0;
            //codeRecord.Type = 2;
            //codeRecord.Type2 = 20;
            //codeRecord.token = token;
            //codeRecord.TypeValue = telNo;
            //db.CodeRecord.AddObject(codeRecord);
            //if (db.SaveChanges() > 0)
            var canSend = new CodeRecordBLL().IsCanSendNewCodeRecord(telNo, MsCodeType.PhoneCode, MsCodeType2.PCStopTransferCode, null, 1, strIP);

            if (!canSend.Success)
            {
                PrintJson("-1", canSend.Message);
            }
            var code = new CodeRecordBLL().CreateCodeRecordInfo(userid, "", MsCodeType.PhoneCode, MsCodeType2.PCStopTransferCode, telNo);

            if (code != null)
            {
                var parameters = new Dictionary <string, object>();
                parameters.Add("ValidateCode", code.Code);
                var msgSender  = new BusinessDll.MessageSend();
                var sendResult = msgSender.SendMessage2(option: SendOption.Sms,
                                                        eventCode: MessageTemplates.ValidateCode, parameters: parameters, mobile: telNo, content: code.Code);
                if (sendResult != "1")
                {
                    PrintJson("-1", "短信发送失败");
                }
                else
                {
                    PrintJson("1", "");
                }
            }
            else
            {
                PrintJson("-1", "短信发送失败");
            }
        }
Ejemplo n.º 2
0
        public void SendCode()
        {
            string mobilePhone = Context.Request.Form["mobilePhone"];

            if (!mobilePhone.IsPhone())
            {
                Response.Write("{\"result\":\"-2\",\"msg\":\"手机号格式不对\"}");
                Response.End();
            }
            var model = new UserBLL().GetUserBasicInfoModelByTelNo(mobilePhone);

            if (model == null)
            {
                Response.Write("{\"result\":\"-1\",\"msg\":\"手机号未在团贷网注册\"}");
                Response.End();
            }
            string err   = "";
            var    ulist = RedisServerStack.StringGet <List <account_manager.WeiXinUser> >(TdConfig.ApplicationName, "/redis/web",
                                                                                           GlobalUtils.OpenId, ref err);

            if (ulist != null && ulist.Exists(o => o.UserId == model.Id))
            {
                Response.Write("{\"result\":\"-3\",\"msg\":\"账号已在微信绑定列表中\"}");
                Response.End();
            }
            var result = new CodeRecordBLL().IsCanSendNewCodeRecord(mobilePhone, MsCodeType.PhoneCode, MsCodeType2.BindWeiXinOpenId, model.Id);

            if (!result.Success)
            {
                Response.Write("{\"result\":\"" + result.Code.ToString() + "\",\"msg\":\"" + result.Message + "\"}");
                Response.End();
            }
            var code = new CodeRecordBLL().CreateCodeRecordInfo(model.Id, "", MsCodeType.PhoneCode, MsCodeType2.BindWeiXinOpenId, mobilePhone);

            if (code != null)
            {
                var parameters = new Dictionary <string, object>();
                parameters.Add("ValidateCode", code.Code);
                var msgSender = new BusinessDll.MessageSend();
                msgSender.SendMessage2(option: SendOption.Sms, eventCode: MessageTemplates.ValidateCode, parameters: parameters, mobile: mobilePhone);
                Response.Write("{\"result\":\"1\",\"msg\":\"已发送,3分钟后可重新获取。\"}");
                Response.End();
            }
            else
            {
                Response.Write("{\"result\":\"0\",\"msg\":\"验证码发送失败,请重试。\"}");
                Response.End();
            }
        }
Ejemplo n.º 3
0
        public void Bind()
        {
            string type   = Context.Request.Form["type"];
            int    result = 1;
            Guid   userid = WebUserAuth.UserId.Value;

            if (string.IsNullOrEmpty(type))
            {
                string code        = Context.Request.Form["code"];
                string mobilePhone = Context.Request.Form["mobilePhone"];
                if (!mobilePhone.IsPhone())
                {
                    Response.Write("{\"result\":\"-2\",\"msg\":\"手机号格式不对\"}");
                    Response.End();
                }
                CookieHelper.WriteCookie("shellben4tel", Tool.Common.Utils.StringHandler.MaskTelNo(mobilePhone));
                var model = new UserBLL().GetUserBasicInfoModelByTelNo(mobilePhone);
                if (model == null)
                {
                    Response.Write("{\"result\":\"-1\",\"msg\":\"手机号未在团贷网注册\"}");
                    Response.End();
                }
                result = new CodeRecordBLL().CheckCodeRecord(code, mobilePhone, MsCodeType.PhoneCode,
                                                             MsCodeType2.BindWeiXinOpenId, model.Id, true);
                userid = model.Id;
            }

            if (result == 1)
            {
                var    posturl = GlobalUtils.MsgApiUrl;
                string err     = "";
                string openId  = GlobalUtils.OpenId;
                if (string.IsNullOrEmpty(openId))
                {
                    Response.Write("{\"result\":\"-4\",\"msg\":\"获取不到微信OpenId\"}");
                    Response.End();
                }
                //openId = "oUYJbuHDRnoxUw0UbTQUTO_nkUtQ";
                string resp = "";
                try
                {
                    var descStr =
                        TuanDai.WXSystem.Core.Common.MsgDesc.GetDescStr("{\"Data\":{\"WeiXinOpenId\":\"" + openId +
                                                                        "\",\"UserId\":\"" + userid + "\"}}");
                    resp = HttpClient.HttpUtil.HttpPostJson(TdConfig.ApplicationName,
                                                            posturl + "/6/UpdateMsgSetInfoWeixinOpenId", descStr,
                                                            out err, null, 3);
                }
                catch (Exception ex)
                {
                    TuanDai.LogSystem.LogClient.LogClients.ErrorLog(TdConfig.ApplicationName, "用户团贷网账户绑定微信", userid.ToString(), ex.Message);
                }

                if (!string.IsNullOrEmpty(resp))
                {
                    var returnmsg =
                        JsonConvert.DeserializeObject <TuanDai.WXSystem.Core.Common.MsgApiResponseMessage <bool> >(
                            resp);
                    if (returnmsg != null && returnmsg.Data)
                    {
                        TuandaiCommnetTool.BaseCommon.TaskAsyncHelper.RunAsync(() =>
                        {
                            if (getCount(userid) <= 0 && InsertRecord(userid, openId) > 0) //插入成功说明是首次绑定
                            {
                                SendTuanBi(userid);
                            }
                            else
                            {
                                UpdateRecord(userid, openId);
                            }
                        });
                        Response.Write("{\"result\":\"1\",\"msg\":\"绑定成功\"}");
                        Response.End();
                    }
                }
                Response.Write("{\"result\":\"0\",\"msg\":\"绑定失败\"}");
                Response.End();
            }
            else
            {
                Response.Write("{\"result\":\"-3\",\"msg\":\"验证码错误\"}");
                Response.End();
            }
        }
Ejemplo n.º 4
0
        public void GetZhphApplySMSCode()
        {
            Guid userid = WebUserAuth.UserId.Value;
            //UserBasicInfo model = db.UserBasicInfo.FirstOrDefault(p => p.Id == userid);
            var model = new UserBLL().GetUserBasicInfoModelById(userid);

            if (model == null)
            {
                PrintJson("-1", "用户不存在");
            }
            string mobileNo = WEBRequest.GetFormString("mobileno");

            if (mobileNo.ToText().IsEmpty())
            {
                PrintJson("-1", "未输入手机号");
            }

            //string random = StringUtilily.GetRandomString(6);
            string telNo = mobileNo;
            string token = Tool.Encryption.MD5(userid.ToString());

            //CodeRecord codeRecord = new CodeRecord();
            //codeRecord.Id = Guid.NewGuid();
            //codeRecord.UserId = userid;
            //codeRecord.Code = random;
            //codeRecord.AddDate = DateTime.Now;
            //codeRecord.Status = 0;
            //codeRecord.Type = MsCodeType.PhoneCode;
            //codeRecord.Type2 = MsCodeType2.ZhphFastLoanCode;
            //codeRecord.token = token;
            //codeRecord.TypeValue = telNo;
            //db.CodeRecord.AddObject(codeRecord);
            var canSend = new CodeRecordBLL().IsCanSendNewCodeRecord(telNo, MsCodeType.PhoneCode, MsCodeType2.ZhphFastLoanCode,
                                                                     null, 1, token);

            if (!canSend.Success)
            {
                PrintJson("-1", "一天之内最多发送5次!");
            }
            var code = new CodeRecordBLL().CreateCodeRecordInfo(userid, Tool.WebFormHandler.GetIP(),
                                                                MsCodeType.PhoneCode, MsCodeType2.ZhphFastLoanCode, telNo);

            //if (db.SaveChanges() > 0)
            if (code != null)
            {
                var parameters = new Dictionary <string, object>();
                parameters.Add("ValidateCode", code.Code);
                var msgSender  = new BusinessDll.MessageSend();
                var sendResult = msgSender.SendMessage2(option: SendOption.Sms,
                                                        eventCode: MessageTemplates.ValidateCode, parameters: parameters, mobile: telNo, content: code.Code);
                if (sendResult != "1")
                {
                    PrintJson("-1", "短信发送失败");
                }
                else
                {
                    PrintJson("1", "");
                }
            }
            else
            {
                PrintJson("-1", "短信发送失败");
            }
        }