Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CustID    = Request["CustID"];
        SPID      = Request["SPID"];
        ReturnUrl = Request["ReturnUrl"];

        this.hdCustID.Value    = CustID;
        this.hdSPID.Value      = SPID;
        this.hdReturnUrl.Value = ReturnUrl;

        if (String.IsNullOrEmpty(CustID))
        {
            CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "您尚未登录,请登录", this.Context);
            return;
        }

        BesttoneAccount _besttoneAccount_entity = _besttoneAccount_dao.QueryByCustID(CustID);

        if (_besttoneAccount_entity == null)
        {
            HttpContext.Current.Response.Redirect("AccountNotBind.aspx");
            return;
        }
        else
        {
            _bestPayAccount = _besttoneAccount_entity.BestPayAccount;
        }

        this.OnceRechargeLimited   = BesttoneAccountHelper.ConvertAmountToYuan(BesttoneAccountConstDefinition.DefaultInstance.AccountRechargeLimitedOne);
        this.DayRechargeLimited    = BesttoneAccountHelper.ConvertAmountToYuan(BesttoneAccountConstDefinition.DefaultInstance.AccountRechargeLimitedDay);
        this.AccountBalanceLimited = BesttoneAccountHelper.ConvertAmountToYuan(BesttoneAccountConstDefinition.DefaultInstance.AccountBalanceLimited);
    }
Exemplo n.º 2
0
    protected void btn_OK_Click(object sender, EventArgs e)
    {
        if (CommonBizRules.IsUrlParams(HttpContext.Current.Request.Url.OriginalString))
        {
            SPID      = HttpUtility.HtmlDecode(Request.QueryString["SPID"].ToString());
            ReturnUrl = HttpUtility.HtmlDecode(Request.QueryString["ReturnUrl"].ToString());
        }

        if (!CommonUtility.ValidateValidateCode(HttpUtility.HtmlDecode(Request.Form["code"].ToString().Trim().ToUpper()), this.Context))
        {
            err_code.InnerHtml = "验证码错误,请重新输入";
            return;
        }
        OldPwd    = Request.Form["oldPasswd"].ToString().Trim();
        VerifyPwd = Request.Form["verifyPasswd"].ToString().Trim();
        if (!PassWordBO.OldPwdIsRight(CustID, OldPwd, "2", out ErrMsg))
        {
            //CommonBizRules.ErrorHappenedRedircet(-1, ErrMsg, "修改登录密码", this.Context);
            error.InnerHtml = "原始密码错误";
            return;
        }
        else
        {
            string ErrMsgSetPwd = "";
            int    Result       = PassWordBO.SetPassword(SPID, CustID, VerifyPwd, "2", "", out ErrMsgSetPwd);
            if (Result != 0)
            {
                CommonBizRules.ErrorHappenedRedircet(Result, ErrMsgSetPwd, "修改登录密码", this.Context);
            }
            CommonBizRules.SuccessRedirect(ReturnUrl, "修改登录成功", this.Context);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 解析请求参数
    /// </summary>
    protected void ParseSPTokenRequest()
    {
        try
        {
            if (HttpContext.Current.Request["SPTokenRequest"] != null)
            {
                String SPTokenRequest = HttpContext.Current.Request["SPTokenRequest"];

                String ErrMsg     = String.Empty;
                String tempCustID = String.Empty;
                Int32  Result     = SSOClass.ParseBesttoneAccountPageRequest(SPTokenRequest, this.Context, out _spid, out tempCustID, out _isNeedHeadFoot, out _returnUrl, out ErrMsg);
                if (Result != 0)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "请求参数有误", this.Context);
                    return;
                }
                if (tempCustID != base.CustID)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "登录信息有误,请重新登录", this.Context);
                    return;
                }
            }
        }
        catch { }
    }
Exemplo n.º 4
0
 /// <summary>
 /// 错误处理
 /// </summary>
 private void ErrorHappened()
 {
     //如果允许跳转则跳转,否则不处理
     if (isRedircet)
     {
         CommonBizRules.ErrorHappenedRedircet(result, errMsg, "您尚未登录,请登录", this.Context);
     }
 }
