Пример #1
0
    protected void UnifyAccountCheck()
    {
        StringBuilder strLog = new StringBuilder();
        Int32         Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        String        ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;

        try
        {
            SPID        = Request["SPID"];
            ReturnUrl   = Request["ReturnUrl"] == null ? String.Empty : Request["ReturnUrl"];
            AccessToken = Request["accessToken"];
            appId       = Request["appId"];
            paras       = Request["paras"];
            sign        = Request["sign"];
            strLog.AppendFormat("SPID:{0},ReturnUrl:{1},appId:{2},paras:{3},sign:{4},AccessToken:{5}\r\n", SPID, ReturnUrl, appId, paras, sign, AccessToken);
            //查综合平台客户信息
            strLog.Append("查询综合平台客户信息\r\n");
            if (!String.IsNullOrEmpty(AccessToken))
            {
                UnifyAccountInfo accountInfo = new UnifyAccountInfo();
                String           clientIp    = System.Configuration.ConfigurationManager.AppSettings["CIP2_clientIp"];//? 通过f5出去的,这样获得地址不对
                if (String.IsNullOrEmpty(clientIp))
                {
                    clientIp = Request.UserHostAddress;
                }

                String clientAgent                = Request.UserAgent;
                String unifyPlatform_appId        = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId;     //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_appId"];
                String unifyPlatform_appSecretKey = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret; //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_appSecretKey"];
                String p_version    = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion;                 //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_version"];
                String p_clientType = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType;
                Result = _UDBMBoss.UnifyPlatformGetUserInfo(unifyPlatform_appId, unifyPlatform_appSecretKey, p_version, p_clientType, AccessToken, clientIp, clientAgent, out accountInfo, out ErrMsg);
                strLog.AppendFormat("查询综合平台返回:Result:{0},ErrMsg:{1},UserID:{2}\r\n", Result, ErrMsg, Convert.ToString(accountInfo.userId));
                if (Result == 0 && !String.IsNullOrEmpty(Convert.ToString(accountInfo.userId)))  //这个地方跟登录回来不一致,登录回来是根据loginnum去匹配
                {
                    ///////////////
                    #region 开始注册到号百
                    String CustID, OuterID, Status, CustType, CustLevel, RealName, UserName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                    CustID = String.Empty;
                    Regex  regMobile  = new Regex(@"^1[345678]\d{9}$");
                    Regex  regEmail   = new Regex(@"^[0-9a-zA-Z_\-\.]*[0-9a-zA-Z_\-]@[0-9a-zA-Z]+\.+[0-9a-zA-Z_\-.]+$");
                    String MobileName = String.Empty;
                    String EmailName  = String.Empty;

                    if (!String.IsNullOrEmpty(accountInfo.nickName))
                    {
                        RealName = accountInfo.nickName;
                    }
                    else if (!String.IsNullOrEmpty(accountInfo.userName))
                    {
                        RealName = accountInfo.userName;
                    }
                    else if (!String.IsNullOrEmpty(accountInfo.mobileName))
                    {
                        RealName = accountInfo.mobileName;
                    }
                    else if (!String.IsNullOrEmpty(accountInfo.emailName))
                    {
                        RealName = accountInfo.emailName;
                    }
                    else
                    {
                        RealName = "";
                    }

                    if (!String.IsNullOrEmpty(accountInfo.mobileName))
                    {
                        MobileName = accountInfo.mobileName;
                    }

                    if (!String.IsNullOrEmpty(accountInfo.emailName))
                    {
                        EmailName = accountInfo.emailName;
                    }

                    String EncrytpPassWord = CryptographyUtil.Encrypt("123456"); //通过页面注册进来的,不知道密码,给一个默认密码
                    //通过统一注册页面过来的,注册为号百的 “非认证用户”,通过语音注册进来的,注册为号百的 “认证用户”
                    String OperType = "1";                                       // 注册 ,
                    if (!String.IsNullOrEmpty(MobileName) || !String.IsNullOrEmpty(EmailName))
                    {
                        strLog.Append("【开始注册或者绑定到号百】:\r\n");
                        Result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", MobileName, EmailName, RealName, EncrytpPassWord, accountInfo.userId, SPID, OperType, out CustID, out ErrMsg);
                        strLog.Append("【开始注册或者绑定到号百的结果】:\r\n");
                        strLog.AppendFormat("Result:{0},CustID:{1},ErrMsg:{2}\r\n", Result, CustID, ErrMsg);
                        //注册成功
                        if (Result == 0)
                        {
                            Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
                                                               out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
                                                               out AreaID, out RegistrationSource);
                            strLog.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                            if (Result != 0)
                            {
                                strLog.Append(",ErrMsg:客户不存在" + CustID);
                                Redirect("ErrMsg", "客户不存在");
                            }
                            strLog.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                            //生成Ticket
                            ticket = CommonBizRules.CreateTicket();
                            Result = CIPTicketManager.insertCIPTicket(ticket, SPID, CustID, RealName, UserName, NickName, OuterID, "UDBTicket", Convert.ToString(accountInfo.userId), "42", out ErrMsg);
                            //insertAccessToken
                            strLog.AppendFormat("【生成ticket】:Result:{0},Ticket:{1}", Result, ticket);
                            strLog.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                            if (Result != 0)
                            {
                                strLog.Append(",ErrMsg:Ticket生成失败" + ticket);
                                Redirect("ErrMsg", "Ticket生成失败");
                            }
                            strLog.Append(",Message:生成ticket成功,返回业务系统\r\n");
                            ReturnUrl = Request["ReturnUrl"];
                            strLog.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                            strLog.AppendFormat("Response.Redirect to {0}\r\n", ReturnUrl);
                            Response.Redirect(ReturnUrl, false);
                        }
                    }
                    else
                    {
                        Result = -7766;
                        ErrMsg = "MobileName,或者EmailName为空,所以不注册号百客户";
                        strLog.Append("MobileName,或者EmailName为空,所以不注册号百客户\r\n");
                        Redirect("ErrMsg", "MobileName,或者EmailName为空,所以不注册号百客户");
                    }
                    strLog.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                    //下面删掉一大段
                    #endregion
                    //////////////
                }
                else
                { //查询综合平台客户信息失败,或者account.userid为空
                    strLog.Append("查询综合平台客户信息失败,或者account.userid为空\r\n");
                    Redirect("ErrMsg", "查询综合平台客户信息失败,或者account.userid为空");
                }
            }
            else
            { //accesstoken没有返回
                strLog.Append("综合平台accesstoken没有返回\r\n");
                Redirect("ErrMsg", "综合平台accesstoken没有返回户");
            }
        }
        catch (Exception e)
        {
            strLog.AppendFormat("异常:{0}\r\n", e.ToString());
        }
        finally
        {
            log(strLog.ToString());
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Int32  Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        String ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;

        StringBuilder strMsg = new StringBuilder();

        SPID = Request["SPID"];
        string appId = Request["appId"];
        string paras = Request["paras"];
        string sign  = Request["sign"];

        string unifyPlatform_appId        = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId;     //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_appId"];
        string unifyPlatform_appSecretKey = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret; //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_appSecretKey"];

        strMsg.AppendFormat("返回参数:appId:{0},paras:{1},sign:{2}\r\n", appId, paras, sign);

        string unifyPlatformResponse = CryptographyUtil.XXTeaDecrypt(paras, unifyPlatform_appSecretKey);

        strMsg.AppendFormat("unifyPlatformResponse:{0}\r\n", unifyPlatformResponse);
        string newsign = CryptographyUtil.HMAC_SHA1(unifyPlatform_appId + paras, unifyPlatform_appSecretKey);

        strMsg.AppendFormat("newsign:{0},sign:{1}\r\n", newsign, sign);

        if (!newsign.Equals(sign))
        {
            Redirect("ErrMsg", "签名不正确");
        }

        string result         = "";
        string accessToken    = "";
        string timeStamp      = "";
        string userId         = "";
        string productUid     = "";
        string loginNum       = "";
        string nickName       = "";
        string userIconUrl    = "";
        string userIconUrl2   = "";
        string userIconUrl3   = "";
        string isThirdAccount = "";

        Dictionary <String, String> parames = new Dictionary <string, string>();

        strMsg.Append("开始解析unifyPlatformResponse\r\n");
        try
        {
            parames = splitParameters(unifyPlatformResponse);
            strMsg.AppendFormat("params:{0}\r\n", parames);
        }
        catch (Exception exp)
        {
            strMsg.AppendFormat(exp.ToString());
        }
        strMsg.Append("解析unifyPlatformResponse完毕\r\n");

        foreach (KeyValuePair <String, String> p in parames)
        {
            if (p.Key.Equals("result"))
            {
                result = p.Value;
                strMsg.AppendFormat("result:{0}\r\n", result);
            }
            if (p.Key.Equals("accessToken"))
            {
                accessToken = p.Value;
                strMsg.AppendFormat("accessToken:{0}\r\n", accessToken);
            }
            if (p.Key.Equals("timeStamp"))
            {
                timeStamp = p.Value;
                strMsg.AppendFormat("timeStamp:{0}\r\n", timeStamp);
            }
            if (p.Key.Equals("userId"))
            {
                userId = p.Value;
                strMsg.AppendFormat("userId:{0}\r\n", userId);
            }
            if (p.Key.Equals("productUid"))
            {
                productUid = p.Value;
                strMsg.AppendFormat("productUid:{0}\r\n", productUid);
            }
            if (p.Key.Equals("loginNum"))
            {
                loginNum = p.Value;
                strMsg.AppendFormat("loginNum:{0}\r\n", loginNum);
            }
            if (p.Key.Equals("nickName"))
            {
                nickName = p.Value;
                strMsg.AppendFormat("nickName:{0}\r\n", nickName);
            }
            if (p.Key.Equals("userIconUrl"))
            {
                userIconUrl = p.Value;
                strMsg.AppendFormat("userIconUrl:{0}\r\n", userIconUrl);
            }
            if (p.Key.Equals("userIconUrl2"))
            {
                userIconUrl2 = p.Value;
                strMsg.AppendFormat("userIconUrl2:{0}\r\n", userIconUrl2);
            }
            if (p.Key.Equals("userIconUrl3"))
            {
                userIconUrl3 = p.Value;
                strMsg.AppendFormat("userIconUrl3:{0}\r\n", userIconUrl3);
            }
            if (p.Key.Equals("isThirdAccount"))
            {
                isThirdAccount = p.Value;
                strMsg.AppendFormat("isThirdAccount:{0}\r\n", isThirdAccount);
            }
        }

        strMsg.Append("【综合平台 getUserInfo.do】:");

        UnifyAccountInfo accountInfo = new UnifyAccountInfo();
        String           clientIp    = System.Configuration.ConfigurationManager.AppSettings["CIP2_clientIp"];//? 通过f5出去的,这样获得地址不对

        if (String.IsNullOrEmpty(clientIp))
        {
            clientIp = Request.UserHostAddress;
        }

        try
        {
            String clientAgent = Request.UserAgent;
            if ("0".Equals(result) && !String.IsNullOrEmpty(accessToken))                      // result = 0 说明已经处于登录状态 result = 1 说明处于未登录状态
            {
                string p_version    = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion; //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_version"];
                string p_clientType = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType;
                Result = _UDBMBoss.UnifyPlatformGetUserInfo(unifyPlatform_appId, unifyPlatform_appSecretKey, p_version, p_clientType, accessToken, clientIp, clientAgent, out accountInfo, out ErrMsg);

                if (Result == 0)  // 综合平台查询客户信息成功
                {
                    String CustID, OuterID, Status, CustType, CustLevel, RealName, UserName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                    //检测对应用户是否在号百系统,不在,则注册进来
                    strMsg.Append("【开始注册到号百】:");
                    CustID = String.Empty;
                    System.Text.RegularExpressions.Regex regMobile = new System.Text.RegularExpressions.Regex(@"^1[345678]\d{9}$");
                    System.Text.RegularExpressions.Regex regEmail  = new System.Text.RegularExpressions.Regex(@"^[0-9a-zA-Z_\-\.]*[0-9a-zA-Z_\-]@[0-9a-zA-Z]+\.+[0-9a-zA-Z_\-.]+$");
                    System.Text.RegularExpressions.Regex regCard   = new System.Text.RegularExpressions.Regex(@"^(\d{9}|\d{16})$");

                    string AuthenType = "1";
                    strMsg.AppendFormat("accountInfo.username:{0}\r\n", accountInfo.userName);
                    strMsg.AppendFormat("acountInfo.userId:{0},accountInfo.pUserId:{1}\r\n", accountInfo.userId, accountInfo.pUserId);
                    if (regMobile.IsMatch(accountInfo.userName))
                    {
                        AuthenType = "2";
                    }
                    if (regEmail.IsMatch(accountInfo.userName))
                    {
                        AuthenType = "4";
                    }
                    if (regCard.IsMatch(accountInfo.userName))
                    {
                        AuthenType = "3";
                    }

                    if ("2".Equals(AuthenType))
                    {
                        //Result = UserRegistry.getUserRegistryUnifyPlatform(accountInfo, out CustID, out ErrMsg);
                        String OperType = "3"; // 注册
                        String Password = "";  // 从综合平台注册过来,密码是不知道的
                        RealName = "";
                        Result   = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", accountInfo.mobileName,
                                                                          accountInfo.emailName, RealName, Password, accountInfo.userId, SPID, OperType, out CustID, out ErrMsg);
                    }
                    else
                    {
                        Result = -7766;
                    }

                    //Result = UserRegistry.getUserRegistryUnifyPlatform(accountInfo, out CustID, out ErrMsg);


                    strMsg.AppendFormat("Result:{0},CustID:{1}\r\n", Result, CustID);
                    strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                    //注册成功
                    if (Result == 0)
                    {
                        Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
                                                           out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
                                                           out AreaID, out RegistrationSource);
                        strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                        if (Result != 0)
                        {
                            strMsg.Append(",ErrMsg:客户不存在" + CustID);
                            //客户不存在
                            Redirect("ErrMsg", "客户不存在");
                        }

                        //埋综合平台token
                        //String UnifyPlatformCookieName = ConfigurationManager.AppSettings["UnifyPlatformCookieName"];
                        //PageUtility.SetCookie(accessToken, UnifyPlatformCookieName, this.Page);

                        strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000");

                        //埋号百token
                        string AuthenName = UserName;
                        AuthenType = "2";
                        SPInfoManager spInfo         = new SPInfoManager();
                        Object        SPData         = spInfo.GetSPData(this.Context, "SPData");
                        string        key            = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);
                        UserToken     UT             = new UserToken();
                        string        UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, OuterID, CustType, AuthenName, AuthenType, key, out ErrMsg);
                        string        CookieName     = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
                        PageUtility.SetCookie(UserTokenValue, CookieName, this.Page);

                        //ReturnUrl = Request["ReturnUrl"] ;
                        strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000");
                        strMsg.AppendFormat("Response.Redirect to {0}\r\n", ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000");
                        Response.Redirect(ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000", false);
                    }
                    else
                    {
                        string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
                        PageUtility.ExpireCookie(CookieName, this.Page);
                        Response.Redirect(ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000", false);
                    }
                }
            }
            else  // 未登录
            {
                //清楚cookie (登录状态)
                string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
                PageUtility.ExpireCookie(CookieName, this.Page);

                //PageUtility.ExpireCookie(UnifyPlatformCookieName, this.Page);

                Response.Redirect(ReturnUrl + "?UnifyAccountCheckResult=1&SPID=35000000", false);
            }

            //if ("0".Equals(result) && Result == 0)   // 认证成功 并且根据accesstoken查客户信息成功
            //{
            //    String CustID, OuterID, Status, CustType, CustLevel, RealName, UserName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
            //    //检测对应用户是否在号百系统,不在,则注册进来
            //    strMsg.Append("【开始注册到号百】:");
            //    Result = UserRegistry.getUserRegistryUnifyPlatform(accountInfo, out CustID, out ErrMsg);
            //    strMsg.AppendFormat("Result:{0},CustID:{1}\r\n", Result, CustID);
            //    strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
            //    //注册成功
            //    if (Result == 0)
            //    {
            //        Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
            //            out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
            //            out AreaID, out RegistrationSource);
            //        strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
            //        if (Result != 0)
            //        {
            //            strMsg.Append(",ErrMsg:客户不存在" + CustID);
            //            //客户不存在
            //            Redirect("ErrMsg", "客户不存在");
            //        }

            //        //埋综合平台token
            //        //String UnifyPlatformCookieName = ConfigurationManager.AppSettings["UnifyPlatformCookieName"];
            //        //PageUtility.SetCookie(accessToken, UnifyPlatformCookieName, this.Page);

            //        strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);

            //        //埋号百token
            //        string AuthenName = UserName;
            //        string AuthenType = "2";
            //        SPInfoManager spInfo = new SPInfoManager();
            //        Object SPData = spInfo.GetSPData(this.Context, "SPData");
            //        string key = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);
            //        UserToken UT = new UserToken();
            //        string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, OuterID, CustType, AuthenName, AuthenType, key, out ErrMsg);
            //        string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
            //        PageUtility.SetCookie(UserTokenValue, CookieName, this.Page);
            //        //ReturnUrl = Request["ReturnUrl"] ;
            //        strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
            //        strMsg.AppendFormat("Response.Redirect to {0}\r\n", ReturnUrl);
            //        Response.Redirect(ReturnUrl, false);
            //    }
            //    else
            //    {
            //        strMsg.Append(",ErrMsg:用户注册到号百失败");

            //    }
            //}
        }
        catch (Exception excp)
        {
            strMsg.AppendFormat("异常:{0}\r\n", excp.ToString());
        }
        finally
        {
            WriteLog(strMsg.ToString());
        }
        //WriteLog(strMsg.ToString());
    }
