コード例 #1
0
    protected void register_Click(object sender, EventArgs e)
    {
        StringBuilder strLog = new StringBuilder();

        try
        {
            ParseSPTokenRequest();
            //CreateSPTokenRequest();

            Int32  Result = ErrorDefinition.CIP_IError_Result_UnknowError_Code;
            String ErrMsg = ErrorDefinition.CIP_IError_Result_UnknowError_Msg;
            realName = Request["realName"];
            //contactMail = Request["contactMail"];
            sex       = Request["sex"];
            certnum   = Request["certnum"];
            checkCode = Request["checkCode"];
            CustID    = this.myCustID.Value;
            strLog.AppendFormat("开户页面手机验证码:{0}", checkCode);

            //判断手机验证码
            if (checkCode != null && !"".Equals(checkCode))
            {
                Result = PhoneBO.SelSendSMSMassage("", this.mobile.Text, checkCode, out ErrMsg);
                if (Result != 0)
                {
                    hintCode.InnerHtml = "手机验证码错误,请重新输入";  // 这里如何控制样式

                    return;
                }
            }

            string BindedBestpayAccount          = "";
            string CreateTime                    = "";
            int    IsBesttoneAccountBindV5Result = CIP2BizRules.IsBesttoneAccountBindV5(this.myCustID.Value, out BindedBestpayAccount, out CreateTime, out ErrMsg);
            if (IsBesttoneAccountBindV5Result == 0)
            {
                Response.Redirect("ErrorInfo.aspx?ErrorInfo=该账户绑定关系未解除,请联系管理人员!");
            }

            TransactionID = BesttoneAccountHelper.CreateTransactionID();
            AccountItem ai           = new AccountItem();
            string      ResponseCode = "";
            int         QueryBesttoneAccountResult = BesttoneAccountHelper.BesttoneAccountInfoQuery(this.mobile.Text, out ai, out ResponseCode, out ErrMsg);
            strLog.AppendFormat("查询账户信息返回:{0},{1},{2}", QueryBesttoneAccountResult, ErrMsg, this.mobile.Text);
            if (QueryBesttoneAccountResult == 0)
            {
                if ("200010".Equals(ResponseCode))  // 200010 -> 客户不存在
                {
                    //todo 发起开户请求日志
                    UserRegistry.BeforeCreateBesttoneAccount(SPID, TransactionID, this.myCustID.Value, this.mobile.Text, out ErrMsg);
                    strLog.AppendFormat("BeforeCreateBesttoneAccount:ErrMsg:{0}", ErrMsg);
                    //String realName,String contactTel,String sex,String certtype,String certnum,
                    Result = BesttoneAccountHelper.RegisterBesttoneAccount(this.mobile.Text, realName, this.mobile.Text, "", sex, "1", certnum, TransactionID, out ErrMsg);
                    if (Result == 0)
                    {
                        strLog.AppendFormat("开户结果:{0},{1},{2}", Result, ErrMsg, this.myCustID.Value);
                        // todo 建立绑定关系,插入绑定关系表
                        int ret = 0;

                        ret = UserRegistry.CreateBesttoneAccount(SPID, this.myCustID.Value, this.mobile.Text, out ErrMsg);
                        strLog.AppendFormat("CreateBesttoneAccount:ErrMsg:{0}", ErrMsg);
                        if (ret == 0)
                        {
                            //todo 开户完成 建立绑定关系 日志
                            UserRegistry.AfterCreateBesttoneAccount(SPID, TransactionID, this.myCustID.Value, this.mobile.Text, out ErrMsg);
                            strLog.AppendFormat("AfterCreateBesttoneAccount:ErrMsg:{0}", ErrMsg);
                            strLog.AppendFormat("绑定结果:ret:{0},ErrMsg:{1},ReturnUrl:{2}", ret, ErrMsg, ReturnUrl);

                            int retWriteBack = UserRegistry.WriteBackBestToneAccountToCustInfo(SPID, this.myCustID.Value, realName, certnum, out ErrMsg);
                            strLog.AppendFormat("回写客户信息结果:retWriteBack:{0},ErrMsg:{1}", retWriteBack, ErrMsg);

                            strLog.AppendFormat("SPTokenRequest={0}", SPTokenRequest);
                            strLog.AppendFormat("Redirect to Url:{0}", "OpenAccountResult.aspx?SPTokenRequest=" + HttpUtility.UrlEncode(SPTokenRequest) + "&CreateBesttoneAccountResult=0");
                            Response.Redirect("OpenAccountResult.aspx?SPTokenRequest=" + HttpUtility.UrlEncode(SPTokenRequest) + "&CreateBesttoneAccountResult=0");
                        }
                        else
                        {
                            strLog.AppendFormat("绑定结果:{0},{1}", ret, ErrMsg);
                            Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
                        }
                    }
                    else
                    {
                        strLog.AppendFormat("开户结果:{0},{1}", Result, ErrMsg);
                        Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
                    }
                }
                else  // 账户已存在
                {
                    // todo 建立绑定关系,插入绑定关系表
                    UserRegistry.OnlyBindingBesttoneAccount(SPID, TransactionID, this.myCustID.Value, this.mobile.Text, out ErrMsg);
                    strLog.AppendFormat("OnlyBindingBesttoneAccount:ErrMsg:{0}", ErrMsg);
                    int ret = 0;

                    ret = UserRegistry.CreateBesttoneAccount(SPID, this.myCustID.Value, this.mobile.Text, out ErrMsg);
                    if (ret == 0)
                    {
                        int retWriteBack = UserRegistry.WriteBackBestToneAccountToCustInfo(SPID, this.myCustID.Value, realName, certnum, out ErrMsg);
                        strLog.AppendFormat("回写客户信息结果:retWriteBack:{0},ErrMsg:{1}", retWriteBack, ErrMsg);
                        strLog.AppendFormat("绑定结果:ret:{0},ErrMsg:{1},ReturnUrl:{2}", ret, ErrMsg, ReturnUrl);
                        strLog.AppendFormat(String.Format("SPTokenRequest={0}", SPTokenRequest));
                        Response.Redirect("OpenAccountResult.aspx?SPTokenRequest=" + HttpUtility.UrlEncode(SPTokenRequest) + "&CreateBesttoneAccountResult=0");
                        //Response.Redirect(this.myReturnUrl.Value);
                    }
                    else
                    {
                        strLog.AppendFormat("绑定结果:{0},{1}", ret, ErrMsg);
                        Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
                    }
                }
            }
            else
            {
                strLog.AppendFormat("查询账户信息返回:{0},{1},{2}", QueryBesttoneAccountResult, ErrMsg, this.mobile.Text);
                Response.Redirect("ErrorInfo.aspx?ErrorInfo=" + ErrMsg);
            }
        }
        catch (System.Exception ex)
        {
            log(ex.ToString());
        }
        finally
        {
            log(strLog.ToString());
        }
    }