Exemplo n.º 5
0
    protected void register_Click(object sender, EventArgs e)
    {
        string mobile    = this.mobile.Text;
        string checkCode = this.checkCode.Text;
        string password  = this.password.Text;
        string password2 = this.password2.Text;

        //判断手机验证码
        if (checkCode != null && !"".Equals(checkCode))
        {
            Result = PhoneBO.SelSendSMSMassage("", mobile, checkCode, out ErrMsg);
            if (Result != 0)
            {
                errorHint.InnerHtml = "手机验证码错误,请重新输入";
                return;
            }
        }

        Result = UserRegistry.quickUserRegistryWeb(SPID, password, mobile, "2", out CustID, out ErrMsg);
        if (Result != 0)
        {
            CommonBizRules.ErrorHappenedRedircet(Result, ErrMsg, "用户注册", this.Context);
            return;
        }

        SPInfoManager spInfo = new SPInfoManager();
        Object        SPData = spInfo.GetSPData(this.Context, "SPData");
        string        key    = spInfo.GetPropertyBySPID(SPID, "SecretKey", SPData);

        string Digest = CryptographyUtil.GenerateAuthenticator(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg, key);
        string temp   = SPID + "$" + CryptographyUtil.Encrypt(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg + "$" + Digest, key);
        string RegistryResponseValue = HttpUtility.UrlEncode(temp);

        log(String.Format("key:{0},Digest:{1},temp:{2},RegistryResponseValue:{3}", key, Digest, temp, RegistryResponseValue));
        //给用户写cookie
        UserToken UT   = new UserToken();
        string    key2 = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);

        string RealName = mobile;
        string UserName = mobile;
        string NickName = mobile;

        //                                           CustID, RealName, UserName, NickName, OuterID, CustType, string LoginAuthenName, string LoginAuthenType,string key, out string ErrMsg
        string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, "", "42", UserName, "1", key2, out ErrMsg);
        string CookieName     = System.Configuration.ConfigurationManager.AppSettings["CookieName"];

        PageUtility.SetCookie(UserTokenValue, CookieName, this.Page);

        //通知积分平台
        CIP2BizRules.InsertCustInfoNotify(CustID, "2", SPID, "", "0", out ErrMsg);
        //记登录日志
        CommonBizRules.WriteDataCustAuthenLog(SPID, CustID, "35", "0", "", "2", Result, ErrMsg);

        Response.Redirect(ReturnUrl + "?RegistryResponse=" + RegistryResponseValue, true);
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder strLog = new StringBuilder();

        try
        {
            strLog.Append("1.开始解析SPTokenRequest\r\n");
            ParseSPTokenRequest();
            strLog.Append("2.解析SPTokenRequest结束\r\n");
            strLog.Append("3.校验全局Token\r\n");
            this.TokenValidate.IsRedircet = false;
            this.TokenValidate.Validate();
            strLog.Append("4.校验全局Token结束\r\n");
            //log("TokenValidate:" + TokenValidate.Result+"\r\n");
            if (TokenValidate.Result == 0)
            {
                strLog.Append("全局token存在\r\n");
                this.ssoFunc();
            }
            else
            {
                strLog.Append("全局token不存在\r\n");

                string Ticket = "179000179000";
                string Url    = "";

                if (ReturnURL.IndexOf("?") > 0)
                {
                    strLog.Append("ReturnUrl包含问号\r\n");
                    Url = ReturnURL + "&Ticket=" + Ticket;
                }
                else
                {
                    strLog.Append("ReturnUrl不包含问号\r\n");
                    Url = ReturnURL + "?Ticket=" + Ticket;
                }
                strLog.Append("重定向\r\n");
                Response.Redirect(Url, false);
            }
        }
        catch (System.Exception ex)
        {
            strLog.Append(ex.ToString());
            CommonBizRules.ErrorHappenedRedircet(Result, ErrMsg + "异常信息:" + ex.ToString(), "您尚未登录,请登录", this.Context);
        }
        finally
        {
            log(strLog.ToString());
        }
    }
Exemplo n.º 7
0
    public BasePage()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
        String     RealName, NickName, OuterID, CustType, LoginAuthenName, LoginAuthenType;
        HttpCookie cookie = HttpContext.Current.Request.Cookies[CookieName];

        if (cookie == null)
        {
            CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "您尚未登录,请登录", this.Context);
            return;
        }
        string strCIPToken = HttpContext.Current.Request.Cookies.Get(CookieName).Value;

        if (CommonUtility.IsEmpty(strCIPToken))
        {
            CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "您尚未登录,请登录", this.Context);
            return;
        }

        SPInfoManager spInfo = new SPInfoManager();
        Object        SPData = spInfo.GetSPData(HttpContext.Current, "SPData");
        string        key    = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);
        UserToken     UT     = new UserToken();

        result = UT.ParseUserToken(strCIPToken, key, out custID, out RealName, out userName, out NickName, out OuterID, out CustType, out LoginAuthenName, out LoginAuthenType, out ErrMsg);
        //如果验证成功则重新生成Cookie以更新超时时间
        if (result == 0)
        {
            string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, OuterID, CustType, LoginAuthenName, LoginAuthenType, key, out ErrMsg);

            PageUtility.SetCookie(CookieName, UserTokenValue);
        }
        //this.custID = "117663768";//117663768,26251932
    }