Пример #3
0
    /// <summary>
    /// 开始UDBSSO功能
    /// </summary>
    protected void ProcessUnifyPlatformReturn()
    {
        StringBuilder strMsg = new StringBuilder();
        Int32         Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        String        ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;

        try
        {
            #region 获取参数并验证

            SPID      = Request["SPID"];
            ReturnUrl = Request["ReturnUrl"] == null ? String.Empty : Request["ReturnUrl"];
            LSID      = Request["LSID"];
            appId     = Request["appId"];
            paras     = Request["paras"];
            sign      = Request["sign"];

            string unifyPlatform_appId        = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId;     //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_appId"];
            string unifyPlatform_appSecretKey = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret; //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_appSecretKey"];


            strMsg.AppendFormat("【验证参数,DateTime:{0}】:SPID:{1},LSID:{2},ReturnUrl:{3},appId:{4},paras:{5},sign:{6}\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), SPID, LSID, ReturnUrl, appId, paras, sign);

            string unifyPlatformResponse = CryptographyUtil.XXTeaDecrypt(paras, unifyPlatform_appSecretKey);
            strMsg.AppendFormat("unifyPlatformResponse:{0}\r\n", unifyPlatformResponse);
            string newsign = CryptographyUtil.HMAC_SHA1(unifyPlatform_appId + paras, unifyPlatform_appSecretKey);
            strMsg.AppendFormat("newsign:{0},sign:{1}\r\n", newsign, sign);
            strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
            if (!newsign.Equals(sign))
            {
                Redirect("ErrMsg", "签名不正确");
            }

            //paras {result,accessToken,timeStamp,userId,productUid,loginNum,nickName,userIconUrl,userIconUrl2,userIconUrl3,isThirdAccount}
            string result         = "";
            string accessToken    = "";
            string timeStamp      = "";
            string userId         = "";
            string productUid     = "";
            string loginNum       = "";
            string nickName       = "";
            string userIconUrl    = "";
            string userIconUrl2   = "";
            string userIconUrl3   = "";
            string isThirdAccount = "";


            Dictionary <String, String> parames = new Dictionary <string, string>();
            strMsg.Append("开始解析unifyPlatformResponse\r\n");
            try
            {
                parames = splitParameters(unifyPlatformResponse);
                strMsg.AppendFormat("params:{0}\r\n", parames);
            }
            catch (Exception exp)
            {
                strMsg.AppendFormat(exp.ToString());
            }
            strMsg.Append("解析unifyPlatformResponse完毕\r\n");
            foreach (KeyValuePair <String, String> p in parames)
            {
                if (p.Key.Equals("result"))
                {
                    result = p.Value;
                    strMsg.AppendFormat("result:{0}\r\n", result);
                }
                if (p.Key.Equals("accessToken"))
                {
                    accessToken = p.Value;
                    strMsg.AppendFormat("accessToken:{0}\r\n", accessToken);
                }
                if (p.Key.Equals("timeStamp"))
                {
                    timeStamp = p.Value;
                    strMsg.AppendFormat("timeStamp:{0}\r\n", timeStamp);
                }
                if (p.Key.Equals("userId"))
                {
                    userId = p.Value;
                    strMsg.AppendFormat("userId:{0}\r\n", userId);
                }
                if (p.Key.Equals("productUid"))
                {
                    productUid = p.Value;
                    strMsg.AppendFormat("productUid:{0}\r\n", productUid);
                }
                if (p.Key.Equals("loginNum"))
                {
                    loginNum = p.Value;
                    strMsg.AppendFormat("loginNum:{0}\r\n", loginNum);
                }
                if (p.Key.Equals("nickName"))
                {
                    nickName = p.Value;
                    strMsg.AppendFormat("nickName:{0}\r\n", nickName);
                }
                if (p.Key.Equals("userIconUrl"))
                {
                    userIconUrl = p.Value;
                    strMsg.AppendFormat("userIconUrl:{0}\r\n", userIconUrl);
                }
                if (p.Key.Equals("userIconUrl2"))
                {
                    userIconUrl2 = p.Value;
                    strMsg.AppendFormat("userIconUrl2:{0}\r\n", userIconUrl2);
                }
                if (p.Key.Equals("userIconUrl3"))
                {
                    userIconUrl3 = p.Value;
                    strMsg.AppendFormat("userIconUrl3:{0}\r\n", userIconUrl3);
                }
                if (p.Key.Equals("isThirdAccount"))
                {
                    isThirdAccount = p.Value;
                    strMsg.AppendFormat("isThirdAccount:{0}\r\n", isThirdAccount);
                }
            }
            strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);

            #endregion

            #region 根据UDBTkcket到UDB查询用户信息

            strMsg.Append("【开始查询信息】:");

            UnifyAccountInfo accountInfo = new UnifyAccountInfo();
            String           clientIp    = System.Configuration.ConfigurationManager.AppSettings["CIP2_clientIp"];//? 通过f5出去的,这样获得地址不对
            if (String.IsNullOrEmpty(clientIp))
            {
                clientIp = Request.UserHostAddress;
            }

            String clientAgent = Request.UserAgent;
            ////根据UDBTicket到UDB查询用户信息
            //Result = _UDBMBoss.AccountInfoQuery(UDBSPID, UDBSPID, UDBTicket, UDBKey, out accountInfo, out ErrMsg);
            if ("0".Equals(result) && !String.IsNullOrEmpty(accessToken))
            {
                string p_version    = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion; //System.Configuration.ConfigurationManager.AppSettings["unifyPlatform_version"];
                string p_clientType = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType;
                Result = _UDBMBoss.UnifyPlatformGetUserInfo(unifyPlatform_appId, unifyPlatform_appSecretKey, p_version, p_clientType, accessToken, clientIp, clientAgent, out accountInfo, out ErrMsg);
            }

            strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);

            if ("0".Equals(result) && Result == 0)   // 认证成功 并且根据accesstoken查客户信息成功
            {
                String CustID, OuterID, Status, CustType, CustLevel, RealName, UserName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                //检测对应用户是否在号百系统,不在,则注册进来
                strMsg.Append("【开始注册到号百】:");
                CustID = String.Empty;

                Regex regMobile = new Regex(@"^1[345678]\d{9}$");
                Regex regEmail  = new Regex(@"^[0-9a-zA-Z_\-\.]*[0-9a-zA-Z_\-]@[0-9a-zA-Z]+\.+[0-9a-zA-Z_\-.]+$");
                Regex regCard   = new Regex(@"^(\d{9}|\d{16})$");

                string AuthenType = "1";
                strMsg.AppendFormat("accountInfo.username:{0}\r\n", accountInfo.userName);
                strMsg.AppendFormat("acountInfo.userId:{0},accountInfo.pUserId:{1}\r\n", accountInfo.userId, accountInfo.pUserId);
                if (regMobile.IsMatch(accountInfo.userName))
                {
                    AuthenType = "2";
                }
                if (regEmail.IsMatch(accountInfo.userName))
                {
                    AuthenType = "4";
                }
                if (regCard.IsMatch(accountInfo.userName))
                {
                    AuthenType = "3";
                }

                if ("2".Equals(AuthenType))
                {
                    //Result = UserRegistry.getUserRegistryUnifyPlatform(accountInfo, out CustID, out ErrMsg);
                    String OperType = "1"; // 注册
                    String Password = "";  // 从综合平台注册过来,密码是不知道的
                    RealName = "";
                    Result   = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", accountInfo.mobileName,
                                                                      accountInfo.emailName, RealName, Password, accountInfo.userId, SPID, OperType, out CustID, out ErrMsg);
                }
                else
                {
                    Result = -7766;
                }

                //Result = UserRegistry.getUserRegistryUnifyPlatform(accountInfo, out CustID, out ErrMsg);

                strMsg.AppendFormat("Result:{0},CustID:{1}\r\n", Result, CustID);
                strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                //注册成功
                if (Result == 0)
                {
                    Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
                                                       out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
                                                       out AreaID, out RegistrationSource);
                    strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                    if (Result != 0)
                    {
                        strMsg.Append(",ErrMsg:客户不存在" + CustID);
                        //客户不存在
                        Redirect("ErrMsg", "客户不存在");
                    }

                    ////登录tab写入cookie
                    //PageUtility.SetCookie("LoginTabCookie", "UDBTab", 8760);

                    strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                    //生成Ticket
                    ticket = CommonBizRules.CreateTicket();
                    Result = CIPTicketManager.insertCIPTicket(ticket, SPID, CustID, RealName, UserName, NickName, OuterID, "UDBTicket", Convert.ToString(accountInfo.userId), UDBBusiness.ConvertAuthenType(Convert.ToString(accountInfo.userType)), out ErrMsg);
                    strMsg.AppendFormat("【生成ticket】:Result:{0},Ticket:{1}", Result, ticket);
                    strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                    if (Result != 0)
                    {
                        strMsg.Append(",ErrMsg:Ticket生成失败" + ticket);
                        Redirect("ErrMsg", "Ticket生成失败");
                    }
                    strMsg.Append(",Message:生成ticket成功,返回业务系统\r\n");
                    ReturnUrl = Request["ReturnUrl"];
                    strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl);
                    strMsg.AppendFormat("Response.Redirect to {0}\r\n", ReturnUrl);

                    //埋综合平台token 6.1 add
                    //String UnifyPlatformCookieName = ConfigurationManager.AppSettings["UnifyPlatformCookieName"];
                    //string AuthenName = UserName;
                    //AuthenType = "2";
                    //SPInfoManager spInfo = new SPInfoManager();
                    //Object SPData = spInfo.GetSPData(this.Context, "SPData");
                    //string key = spInfo.GetPropertyBySPID("35000000", "SecretKey", SPData);
                    //UserToken UT = new UserToken();
                    //string UserTokenValue = UT.GenerateUserToken(CustID, RealName, UserName, NickName, OuterID, CustType, AuthenName, AuthenType, key, out ErrMsg);
                    //string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
                    //PageUtility.SetCookie(UserTokenValue, UnifyPlatformCookieName, this.Page);
                    //埋综合平台token 6.1 end
                }
                else
                {
                    strMsg.Append(",ErrMsg:用户注册到号百失败");
                    Redirect("ErrMsg", "用户注册到号百失败" + ErrMsg);
                }
            }
            else
            {
                strMsg.Append(",ErrMsg:查询用户信息失败");
                Redirect("ErrMsg", "查询用户信息失败");
            }

            #endregion
        }
        catch (Exception ex)
        {
            strMsg.AppendFormat(",ErrMsg:{0}", ex.Message);
        }
        finally
        {
            WriteLog(strMsg.ToString());
        }
    }