コード例 #2
0
ファイル: Register.aspx.cs プロジェクト: qinains/lihongtu
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        StringBuilder strLog = new StringBuilder();
        String        Url    = "";

        try
        {
            PassWord       = Request.Form["password"].ToString().Trim();
            Mobile         = Request.Form["mobile"].ToString().Trim();
            CheckPhoneCode = Request.Form["checkCode"].ToString().Trim();
            strLog.AppendFormat("接收到password:{0},Mobile:{1},CheckPhoneCode:{2}\r\n", PassWord, Mobile, CheckPhoneCode);


            string UserName = "";
            string Email    = "";

            if (ViewState["phonestate"] == null)
            {
                strLog.AppendFormat("phonestate=null\r\n");
                ViewState["phonestate"] = Request.Form["phonestate"].ToString();
                string a = (string)ViewState["phonestate"];
            }
            if (((string)ViewState["phonestate"]).Equals("0"))
            {
                Result = PhoneBO.SelSendSMSMassage("", Mobile, CheckPhoneCode, out ErrMsg);
                if (Result != 0)
                {
                    strLog.AppendFormat("手机验证码校验未通过!\r\n");
                    return;
                }
            }

            strLog.AppendFormat("手机验证码校验通过!\r\n");
            Result = UserRegistry.quickUserRegistryWebV4(SPID, PassWord, Mobile, (string)ViewState["phonestate"], UserName, Email, Device, out CustID, out ErrMsg);
            if (Result != 0)
            {
                strLog.AppendFormat("注册失败!\r\n");
                return;
            }
            strLog.AppendFormat("注册成功!CustID:{0}\r\n", CustID);
            String hid_openAccount = Request.Form["hid_openAccount"].ToString().Trim();
            if ("1".Equals(hid_openAccount))
            {
                strLog.AppendFormat("开户过程\r\n");
                string BindedBestpayAccount = "";
                string CreateTime           = "";

                int IsBesttoneAccountBindV5Result = CIP2BizRules.IsBesttoneAccountBindV5(CustID, out BindedBestpayAccount, out CreateTime, out ErrMsg);
                if (IsBesttoneAccountBindV5Result == 0)
                {
                    Response.Redirect("ErrorInfo.aspx?ErrorInfo=该账户绑定关系未解除,请联系管理人员!");
                }
                String      TransactionID   = BesttoneAccountHelper.CreateTransactionID();
                AccountItem ai              = new AccountItem();
                string      ResponseCode    = "";
                string      BestToneAccount = Request.Form["mobile"].ToString().Trim();
                realName = Request.Form["realName"].ToString().Trim();
                certnum  = Request.Form["certnum"].ToString().Trim();
                int QueryBesttoneAccountResult = BesttoneAccountHelper.BesttoneAccountInfoQuery(BestToneAccount, out ai, out ResponseCode, out ErrMsg);
                if (QueryBesttoneAccountResult == 0)
                {
                    if ("200010".Equals(ResponseCode))   // 未开户
                    {
                        strLog.AppendFormat("该号码未开过户:\r\n");
                        UserRegistry.BeforeCreateBesttoneAccount(SPID, TransactionID, CustID, BestToneAccount, out ErrMsg);
                        Result = BesttoneAccountHelper.RegisterBesttoneAccount(BestToneAccount, realName, BestToneAccount, "", sex, "1", certnum, TransactionID, out ErrMsg);
                        if (Result == 0)
                        {
                            strLog.AppendFormat("开户成功:\r\n");
                            int BindResult = UserRegistry.CreateBesttoneAccount(SPID, CustID, BestToneAccount, out 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);
                        }
                    }
                    else
                    {
                        UserRegistry.OnlyBindingBesttoneAccount(SPID, TransactionID, CustID, BestToneAccount, out ErrMsg);
                        int BindResult = UserRegistry.CreateBesttoneAccount(SPID, CustID, BestToneAccount, out 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);
                }
            }

            if (ReturnUrl.IndexOf("?") > 0)
            {
                Url = ReturnUrl + "&CustID=" + CustID + "&welcomeName=" + Mobile;
            }
            else
            {
                Url = ReturnUrl + "?CustID=" + CustID + "&welcomeName=" + Mobile;
            }

            Response.Redirect(Url, true);
        }
        catch (Exception ex)
        {
            strLog.AppendFormat(ex.ToString());
        }
        finally
        {
            log(strLog.ToString());
        }
    }