Exemplo n.º 8
0
    protected void register_Click(object sender, EventArgs e)
    {
        Response.AddHeader("P3P", "CP=CAO PSA OUR");

        SPID      = Request["SPID"] == null ? ConstHelper.DefaultInstance.BesttoneSPID : HttpUtility.HtmlDecode(Request["SPID"]);
        ReturnUrl = Request["ReturnUrl"] == null ? ConstHelper.DefaultInstance.BesttoneLoginPage : HttpUtility.HtmlDecode(Request["ReturnUrl"]);

        log(String.Format("【Web注册】:SPID:{0},ReturnUrl:{1}", SPID, ReturnUrl));
        string password  = Request.Form["password"].ToString().Trim();
        string telephone = Request.Form["mobile"].ToString().Trim();
        string phonecode = Request.Form["checkCode"].ToString().Trim();

        log(String.Format("mobile:{0},password:{1},phonecode:{2}", telephone, password, phonecode));
        string ErrMsg = "";
        int    Result;


        if (CommonUtility.IsEmpty(password))
        {
            hintPassword.InnerHtml = "密码不能为空格"; // 这里如何控制样式
            return;
        }

        if (ViewState["phonestate"] == null)
        {
            ViewState["phonestate"] = Request.Form["phonestate"].ToString();
            string a = (string)ViewState["phonestate"];
        }

        if (((string)ViewState["phonestate"]).Equals("0"))
        {
            //判断手机验证码
            Result = PhoneBO.SelSendSMSMassage("", telephone, phonecode, out ErrMsg);
            if (Result != 0)
            {
                hintCode.InnerHtml = "手机验证码错误,请重新输入";  // 这里如何控制样式
                return;
            }
        }

        TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        Result    = UserRegistry.quickUserRegistryWeb(SPID, password, telephone, (string)ViewState["phonestate"], out CustID, out ErrMsg);
        if (Result != 0)
        {
            CommonBizRules.ErrorHappenedRedircet(Result, ErrMsg, "用户注册", this.Context);
            return;
        }

        SPInfoManager spInfo = new SPInfoManager();
        Object        SPData = spInfo.GetSPData(this.Context, "SPData");
        string        key    = spInfo.GetPropertyBySPID(SPID, "SecretKey", SPData);
        string        Digest = CryptographyUtil.GenerateAuthenticator(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg, key);
        string        temp   = SPID + "$" + CryptographyUtil.Encrypt(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg + "$" + Digest, key);
        string        RegistryResponseValue = HttpUtility.UrlEncode(temp);

        log(String.Format("key:{0},Digest:{1},temp:{2},RegistryResponseValue:{3}", key, Digest, temp, RegistryResponseValue));
        //给用户写cookie
        UserToken UT   = new UserToken();
        string    key2 = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);

        string RealName = telephone;
        string UserName = telephone;
        string NickName = telephone;

        //                                           CustID, RealName, UserName, NickName, OuterID, CustType, string LoginAuthenName, string LoginAuthenType,string key, out string ErrMsg
        string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, "", "42", UserName, "1", key2, out ErrMsg);
        string CookieName     = System.Configuration.ConfigurationManager.AppSettings["CookieName"];

        PageUtility.SetCookie(UserTokenValue, CookieName, this.Page);

        //通知积分平台
        CIP2BizRules.InsertCustInfoNotify(CustID, "2", SPID, "", "0", out ErrMsg);
        //记登录日志
        CommonBizRules.WriteDataCustAuthenLog(SPID, CustID, "35", "0", "", "2", Result, ErrMsg);

        log(String.Format("【返回之前】:SPID:{0},ReturnUrl:{1}", SPID, ReturnUrl));


        string hid_openAccount = Request.Form["hid_openAccount"].ToString().Trim();

        log(String.Format("开户选项:{0}", hid_openAccount));



        if (ReturnUrl.IndexOf("?") > 0)
        {
            if ("1".Equals(hid_openAccount))
            {
                // 这里要 跳回 调用方,并告知 CreateBesttoneAccount.aspx,让其重定向到该地址
                //Response.Write(" <A   id= 'kh '   href= 'CreateBesttoneAccount.aspx?mobile=" + telephone + "&ReturnUrl=" + ReturnUrl + "'   target= '_top '> </A> <script language='javascript' type='text/javascript'> document.getElementById('kh').click(); </script> ");
                //return;
                //Response.Redirect("CreateBesttoneAccount.aspx?mobile=" + telephone + "&ReturnUrl=" + ReturnUrl);
                Response.Redirect(ReturnUrl + "&RegistryResponse=" + RegistryResponseValue + "&registBesttoneAccount=true", true);
            }
            else
            {
                Response.Redirect(ReturnUrl + "&RegistryResponse=" + RegistryResponseValue, true);
            }


            //Response.Redirect(ReturnUrl  + "&RegistryResponse=" + RegistryResponseValue, true);
            //CommonBizRules.SuccessRedirect(ReturnUrl + "&RegistryResponse=" + RegistryResponseValue, "成功注册", this.Context);
        }
        else
        {
            if ("1".Equals(hid_openAccount))
            {
                // 这里要 跳回 调用方,并告知 CreateBesttoneAccount.aspx,让其重定向到该地址
                //Response.Write(" <A   id= 'kh '   href= 'CreateBesttoneAccount.aspx?mobile=" + telephone + "&ReturnUrl=" + ReturnUrl + "'   target= '_top '> </A> <script language='javascript' type='text/javascript'> document.getElementById('kh').click(); </script> ");
                //return;
                //Response.Redirect("CreateBesttoneAccount.aspx?mobile=" + telephone + "&ReturnUrl=" + ReturnUrl);
                Response.Redirect(ReturnUrl + "?RegistryResponse=" + RegistryResponseValue + "&registBesttoneAccount=true", true);
            }
            else
            {
                Response.Redirect(ReturnUrl + "?RegistryResponse=" + RegistryResponseValue, true);
            }

            //CommonBizRules.SuccessRedirect(ReturnUrl + "?RegistryResponse=" + RegistryResponseValue, "成功注册", this.Context);
        }
    }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                String custid         = Request["hiddenCustID"];
                String spid           = Request["hiddenSPID"];
                String InvoiceType    = Request["InvoiceType"];
                String InvoiceTitle   = Request["InvoiceTitle"];
                String InvoiceContent = Request["InvoiceContent"];
                String ContactPerson  = Request["ContactPerson"];
                String ContactPhone   = Request["ContactPhone"];
                String Address        = Request["Address"];
                String Zip            = Request["Zip"];
                String Mem            = Request["Mem"];
                String NeedInvoice    = Request["NeedInvoice"];


                long     balance = Convert.ToInt64(Convert.ToDouble(Request["TranAmount"]) * 100);
                DateTime reqTime = DateTime.Now;

                //查询账户信息
                BesttoneAccountDAO _besttoneAccount_dao = new BesttoneAccountDAO();
                BesttoneAccount    account_entity       = _besttoneAccount_dao.QueryByCustID(custid);
                if (account_entity == null)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "账户信息异常", this.Context);
                    return;
                }

                #region 账户充值金额上限校验

                long OnceRechargeLimit   = BesttoneAccountConstDefinition.DefaultInstance.AccountRechargeLimitedOne;            //单笔充值金额上限
                long RechargeAmountLimit = BesttoneAccountConstDefinition.DefaultInstance.AccountRechargeLimitedDay;            //账户单日充值额度上限
                long CurrentAmountLimit  = BesttoneAccountConstDefinition.DefaultInstance.AccountBalanceLimited;                //账户余额上限
                if (OnceRechargeLimit > 0)
                {
                    //检测用户单笔充值金额是否超限(10000元)
                    if (balance > OnceRechargeLimit)
                    {
                        result = 100003;
                        ErrMsg = String.Format("单笔充值金额最多不能超过{0}元", BesttoneAccountHelper.ConvertAmountToYuan(OnceRechargeLimit));
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "充值金额超过上限", this.Context);
                        return;
                    }
                }
                if (RechargeAmountLimit > 0)
                {
                    //检测用户当日充值是否超限(当日充值金额不能超过50000元)
                    long hadRechargeAmount = _rechargeOrder_dao.QueryCurrentRechargeAmount(account_entity.BestPayAccount);
                    if ((hadRechargeAmount + balance) > RechargeAmountLimit)
                    {
                        result = 100001;
                        ErrMsg = String.Format("您今日累计充值金额:{0}元,本次充值将超过您的当日累计充值限额:{1}元,请改日再进行充值操作!",
                                               BesttoneAccountHelper.ConvertAmountToYuan(hadRechargeAmount), BesttoneAccountHelper.ConvertAmountToYuan(RechargeAmountLimit));
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "充值金额超过上限", this.Context);
                        return;
                    }
                }

                if (CurrentAmountLimit > 0)
                {
                    long accountBalance = 0;
                    //检测用户帐户余额(个人账户余额不能超过100000元)
                    result = BesttoneAccountHelper.QueryAccountBalance(account_entity.BestPayAccount, out accountBalance, out ErrMsg);
                    if (result != 0)
                    {
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "账户信息异常", this.Context);
                        return;
                    }

                    if ((accountBalance + balance) > CurrentAmountLimit)
                    {
                        result = 100002;
                        ErrMsg = String.Format("您的账户余额为:{0}元,本次充值将超过您的账户余额上限:{1}元,请消费后再进行充值操作!",
                                               BesttoneAccountHelper.ConvertAmountToYuan(accountBalance), BesttoneAccountHelper.ConvertAmountToYuan(CurrentAmountLimit));
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "充值金额超过上限", this.Context);
                        return;
                    }
                }

                #endregion

                bool Result = false;

                #region 生成订单信息

                /***************************************************************************/
                String orderSeq      = BesttoneAccountHelper.CreateOrderSeq();              //订单号
                String transactionID = BesttoneAccountHelper.CreateTransactionID();         //流水号
                // 在发起网银扣款请求,主表状态为1,扣款子表状态为0
                //初始化充值订单
                //2013-04-13 add -start
                if (String.IsNullOrEmpty(NeedInvoice))
                {
                    NeedInvoice = "0";
                }
                //2013-04-13 add -end
                RechargeOrder _recharge_order = new RechargeOrder(orderSeq, transactionID, reqTime.ToString("yyyyMMdd"), "RMB",
                                                                  balance, balance, 0, "网银充值", custid, account_entity.BestPayAccount, "0", spid, reqTime, new DateTime(1900, 1, 1),
                                                                  new DateTime(1900, 1, 1), 1, 0, "", "", "", NeedInvoice); //2013-04-13 add NeedInvoice 字段

                //初始化网银扣款流水记录
                BankRechargeRecord _bankRecharge_record = new BankRechargeRecord(orderSeq, transactionID, reqTime.ToString("yyyyMMdd"), "RMB",
                                                                                 balance, balance, 0, "网银充值", account_entity.BestPayAccount, 0, reqTime, new DateTime(1900, 1, 1), "", "", "", "", "");

                Result = _rechargeOrder_dao.Insert(_recharge_order);
                if (!Result)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败1", this.Context);
                    return;
                }

                //如果需要开发票 -- 插入发票表  2013-04-14 add-start
                if ("1".Equals(NeedInvoice))
                {
                    System.Text.StringBuilder datalog = new System.Text.StringBuilder();
                    //Result = _rechargeOrder_dao.InsertInvoice(orderSeq, InvoiceType, "", InvoiceTitle, ContactPerson, ContactPhone, Address, Zip, Mem, out datalog);
                    if ("0".Equals("InvoiceType"))
                    {
                        InvoiceTitle = "个人";
                    }
                    if (String.IsNullOrEmpty(InvoiceTitle))
                    {
                        InvoiceTitle = "个人";
                    }
                    if (String.IsNullOrEmpty(InvoiceContent))
                    {
                        InvoiceContent = "日用品";
                    }
                    Result = _rechargeOrder_dao.InsertInvoice(orderSeq, InvoiceType, InvoiceContent, InvoiceTitle, ContactPerson, ContactPhone, Address, Zip, Mem, "9", out datalog);  // "9" 代表需要开票
                    if (!Result)
                    {
                        CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败-发票生成失败", this.Context);
                        return;
                    }
                }
                //2013-04-14 add-end

                Result = _bankRechargeRecord_dao.Insert(_bankRecharge_record);
                if (!Result)
                {
                    CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败2", this.Context);
                    return;
                }
                /***************************************************************************/

                #endregion

                this._ORDERSEQ        = orderSeq;
                this._ORDERREQTRANSEQ = transactionID;
                this._ORDERDATE       = reqTime.ToString("yyyyMMddHHmmss");
                this._ORDERAMOUNT     = balance.ToString();
                this._PRODUCTAMOUNT   = balance.ToString();

                //MAC签名
                String mac = String.Format("MERCHANTID={0}&ORDERSEQ={1}&ORDERDATE={2}&ORDERAMOUNT={3}", this.MERCHANTID, this._ORDERSEQ, this._ORDERDATE, this._ORDERAMOUNT);
                mac = BesttoneAccountHelper.MACSign(mac);

                this._MAC = mac;
            }
            catch (Exception ex)
            {
                CommonBizRules.ErrorHappenedRedircet(result, ErrMsg, "网银充值失败", this.Context);
                return;
            }
        }
    }