Пример #4
0
    public String RegisterInLowstingHttp(String SPID, String UserName, String PassWord, String PassWord2, String Device, String ShareCode, String wt)
    {
        StringBuilder ResponseMsg = new StringBuilder();

        #region 数据校验
        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(UserName))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "996");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "UserName不能为空!");
                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>", "UserName不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        if (CommonUtility.IsEmpty(AuthenCode))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "AuthenCode不能为空!");
                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>", "AuthenCode不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }
        String t_CustID = String.Empty;
        String msg      = String.Empty;
        int    k        = PhoneBO.SelSendSMSMassage(t_CustID, UserName, AuthenCode, out msg);
        if (k != 0)
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998");
                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>", "998");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "验证码不正确!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }


        String regMobile = @"^1[345678]\d{9}$";
        //String regEmail = @"^[0-9a-zA-Z_\-\.]*[0-9a-zA-Z_\-]@[0-9a-zA-Z]+\.+[0-9a-zA-Z_\-.]+$";
        //String RegularUserName = @"^[a-zA-Z][a-zA-Z0-9]*([-._]?[a-zA-Z0-9]+)*$";
        if (!ValidateUserName(UserName, regMobile))
        //if (!ValidateUserName(UserName, RegularUserName))
        {
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "991");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "UserName只能是手机号码!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "991");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "UserName只能是手机号码!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        if (CommonUtility.IsEmpty(PassWord))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "PassWord不能为空!");
                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>", "PassWord不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }


        if (CommonUtility.IsEmpty(PassWord2))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "PassWord2不能为空!");
                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>", "PassWord2不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        if (!PassWord.Equals(PassWord2))
        {
            // 返回错误信息
            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());
        }

        #endregion

        String appId       = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId;
        String appSecret   = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret;
        String version     = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion;
        String clientType  = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType;
        String clientIp    = HttpContext.Current.Request.UserHostAddress;
        String clientAgent = HttpContext.Current.Request.UserAgent;
        String sendSms     = UDBConstDefinition.DefaultInstance.UnifyPlatformRegisterAccountSendSms;
        if (String.IsNullOrEmpty(sendSms))
        {
            sendSms = "false";
        }

        //综合平台隐式注册只支持手机,也就是说,用户名模式,放弃注册为天翼账号,仅注册为号百用户
        //既有用户名又有手机的,放弃注册天翼账号
        String Unify_ErrMsg = String.Empty;
        String userId       = String.Empty;
        String o_userName   = String.Empty;
        String accessToken  = String.Empty;
        //msg.AppendFormat("注册天翼账号:\r\n");
        int Unify_Result = CIP2BizRules.RegisterUnifyPlatformAccount(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, PassWord, sendSms, out userId, out o_userName, out accessToken, out Unify_ErrMsg);
        //msg.AppendFormat("注册天翼账号,Result:{0},accessToken:{1},userId:{2},usrName:{3},ErrMsg:{4}\r\n", Unify_Result, accessToken, userId, o_userName, Unify_ErrMsg);


        if (Unify_Result == 0 && !String.IsNullOrEmpty(userId) && !String.IsNullOrEmpty(accessToken))
        {
            //Result = UserRegistry.UserRegisterWebLowStintV3(SPID, UserName, PassWord, Device, ShareCode, out CustID, out ErrMsg);
            UDBMBOSS         _UDBMBoss   = new UDBMBOSS();
            UnifyAccountInfo accountInfo = new UnifyAccountInfo();
            Unify_Result = _UDBMBoss.UnifyPlatformGetUserInfo(appId, appSecret, version, clientType, accessToken, clientIp, clientAgent, out accountInfo, out Unify_ErrMsg);
            String OuterID, Status, CustType, CustLevel, NickName, Email, CertificateCode, CertificateType, Sex, RealName, EnterpriseID, ProvinceID, AreaID, RegistrationSource;

            if (Unify_Result == 0 && !String.IsNullOrEmpty(Convert.ToString(accountInfo.userId)))
            {
                String MobileName = String.Empty;
                String EmailName  = String.Empty;
                if (!String.IsNullOrEmpty(accountInfo.nickName))
                {
                    RealName = accountInfo.nickName;
                }
                else if (!String.IsNullOrEmpty(accountInfo.userName))
                {
                    RealName = accountInfo.userName;
                }
                else if (!String.IsNullOrEmpty(accountInfo.mobileName))
                {
                    RealName = accountInfo.mobileName;
                }
                else if (!String.IsNullOrEmpty(accountInfo.emailName))
                {
                    RealName = accountInfo.emailName;
                }
                else
                {
                    RealName = "";
                }
                if (!String.IsNullOrEmpty(accountInfo.mobileName))
                {
                    MobileName = accountInfo.mobileName;
                }
                if (!String.IsNullOrEmpty(accountInfo.emailName))
                {
                    EmailName = accountInfo.emailName;
                }
                String EncrytpPassWord = CryptographyUtil.Encrypt(PassWord);
                String OperType        = "2"; // 注册 ,

                if (!String.IsNullOrEmpty(MobileName) || !String.IsNullOrEmpty(EmailName))
                {
                    CustID = String.Empty;

                    Result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", MobileName, EmailName, RealName, EncrytpPassWord, accountInfo.userId, SPID, OperType, out CustID, out ErrMsg);

                    if (Result == 0 && !String.IsNullOrEmpty(CustID))
                    {
                        Result = CustBasicInfo.getCustInfo(SPID, CustID, out ErrMsg, out OuterID, out Status, out CustType, out CustLevel, out RealName,
                                                           out UserName, out NickName, out CertificateCode, out CertificateType, out Sex, out Email, out EnterpriseID, out ProvinceID,
                                                           out AreaID, out RegistrationSource);
                        CommonBizRules.WriteTraceIpLog(CustID, UserName, SPID, Request.UserHostAddress.ToString(), "client_zc");

                        String youhuiquan_url = "http://www.114yg.cn/facadeHome.do?actions=facadeHome&method=sendCouponToShare&wt=json&from=" + Device + "&registerCustId=" + CustID;
                        String jsonmsg        = HttpMethods.HttpGet(youhuiquan_url);
                        System.Collections.Generic.Dictionary <string, string> resuzt = Newtonsoft.Json.JsonConvert.DeserializeObject <System.Collections.Generic.Dictionary <string, string> >(jsonmsg);
                        //{"returnCode":"00000"}
                        string youhuiquan = "";
                        resuzt.TryGetValue("returnCode", out youhuiquan);
                        ResponseMsg.Length = 0;
                        if ("json".Equals(wt))
                        {
                            ResponseMsg.Append("{");
                            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "0");
                            ResponseMsg.AppendFormat("\"CustID\":\"{0}\",", CustID);
                            ResponseMsg.AppendFormat("\"returnCode\":\"{0}\",", youhuiquan);
                            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "注册成功!");
                            ResponseMsg.Append("}");
                        }
                        else
                        {
                            ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                            ResponseMsg.Append("<PayPlatRequestParameter>");
                            ResponseMsg.Append("<PARAMETERS>");
                            ResponseMsg.AppendFormat("<CustID>{0}</CustID>", CustID);
                            ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "0");
                            ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "注册成功!");
                            ResponseMsg.Append("</PARAMETERS>");
                            ResponseMsg.Append("</PayPlatRequestParameter>");
                        }
                        return(ResponseMsg.ToString());
                    }
                }
                else
                {
                    ResponseMsg.Length = 0;
                    if ("json".Equals(wt))
                    {
                        ResponseMsg.Append("{");
                        ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-11");
                        ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "MobileName或EmailName为空不能注册天翼账号所以号百注册也失败!");
                        ResponseMsg.Append("}");
                    }
                    else
                    {
                        ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                        ResponseMsg.Append("<PayPlatRequestParameter>");
                        ResponseMsg.Append("<PARAMETERS>");
                        ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "-11");
                        ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "MobileName或EmailName为空不能注册天翼账号所以号百注册也失败!!");
                        ResponseMsg.Append("</PARAMETERS>");
                        ResponseMsg.Append("</PayPlatRequestParameter>");
                    }
                    return(ResponseMsg.ToString());
                }
                //http://www.114yg.cn/facadeHome.do?actions=facadeHome&method=sendCouponToShare&wt=json&from=ios&registerCustId=134664179
                //"http://116.228.55.13:8113/facadeHome.do?actions=facadeHome&method=sendCouponToShare&wt=json&from=ios&registerCustId=
            }
            else
            {
                ResponseMsg.Length = 0;
                if ("json".Equals(wt))
                {
                    ResponseMsg.Append("{");
                    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-10");
                    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>", "-10");
                    ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "号百账号注册失败!");
                    ResponseMsg.Append("</PARAMETERS>");
                    ResponseMsg.Append("</PayPlatRequestParameter>");
                }
                return(ResponseMsg.ToString());
            }
        }
        else
        {
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-10");
                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>", "-10");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "天翼账号注册失败!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }
        return(ResponseMsg.ToString());
    }