コード例 #3
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());
        }
    }
コード例 #4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="SPID"></param>
    /// <param name="CustID"></param>
    /// <param name="Phone"></param>
    /// <param name="CheckPhoneCode"></param>
    /// <param name="wt"></param>
    /// <returns></returns>
    public String OpenBesttoneAccount(String SPID, String CustID, String Phone, String IDCard, String RealName, String ContactTel, String Email, String Sex, String AuthenCode, String wt)
    {
        //返回参数
        String ErrMsg = String.Empty;
        Int32  Result = ErrorDefinition.CIP_IError_Result_UnknowError_Code;

        StringBuilder ResponseMsg = new StringBuilder();


        if (CommonUtility.IsEmpty(SPID))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "995");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "SPID不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }


        if (CommonUtility.IsEmpty(CustID))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "996");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "CustID不能为空!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "996");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "CustID不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }


        if (CommonUtility.IsEmpty(Phone))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "Phone不能为空!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "997");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "Phone不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }


        if (CommonUtility.IsEmpty(IDCard))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "IDCard不能为空!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "998");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "IDCard不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        if (CommonUtility.IsEmpty(RealName))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "RealName不能为空!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "999");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "RealName不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        //验证码校验
        Result = PhoneBO.SelSendSMSMassage(CustID, Phone, AuthenCode, out ErrMsg);
        if (Result != 0)
        {
            // 验证码未校验通过  return
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1000");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", ErrMsg);
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1000");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", ErrMsg);
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }
        else
        {
            String t_custid = PhoneBO.IsAuthenPhone(Phone, SPID, out ErrMsg);
            // t_custid 可以为空,但不能是别人的custid,可以为空是说明此客户无认证电话
            if (!String.IsNullOrEmpty(t_custid))
            {
                if (CustID != t_custid)
                {
                    //是别人的手机号,不能用来开户  return
                    ResponseMsg.Length = 0;
                    if ("json".Equals(wt))
                    {
                        ResponseMsg.Append("{");
                        ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1000");
                        ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", Phone + "(" + CustID + ")是别人的手机号(" + t_custid + "),不能用来开户!");
                        ResponseMsg.Append("}");
                    }
                    else
                    {
                        ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                        ResponseMsg.Append("<PayPlatRequestParameter>");
                        ResponseMsg.Append("<PARAMETERS>");
                        ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1000");
                        ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "是别人的手机号,不能用来开户!");
                        ResponseMsg.Append("</PARAMETERS>");
                        ResponseMsg.Append("</PayPlatRequestParameter>");
                    }
                    return(ResponseMsg.ToString());
                }
            }


            if (!CommonUtility.CheckIDCard(IDCard))
            {
                //身份证不合法! return
                ResponseMsg.Length = 0;
                if ("json".Equals(wt))
                {
                    ResponseMsg.Append("{");
                    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1001");
                    ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "身份证不合法!");
                    ResponseMsg.Append("}");
                }
                else
                {
                    ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                    ResponseMsg.Append("<PayPlatRequestParameter>");
                    ResponseMsg.Append("<PARAMETERS>");
                    ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1001");
                    ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "身份证不合法!");
                    ResponseMsg.Append("</PARAMETERS>");
                    ResponseMsg.Append("</PayPlatRequestParameter>");
                }
                return(ResponseMsg.ToString());
            }

            try
            {
                String             TransactionID        = CreateTransactionID();
                BesttoneAccountDAO _besttoneAccount_dao = new BesttoneAccountDAO();
                //strLog.AppendFormat("select * from besttoneaccount where custid={0}\r\n", CustID);
                BesttoneAccount besttoneAccountEntity = _besttoneAccount_dao.QueryByCustID(CustID);


                AccountItem ai = new AccountItem();
                String      QueryBAResponseCode = "";

                if (besttoneAccountEntity == null)   // 未绑定
                {
                    //去翼支付查
                    int QueryBesttoneAccountResult = QueryBesttoneAccount(Phone, out ai, out QueryBAResponseCode, out ErrMsg);

                    //if (QueryBesttoneAccountResult == 0)
                    //{
                    if ("200010".Equals(QueryBAResponseCode))                                                     // 未开户
                    {
                        UserRegistry.BeforeCreateBesttoneAccount(SPID, TransactionID, CustID, Phone, out ErrMsg); //日志
                        RegisterBesttoneAccount(Phone, RealName, ContactTel, Email, Sex, "1", IDCard, TransactionID, out ErrMsg);
                        UserRegistry.CreateBesttoneAccount(SPID, CustID, Phone, out ErrMsg);                      //建立绑定关系
                        UserRegistry.AfterCreateBesttoneAccount(SPID, TransactionID, CustID, Phone, out ErrMsg);  //日志
                        UserRegistry.WriteBackBestToneAccountToCustInfo(SPID, CustID, RealName, IDCard, out ErrMsg);
                        ResponseMsg.Length = 0;
                        if ("json".Equals(wt))
                        {
                            ResponseMsg.Append("{");
                            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "0");
                            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "开户成功,绑定成功!");
                            ResponseMsg.Append("}");
                        }
                        else
                        {
                            ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                            ResponseMsg.Append("<PayPlatRequestParameter>");
                            ResponseMsg.Append("<PARAMETERS>");
                            ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "0");
                            ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "开户成功,绑定成功!");
                            ResponseMsg.Append("</PARAMETERS>");
                            ResponseMsg.Append("</PayPlatRequestParameter>");
                        }
                        return(ResponseMsg.ToString());
                    }
                    else
                    {       //可能在开过户
                        if ("000000".Equals(QueryBAResponseCode))
                        {
                            //绑定操作
                            UserRegistry.CreateBesttoneAccount(SPID, CustID, Phone, out ErrMsg);
                            UserRegistry.OnlyBindingBesttoneAccount(SPID, TransactionID, CustID, Phone, out ErrMsg);

                            ResponseMsg.Length = 0;
                            if ("json".Equals(wt))
                            {
                                ResponseMsg.Append("{");
                                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "0");
                                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "仅仅绑定成功!");
                                ResponseMsg.Append("}");
                            }
                            else
                            {
                                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                                ResponseMsg.Append("<PayPlatRequestParameter>");
                                ResponseMsg.Append("<PARAMETERS>");
                                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "0");
                                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "仅仅绑定成功!");
                                ResponseMsg.Append("</PARAMETERS>");
                                ResponseMsg.Append("</PayPlatRequestParameter>");
                            }
                            return(ResponseMsg.ToString());
                        }
                        else
                        {
                            //账户状态可能存在异常  return

                            ResponseMsg.Length = 0;
                            if ("json".Equals(wt))
                            {
                                ResponseMsg.Append("{");
                                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1002");
                                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "账户状态可能存在异常!");
                                ResponseMsg.Append("}");
                            }
                            else
                            {
                                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                                ResponseMsg.Append("<PayPlatRequestParameter>");
                                ResponseMsg.Append("<PARAMETERS>");
                                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1002");
                                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "账户状态可能存在异常!");
                                ResponseMsg.Append("</PARAMETERS>");
                                ResponseMsg.Append("</PayPlatRequestParameter>");
                            }
                            return(ResponseMsg.ToString());
                        }
                    }
                    //}
                    //else
                    //{
                    ////账户查询过程中发生异常  return
                    //ResponseMsg.Length = 0;
                    //if ("json".Equals(wt))
                    //{
                    //    ResponseMsg.Append("{");
                    //    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1003");
                    //    ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "账户查询过程中发生异常!");
                    //    ResponseMsg.Append("}");
                    //}
                    //else
                    //{
                    //    ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                    //    ResponseMsg.Append("<PayPlatRequestParameter>");
                    //    ResponseMsg.Append("<PARAMETERS>");
                    //    ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1003");
                    //    ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "账户查询过程中发生异常!");
                    //    ResponseMsg.Append("</PARAMETERS>");
                    //    ResponseMsg.Append("</PayPlatRequestParameter>");
                    //}
                    //return ResponseMsg.ToString();
                    //}
                }
                else
                {
                    //该手机号码已经开过户,账户所绑定的custid不管是不是自己的,都不允许再开户
                    ResponseMsg.Length = 0;
                    if ("json".Equals(wt))
                    {
                        ResponseMsg.Append("{");
                        ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1004");
                        ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "该手机号码已经开过户!");
                        ResponseMsg.Append("}");
                    }
                    else
                    {
                        ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                        ResponseMsg.Append("<PayPlatRequestParameter>");
                        ResponseMsg.Append("<PARAMETERS>");
                        ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1004");
                        ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "该手机号码已经开过户!");
                        ResponseMsg.Append("</PARAMETERS>");
                        ResponseMsg.Append("</PayPlatRequestParameter>");
                    }
                    return(ResponseMsg.ToString());
                }
            }
            catch (Exception ecp)
            {
                ResponseMsg.Length = 0;
                if ("json".Equals(wt))
                {
                    ResponseMsg.Append("{");
                    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1005");
                    ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", ecp.ToString());
                    ResponseMsg.Append("}");
                }
                else
                {
                    ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                    ResponseMsg.Append("<PayPlatRequestParameter>");
                    ResponseMsg.Append("<PARAMETERS>");
                    ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "1005");
                    ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", ecp.ToString());
                    ResponseMsg.Append("</PARAMETERS>");
                    ResponseMsg.Append("</PayPlatRequestParameter>");
                }
                return(ResponseMsg.ToString());
            }
        }

        // 开户的前置条件
        //1.必须先登录(说明是合法号百客户,有CUSTID)
        //2.手机验证码校验  (如果是接口,仅校验手机验证码,如果是页面,则需校验页面验证码?)
        //3.检查手机号码是否是别人的登录账号 (登录后获得的custid和custphone 的custid比对)
        //4.验证身份证号是否合法
        //5.检查手机号码是否是别人的支付账户 (是否已经存在绑定关系,如果是,是否是绑定在自己的custid下)
        //6.去翼支付检查该手机号码是否开过户(直接调翼支付账户查询)

        //开户

        //IF 校验码未通过
        //    重定向到错误页面(如果是接口,则返回错误提示)
        //ELSE
        //      IF 根据PHONE 获得的CUSTID不是 登录CUSTID
        //           非法开户,重定向到错误页面 (如果是接口,则返回错误提示)  --
        //      ELSE
        //            IF PHONE 存在于账户绑定关系
        //    IF 账户对应的CUSTID 与登录后获得的CUSTID 不匹配   -- 说明该手机号码已经被别的客户开成账户了
        //           该手机号码已经被别的客户开成账户了,重定向到错误页面,如果是接口,则返回错误提示信息
        //                ELSE
        //                      该手机已经开过户,不需要再开户
        //    END
        //           ELSE
        //                     IF 翼支付没能能查到该手机的账户信息 --说明的确未开户
        //                              验证身份证号是否合法
        //                               开户 (调用翼支付开户接口)
        //                                插入绑定关系表
        //                     END
        //           END
        //       END
        //END
        return(ResponseMsg.ToString());
    }