Exemplo n.º 10
0
    protected void register_Click(object sender, EventArgs e)
    {
        StringBuilder strLog = new StringBuilder();

        try
        {
            logger.Info("RegisterAllInOne-注册来源:" + HttpContext.Current.Request.RawUrl);
            Response.AddHeader("P3P", "CP=CAO PSA OUR");
            strLog.AppendFormat("----------------------注册事件开始:------------------\r\n");
            strLog.AppendFormat("SPID:{0}\r\n", SPID);
            strLog.AppendFormat("ReturnUrl:{0}\r\n", ReturnUrl);
            PassWord = Request.Form["password"].ToString().Trim();
            strLog.AppendFormat("PassWord:{0}\r\n", PassWord);
            Mobile = Request.Form["mobile"].ToString().Trim();
            strLog.AppendFormat("mobile:{0}\r\n", Mobile);
            CheckPhoneCode = Request.Form["checkCode"].ToString().Trim();
            strLog.AppendFormat("checkCode:{0}\r\n", CheckPhoneCode);
            Email    = Request.Form["email"].ToString().Trim();
            UserName = Request.Form["userName"].ToString().Trim();

            strLog.AppendFormat("ViewState[phonestate]:{0}\r\n", ViewState["phonestate"]);
            strLog.AppendFormat("Request.Form[phonestate]:{0}\r\n", Request.Form["phonestate"]);
            if (ViewState["phonestate"] == null)
            {
                ViewState["phonestate"] = Request.Form["phonestate"].ToString();
                string a = (string)ViewState["phonestate"];
            }

            if (((string)ViewState["phonestate"]).Equals("0"))
            {
                strLog.AppendFormat("phonestate==0\r\n");
                //判断手机验证码
                string needCheckCode = "0";  //ConfigurationManager.AppSettings["needCheckCode"];
                strLog.AppendFormat("判断手机验证码\r\n");
                //strLog.AppendFormat("needCheckCode:{0}\r\n}", needCheckCode);
                if ("0".Equals(needCheckCode))
                {
                    //strLog.AppendFormat("needCheckCode==0");
                    Result = PhoneBO.SelSendSMSMassage("", Mobile, CheckPhoneCode, out ErrMsg);
                    if (Result != 0)
                    {
                        strLog.AppendFormat("手机验证码验证错误\r\n");
                        hintCode.InnerHtml = "手机验证码错误,请重新输入";  // 这里如何控制样式
                        return;
                    }
                    strLog.AppendFormat("手机验证码验证无误\r\n");
                }
                //strLog.AppendFormat("does not needCheckCode:{0}\r\n}", needCheckCode);
            }
            //strLog.AppendFormat("phonestate!=0 \r\n");
            strLog.AppendFormat("-----------------quickUserRegistryWeb  begin------------------\r\n");
            Result = UserRegistry.quickUserRegistryWebV3(SPID, PassWord, Mobile, (string)ViewState["phonestate"], UserName, Email, out CustID, out ErrMsg);
            if (Result != 0)
            {
                strLog.AppendFormat("注册失败!\r\n");
                CommonBizRules.ErrorHappenedRedircet(Result, ErrMsg, "用户注册", this.Context);
                return;
            }

            strLog.AppendFormat("注册成功!\r\n");
            //短信通知
            // string VoicePwdSPID = System.Configuration.ConfigurationManager.AppSettings["VoicePwd_SPID"];
            // int SIP1 = VoicePwdSPID.IndexOf(SPID);
            String SMS_Message = String.Empty;
            // if (SIP1 >= 0)
            //  {
            SMS_Message = "恭喜您成为号码百事通会员!请妥善保管您的密码;如需帮助请联系:4008-118114。";
            //通知短信网关
            //CommonBizRules.SendMessageV3(Mobile, SMS_Message, SPID);   //2013-11-19 注释掉
            //   }

            strLog.AppendFormat("检查邮箱是否需要发送\r\n");
            if (!String.IsNullOrEmpty(Email))
            {
                SendEmail(CustID, Email);
            }

            strLog.AppendFormat("写Cookie\r\n");
            String        TimeStamp             = DateTime.Now.ToString("yyyy-MM-dd HH:ta:ss");
            SPInfoManager spInfo                = new SPInfoManager();
            Object        SPData                = spInfo.GetSPData(this.Context, "SPData");
            String        key                   = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);
            String        Digest                = CryptographyUtil.GenerateAuthenticator(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg, key);
            String        temp                  = SPID + "$" + CryptographyUtil.Encrypt(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg + "$" + Digest, key);
            String        RegistryResponseValue = HttpUtility.UrlEncode(temp);

            //给用户写cookie
            UserToken UT             = new UserToken();
            String    RealName       = Mobile;
            String    NickName       = Mobile;
            string    UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, "", "42", UserName, "1", key, out ErrMsg);
            string    CookieName     = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
            PageUtility.SetCookie(UserTokenValue, CookieName, this.Page);
            //通知积分平台
            //strLog.AppendFormat("通知积分平台,CustID:{0}\r\n", CustID);

            CIP2BizRules.InsertCustInfoNotify(CustID, "2", SPID, "", "0", out ErrMsg);
            strLog.AppendFormat("写入数据库日志\r\n");
            //记登录日志
            CommonBizRules.WriteDataCustAuthenLog(SPID, CustID, "35", "0", "", "2", Result, ErrMsg);
            strLog.AppendFormat("-----------------quickUserRegistryWeb  end------------------\r\n");

            strLog.AppendFormat("是否开户\r\n");
            strLog.AppendFormat("--------------------openBestToneAccount begin------------------------\r\n");
            String hid_openAccount = Request.Form["hid_openAccount"].ToString().Trim();
            //strLog.AppendFormat("hid_openAccount:{0}\r\n", hid_openAccount);
            if ("1".Equals(hid_openAccount))
            {
                strLog.AppendFormat("hid_openAccount==1 需要开户\r\n");
                // 开户要做的事情  需要前面注册获得的custID
                string BindedBestpayAccount = "";
                string CreateTime           = "";
                strLog.AppendFormat("先查看该CustID:{0}头上是否有账户\r\n", CustID);
                int IsBesttoneAccountBindV5Result = CIP2BizRules.IsBesttoneAccountBindV5(CustID, out BindedBestpayAccount, out CreateTime, out ErrMsg);
                //strLog.AppendFormat("查看结果:IsBesttoneAccountBindV5Result:{0},BindedBestpayAccount:{1},CreateTime:{2},ErrMsg:{3}\r\n", IsBesttoneAccountBindV5Result, BindedBestpayAccount, CreateTime, ErrMsg);
                if (IsBesttoneAccountBindV5Result == 0)
                {
                    //strLog.AppendFormat("IsBesttoneAccountBindV5Result==0,该CustID:{0}头上有账户BindedBestpayAccount:{1}\r\n", CustID, BindedBestpayAccount);
                    Response.Redirect("ErrorInfo.aspx?ErrorInfo=该账户绑定关系未解除,请联系管理人员!");
                }
                strLog.AppendFormat("该CustID:{0}头上无绑定账户\r\n", CustID);
                String      TransactionID = BesttoneAccountHelper.CreateTransactionID();
                AccountItem ai            = new AccountItem();
                string      ResponseCode  = "";
                BestToneAccount = Request.Form["mobile"].ToString().Trim();
                //strLog.AppendFormat("开户账号:{0}\r\n", BestToneAccount);
                realName = Request.Form["realName"].ToString().Trim();
                //strLog.AppendFormat("realName:{0}\r\n", realName);
                certnum = Request.Form["certnum"].ToString().Trim();
                //strLog.AppendFormat("certnum:{0}\r\n", certnum);
                strLog.AppendFormat("去翼支付查看该账号是否已经存在\r\n");
                int QueryBesttoneAccountResult = BesttoneAccountHelper.BesttoneAccountInfoQuery(BestToneAccount, out ai, out ResponseCode, out ErrMsg);
                //strLog.AppendFormat("查看结果 QueryBesttoneAccountResult:{0},ResponseCode:{1},ErrMsg:{2}\r\n", QueryBesttoneAccountResult, ResponseCode, ErrMsg);
                if (QueryBesttoneAccountResult == 0)
                {
                    if ("200010".Equals(ResponseCode))   // 未开户
                    {
                        strLog.AppendFormat("200010-未开户\r\n");
                        strLog.AppendFormat("准备开户\r\n");
                        //strLog.AppendFormat("开户前日志参数:SPID:{0},TransactionID:{1},CustID:{2},BestToneAccount:{3}\r\n", SPID, TransactionID, BestToneAccount);
                        UserRegistry.BeforeCreateBesttoneAccount(SPID, TransactionID, CustID, BestToneAccount, out ErrMsg);
                        //strLog.AppendFormat("日志结果 ErrMsg:{0} \r\n", ErrMsg);
                        strLog.AppendFormat("开户...\r\n");

                        Result = BesttoneAccountHelper.RegisterBesttoneAccount(BestToneAccount, realName, BestToneAccount, "", sex, "1", certnum, TransactionID, out ErrMsg);
                        //strLog.AppendFormat("开户结果:Result:{0},ErrMsg:{1},TransactionID:{2}\r\n", Result, ErrMsg, TransactionID);
                        if (Result == 0)
                        {
                            //strLog.AppendFormat("开户成功\r\n,准备去将账户{0}绑定到{1}上\r\n", BestToneAccount, CustID);
                            int BindResult = UserRegistry.CreateBesttoneAccount(SPID, CustID, BestToneAccount, out ErrMsg);
                            //strLog.AppendFormat("绑定结果:BindResult:{0},ErrMsg:{1}上\r\n", BindResult, ErrMsg);
                            if (BindResult == 0)
                            {
                                strLog.AppendFormat("开户后日志\r\n");
                                UserRegistry.AfterCreateBesttoneAccount(SPID, TransactionID, CustID, BestToneAccount, out ErrMsg);
                                int retWriteBack = UserRegistry.WriteBackBestToneAccountToCustInfo(SPID, CustID, realName, certnum, out ErrMsg);
                                //strLog.AppendFormat("开户后日志结果:ErrMsg:{0}\r\n", ErrMsg);
                                Response.Redirect("NewOpenAccountResult.aspx?SPTokenRequest=" + HttpUtility.UrlEncode(SPTokenRequest) + "&CreateBesttoneAccountResult=0&RegistryResponse=" + HttpUtility.UrlEncode(RegistryResponseValue), true);
                            }
                            else
                            {
                                Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
                            }
                        }
                        else
                        {
                            Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
                        }
                    }
                    else
                    {
                        // 账户已存在
                        strLog.AppendFormat("账户已经存在\r\n");
                        strLog.AppendFormat("仅仅做绑定\r\n");
                        UserRegistry.OnlyBindingBesttoneAccount(SPID, TransactionID, CustID, BestToneAccount, out ErrMsg);

                        int BindResult = UserRegistry.CreateBesttoneAccount(SPID, CustID, BestToneAccount, out ErrMsg);
                        //strLog.AppendFormat("绑定结果:ErrMsg:{0}\r\n", ErrMsg);
                        if (BindResult == 0)
                        {
                            UserRegistry.AfterCreateBesttoneAccount(SPID, TransactionID, CustID, BestToneAccount, out ErrMsg);
                            int retWriteBack = UserRegistry.WriteBackBestToneAccountToCustInfo(SPID, CustID, realName, certnum, out ErrMsg);
                            Response.Redirect("NewOpenAccountResult.aspx?SPTokenRequest=" + HttpUtility.UrlEncode(SPTokenRequest) + "&CreateBesttoneAccountResult=0&RegistryResponse=" + HttpUtility.UrlEncode(RegistryResponseValue), true);
                        }
                        else
                        {
                            Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
                        }
                    }
                }
                else
                {
                    Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
                }
            }
            //不需要开户
            //这里应该先到一个结果页面,并将ReturnUrl传给结果页面,结果页面倒计时3秒后自动跳转到ReturnUrl,根据注册和开户跳转到不同的结果页面
            if (ReturnUrl.IndexOf("?") > 0)
            {
                Response.Redirect(ReturnUrl + "&RegistryResponse=" + RegistryResponseValue, false);
            }
            else
            {
                Response.Redirect(ReturnUrl + "?RegistryResponse=" + RegistryResponseValue, false);
            }
        }
        catch (Exception ex)
        {
            strLog.AppendFormat(ex.ToString());
            Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ex.ToString());
        }
        finally
        {
            log(strLog.ToString());
        }
    }