Пример #5
0
    public String GetUserInfo(String SPID, String AccessToken)
    {
        StringBuilder strMsg      = new StringBuilder();
        StringBuilder ResponseMsg = new StringBuilder();

        Result = ErrorDefinition.IError_Result_UnknowError_Code;
        ErrMsg = ErrorDefinition.IError_Result_UnknowError_Msg;
        strMsg.AppendFormat("接收参数 SPID:{0},AccessToken:{1}\r\n", SPID, AccessToken);

        #region 数据校验
        if (CommonUtility.IsEmpty(SPID))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!");
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }

        if (CommonUtility.IsEmpty(AccessToken))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "AccessToken不能为空!");
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }


        #endregion

        String appId       = String.Empty;
        String appSecret   = String.Empty;
        String version     = String.Empty;
        String clientType  = String.Empty;
        String clientIp    = String.Empty;
        String clientAgent = String.Empty;
        #region

        try
        {
            try
            {
                appId       = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId;
                appSecret   = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret;
                version     = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion;
                clientType  = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType;
                clientIp    = HttpContext.Current.Request.UserHostAddress;
                clientAgent = HttpContext.Current.Request.UserAgent;
                strMsg.AppendFormat("获取综合平台接入参数:appId:{0},appSecret:{1},version:{2},clientType:{3},clientIp:{4},clientAgent:{5}\r\n", appId, appSecret, version, clientType, clientIp, clientAgent);
            }
            catch (Exception e)
            {
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "获取综合平台参数异常:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }

            UnifyAccountInfo accountInfo = new UnifyAccountInfo();
            try
            {
                UDBMBOSS _UDBMBoss = new UDBMBOSS();
                Result = _UDBMBoss.UnifyPlatformGetUserInfo(appId, appSecret, version, clientType, AccessToken, clientIp, clientAgent, out accountInfo, out ErrMsg);
                strMsg.AppendFormat("根据accesstoken去综合平台查询结果,Result:{0},ErrMsg{1}\r\n", Result, ErrMsg);
                if (accountInfo != null)
                {
                    strMsg.AppendFormat("account.userId:{0},accountInfo.userName:{1},accountInfo.province:{2},accountInfo.city:{3},accountInfo.mobileName:{4},accountInfo.emailName:{5},accountInfo.gender:{6}\r\n", accountInfo.userId, accountInfo.userName, accountInfo.province, accountInfo.city, accountInfo.mobileName, accountInfo.emailName, accountInfo.gender);

                    ResponseMsg.Length = 0;
                    ResponseMsg.Append("{");
                    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "0");
                    ResponseMsg.AppendFormat("\"userName\":\"{0}\",", accountInfo.userName);
                    ResponseMsg.AppendFormat("\"userId\":\"{0}\",", accountInfo.userId);
                    ResponseMsg.AppendFormat("\"nickname\":\"{0}\",", accountInfo.nickName);
                    ResponseMsg.AppendFormat("\"gender\":\"{0}\",", accountInfo.gender);
                    ResponseMsg.AppendFormat("\"birthday\":\"{0}\",", accountInfo.birthday);
                    ResponseMsg.AppendFormat("\"province\":\"{0}\",", accountInfo.province);
                    ResponseMsg.AppendFormat("\"city\":\"{0}\",", accountInfo.city);
                    ResponseMsg.AppendFormat("\"address\":\"{0}\",", accountInfo.address);
                    ResponseMsg.AppendFormat("\"mail\":\"{0}\",", accountInfo.mail);
                    ResponseMsg.AppendFormat("\"qq\":\"{0}\",", accountInfo.qq);
                    ResponseMsg.AppendFormat("\"position\":\"{0}\",", accountInfo.position);
                    ResponseMsg.AppendFormat("\"intro\":\"{0}\",", accountInfo.intro);
                    ResponseMsg.AppendFormat("\"photo\":\"{0}\",", accountInfo.userIconUrl1);
                    ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "");
                    ResponseMsg.Append("}");
                    return(ResponseMsg.ToString());
                }
            }
            catch (Exception e)
            {
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "根据accesstoken去综合平台查询:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }
        }
        catch (Exception ex)
        {
            strMsg.AppendFormat("ex:{0}\r\n", ex.ToString());
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", ":" + ex.ToString());
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }
        finally
        {
            log(strMsg.ToString());
        }
        #endregion
        return(ResponseMsg.ToString());
    }