Exemplo n.º 11
0
    protected void btn_OK_Click(object sender, EventArgs e)
    {
        if (CertificateType.Value != "")
        {
            certno.Style.Value  = "display:block";
            certnoL.Style.Value = "display:block";
        }
        else
        {
            certno.Style.Value  = "display:none";
            certnoL.Style.Value = "display:none";
        }
        this.areaInfoList.Value = resulttxt.Value.ToString();
        SPID      = Request["SPID"] == null ? ConstHelper.DefaultInstance.BesttoneSPID : HttpUtility.HtmlDecode(Request["SPID"]);
        ReturnUrl = Request["ReturnUrl"] == null ? ConstHelper.DefaultInstance.BesttoneLoginPage : HttpUtility.HtmlDecode(Request["ReturnUrl"]);

        string username = Request.Form["username"].ToString().Trim();
        string fullname = Request.Form["fullname"].ToString().Trim();
        string password = Request.Form["password"].ToString().Trim();

        if (CommonUtility.IsEmpty(password))
        {
            err_password.InnerHtml = "密码不能为空格";
            return;
        }
        string telephone = Request.Form["telephone"].ToString().Trim();
        string phonecode = Request.Form["phone_code"].ToString().Trim();

        if (ViewState["phonestate"] == null)
        {
            ViewState["phonestate"] = Request.Form["phonestate"].ToString();
            string a = (string)ViewState["phonestate"];
        }

        string email            = Request.Form["email"].ToString().Trim();
        string NickName         = Request.Form["NickName"].ToString();
        string CertificateType1 = Request.Form["CertificateType"].ToString();
        string certnoS          = Request.Form["certno"].ToString().Trim();
        string sex         = Request.Form["sex"].ToString();
        string birthday    = Request.Form["birthday"].ToString().Trim();
        string EduLevel    = Request.Form["EduLevel"].ToString().Trim();
        string IncomeLevel = Request.Form["IncomeLevel"].ToString();
        string Province    = stext.Value.ToString();
        string Area        = resulttxt.Value.ToString();
        string ErrMsg      = "";
        int    Result;

        //判断用户名是否存在
        if (CustBasicInfo.IsExistUser(username) != 0)
        {
            err_username.InnerHtml = "该用户名已经存在";

            return;
        }


        if (((string)ViewState["phonestate"]).Equals("0"))
        {
            //判断手机验证码
            Result = PhoneBO.SelSendSMSMassage("", telephone, phonecode, out ErrMsg);
            if (Result != 0)
            {
                err_phone_code.InnerHtml = "手机验证码错误,请重新输入";

                return;
            }

            //判断页面验证码
            if (!CommonUtility.ValidateValidateCode(HttpUtility.HtmlDecode(Request.Form["page_code"].ToString().Trim().ToUpper()), this.Context))
            {
                err_page_code.InnerHtml = "页面验证码错误,请重新输入";

                return;
            }
        }

        //当为认证邮箱时,判断是否已经被绑定
        if (Chk_Mail.Checked && !CommonUtility.IsEmpty(email))
        {
            Result = SetMail.EmailSel("", email, SPID, out ErrMsg);
            if (Result != 0)
            {
                err_email.InnerHtml = "该邮箱已经被其他用户绑定";

                return;
            }
            emailstate = "0";
        }

        TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        Result    = UserRegistry.getUserRegistryWeb(SPID, username, fullname, password, telephone, (string)ViewState["phonestate"], email, emailstate,
                                                    NickName, CertificateType1, certnoS, sex, birthday, EduLevel, IncomeLevel, Province, Area, out CustID, out ErrMsg);
        if (Result != 0)
        {
            //跳转至错误页面
            if (Result == -30002)
            {
                Err_certno.InnerHtml = ErrMsg;
            }
            else
            {
                CommonBizRules.ErrorHappenedRedircet(Result, ErrMsg, "用户注册", this.Context);
            }

            return;
        }

        SPInfoManager spInfo = new SPInfoManager();
        Object        SPData = spInfo.GetSPData(this.Context, "SPData");
        string        key    = spInfo.GetPropertyBySPID(SPID, "SecretKey", SPData);
        string        Digest = CryptographyUtil.GenerateAuthenticator(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg, key);
        string        temp   = SPID + "$" + CryptographyUtil.Encrypt(TimeStamp + "$" + CustID + "$" + Result + "$" + ErrMsg + "$" + Digest, key);
        string        RegistryResponseValue = HttpUtility.UrlEncode(temp);

        //给用户写cookie
        UserToken UT             = new UserToken();
        string    key2           = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);
        string    UserTokenValue = UT.GenerateUserToken(CustID, fullname, username, NickName, "", "42", username, "1", key2, out ErrMsg);
        string    CookieName     = System.Configuration.ConfigurationManager.AppSettings["CookieName"];

        PageUtility.SetCookie(UserTokenValue, CookieName, this.Page);

        //给客户认证邮箱发EMAIL
        string m   = CommonBizRules.EncryptEmailURl(CustID, email, this.Context);
        string url = "点击完成认证:<a href='" + m + "'>" + m + "</a>";

        if (Chk_Mail.Checked && !CommonUtility.IsEmpty(email))
        {
            DateTime datetime = DateTime.Now;
            SetMail.InsertEmailSendMassage(CustID, "1", url, "", 1, email, datetime, "", "中国电信号码百事通:激活邮箱", 0, out ErrMsg);
        }

        //通知积分平台
        CIP2BizRules.InsertCustInfoNotify(CustID, "2", SPID, "", "0", out ErrMsg);
        //记登录日志
        CommonBizRules.WriteDataCustAuthenLog(SPID, CustID, "35", "0", "", "2", Result, ErrMsg);

        //跳转至成功页面
        if (ReturnUrl.IndexOf("?") > 0)
        {
            CommonBizRules.SuccessRedirect(ReturnUrl + "&RegistryResponse=" + RegistryResponseValue, "成功注册", this.Context);
        }
        else
        {
            CommonBizRules.SuccessRedirect(ReturnUrl + "?RegistryResponse=" + RegistryResponseValue, "成功注册", this.Context);
        }
    }