Пример #6
0
    public String UpdateUserInfo(String SPID, String AccessToken, UnifyAccountInfo accountInfo)
    {
        StringBuilder strLog      = new StringBuilder();
        StringBuilder ResponseMsg = new StringBuilder();

        Result = ErrorDefinition.IError_Result_UnknowError_Code;
        ErrMsg = ErrorDefinition.IError_Result_UnknowError_Msg;
        strLog.AppendFormat("接收参数 SPID:{0},gender:{1},birthday:{2},province:{3},city:{4},address:{5},mail:{6},qq:{7},position:{8},intro:{9},nickname:{10}\r\n",
                            SPID, accountInfo.gender,
                            accountInfo.birthday, accountInfo.province, accountInfo.city,
                            accountInfo.address, accountInfo.mail, accountInfo.qq, accountInfo.position, accountInfo.intro,
                            accountInfo.nickName);

        #region  数据校验
        if (CommonUtility.IsEmpty(SPID))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!");
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }

        if (CommonUtility.IsEmpty(AccessToken))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "AccessToken不能为空!");
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }

        #endregion

        String appId       = String.Empty;
        String appSecret   = String.Empty;
        String version     = String.Empty;
        String clientType  = String.Empty;
        String clientIp    = String.Empty;
        String clientAgent = String.Empty;

        try
        {
            try
            {
                appId       = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId;
                appSecret   = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret;
                version     = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion;
                clientType  = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType;
                clientIp    = HttpContext.Current.Request.UserHostAddress;
                clientAgent = HttpContext.Current.Request.UserAgent;
                strLog.AppendFormat("获取综合平台接入参数:appId:{0},appSecret:{1},version:{2},clientType:{3},clientIp:{4},clientAgent:{5}\r\n", appId, appSecret, version, clientType, clientIp, clientAgent);
            }
            catch (Exception e)
            {
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "获取综合平台参数异常:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }


            try
            {
                UDBMBOSS _UDBMBoss = new UDBMBOSS();
                Result = _UDBMBoss.UnifyPlatformUpdateUserInfo(appId, appSecret, version, clientType, AccessToken, clientIp, clientAgent, accountInfo, out ErrMsg);

                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", Result);
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", ":" + ErrMsg);
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }
            catch (Exception e)
            {
                strLog.AppendFormat("ex:{0}\r\n", e.ToString());
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "修改信息失败:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }
        }
        catch (Exception ex)
        {
            strLog.AppendFormat("ex:{0}\r\n", ex.ToString());
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "修改信息失败:" + ex.ToString());
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }
        finally
        {
            log(strLog.ToString());
        }
        return(ResponseMsg.ToString());
    }
Пример #7
0
    public String UnifyAccountBinding(String SPID, String CustID, String AccessToken, String OperType)
    {
        StringBuilder strLog      = new StringBuilder();
        StringBuilder ResponseMsg = new StringBuilder();

        Result = ErrorDefinition.IError_Result_UnknowError_Code;
        ErrMsg = ErrorDefinition.IError_Result_UnknowError_Msg;

        strLog.AppendFormat("接收参数 SPID:{0},CustID:{1},AccessToken:{2},OperType:{3}\r\n", SPID, CustID, AccessToken, OperType);

        #region 数据校验
        if (CommonUtility.IsEmpty(SPID))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!");
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }


        if (CommonUtility.IsEmpty(AccessToken))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "996");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "AccessToken不能为空!");
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }


        if (CommonUtility.IsEmpty(OperType))
        {
            // 返回错误信息
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "OperType不能为空!");
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }
        #endregion

        String appId       = String.Empty;
        String appSecret   = String.Empty;
        String version     = String.Empty;
        String clientType  = String.Empty;
        String clientIp    = String.Empty;
        String clientAgent = String.Empty;


        try
        {
            try
            {
                appId       = UDBConstDefinition.DefaultInstance.UnifyPlatformAppId;
                appSecret   = UDBConstDefinition.DefaultInstance.UnifyPlatformAppSecret;
                version     = UDBConstDefinition.DefaultInstance.UnifyPlatformVersion;
                clientType  = UDBConstDefinition.DefaultInstance.UnifyPlatformClientType;
                clientIp    = HttpContext.Current.Request.UserHostAddress;
                clientAgent = HttpContext.Current.Request.UserAgent;
                strLog.AppendFormat("获取综合平台接入参数:appId:{0},appSecret:{1},version:{2},clientType:{3},clientIp:{4},clientAgent:{5}\r\n", appId, appSecret, version, clientType, clientIp, clientAgent);
            }
            catch (Exception e)
            {
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "998");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "获取综合平台参数异常:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }

            UnifyAccountInfo accountInfo = new UnifyAccountInfo();
            strLog.Append("根据accesstoken去综合平台查询\r\n");

            try
            {
                UDBMBOSS _UDBMBoss = new UDBMBOSS();
                Result = _UDBMBoss.UnifyPlatformGetUserInfo(appId, appSecret, version, clientType, AccessToken, clientIp, clientAgent, out accountInfo, out ErrMsg);
                strLog.AppendFormat("根据accesstoken去综合平台查询结果,Result:{0},ErrMsg{1}\r\n", Result, ErrMsg);
                if (accountInfo != null)
                {
                    strLog.AppendFormat("account.userId:{0},accountInfo.userName:{1},accountInfo.province:{2},accountInfo.city:{3},accountInfo.mobileName:{4},accountInfo.emailName:{5},accountInfo.gender:{6}\r\n", accountInfo.userId, accountInfo.userName, accountInfo.province, accountInfo.city, accountInfo.mobileName, accountInfo.emailName, accountInfo.gender);
                }
            }
            catch (Exception e)
            {
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "根据accesstoken去综合平台查询:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }

            strLog.Append("建立绑定关系\r\n");
            try
            {
                if (Result == 0 && accountInfo != null && !String.IsNullOrEmpty(Convert.ToString(accountInfo.userId)))
                {
                    Result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", accountInfo.mobileName,
                                                                    accountInfo.emailName, accountInfo.nickName, "", accountInfo.userId, SPID, OperType, out CustID, out ErrMsg);
                    strLog.AppendFormat("绑定结果Result:{0},Errmsg:{1}\r\n", Result, ErrMsg);

                    ResponseMsg.Append("{");
                    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", Result);
                    ResponseMsg.AppendFormat("\"errmsg\":\"{0}\",", ErrMsg);
                    ResponseMsg.AppendFormat("\"CustID\":\"{0}\",", CustID);
                    ResponseMsg.AppendFormat("\"UserID\":\"{0}\"", accountInfo.userId);
                    ResponseMsg.Append("}");
                    strLog.AppendFormat("返回json:{0}\r\n", ResponseMsg.ToString());
                }
            }
            catch (Exception e)
            {
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "1000");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "建立绑定关系失败:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }
        }
        catch (Exception ex)
        {
            strLog.AppendFormat("ex:{0}\r\n", ex.ToString());
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", ":" + ex.ToString());
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }
        finally
        {
            log(strLog.ToString());
        }
        return(ResponseMsg.ToString());
    }