Ejemplo n.º 1
0
        /// <summary>
        /// 5.1.3	��¼��֤�ӿ�
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="appSecret"></param>
        /// <param name="version"></param>
        /// <param name="clientType"></param>
        /// <param name="clientIp"></param>
        /// <param name="clientAgent"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="account"></param>
        /// <param name="accessToken"></param>
        /// <param name="expiresIn"></param>
        /// <param name="result"></param>
        /// <param name="msg"></param>
        public void UnifyPlatformUserAuth(String appId, String appSecret, String version, String clientType, String clientIp, String clientAgent, String userName, String password, out UnifyAccountInfo account, out String accessToken, out string loginNum, out long expiresIn, out int result, out String msg)
        {
            StringBuilder strMsg = new StringBuilder();
            String jsonResult = String.Empty;
            string sign = String.Empty;
            expiresIn = 0;
            result = -1;
            loginNum = String.Empty;
            accessToken = String.Empty;
            msg = String.Empty;
            account = new UnifyAccountInfo();
            try
            {
                #region
                string paras = String.Empty;
                string format = "json";
                string parameters = "userName="******"&password="******"&clientIp=" + clientIp + "&clientAgent=" + clientAgent;
                strMsg.AppendFormat("parameters:={0}\r\n", parameters);
                paras = CryptographyUtil.XXTeaEncrypt(parameters, appSecret);
                strMsg.AppendFormat("paras:={0}\r\n", paras);
                sign = CryptographyUtil.HMAC_SHA1(appId + clientType + format + version + paras, appSecret);
                strMsg.AppendFormat("sign:={0}\r\n", sign);
                NameValueCollection postData = new NameValueCollection();
                postData.Add("appId", appId);
                postData.Add("version", version);
                postData.Add("clientType", clientType);
                postData.Add("paras", paras);
                postData.Add("sign", sign);
                postData.Add("format", format);

                WebClient webclient = new WebClient();
                webclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//��ȡPOST��ʽ����ӵ�header�������ΪGET��ʽ�Ļ���ȥ����仰����
                byte[] responseData = webclient.UploadValues(UDBConstDefinition.DefaultInstance.UnifyPlatformLoginUrl, "POST", postData);
                jsonResult = System.Text.Encoding.UTF8.GetString(responseData);
                strMsg.AppendFormat("jsonResult:{0}\r\n", jsonResult);
                #endregion
                Dictionary<string, string> result_dic = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonResult);
                String strResult = String.Empty;
                String strExpiresIn = String.Empty;

                result_dic.TryGetValue("result", out strResult);
                result_dic.TryGetValue("expiresIn", out strExpiresIn);
                if (!String.IsNullOrEmpty(strResult))
                {
                    result = Convert.ToInt32(strResult);
                }
                if (!String.IsNullOrEmpty(strExpiresIn))
                {
                    expiresIn = Convert.ToInt64(strExpiresIn);
                }
                String userId = String.Empty;

                result_dic.TryGetValue("msg", out msg);
                result_dic.TryGetValue("userId", out userId);
                result_dic.TryGetValue("accessToken", out accessToken);
                result_dic.TryGetValue("loginNum", out loginNum);
                String o_UserName = String.Empty;
                String zhUserName = String.Empty;
                String pUserId = String.Empty;
                String productUid = String.Empty;
                String userType = String.Empty;
                String status = String.Empty;
                String aliasName = String.Empty;
                String provinceId = String.Empty;
                String cityId = String.Empty;

                result_dic.TryGetValue("userName", out o_UserName);
                result_dic.TryGetValue("zhUserName", out zhUserName);
                result_dic.TryGetValue("pUserId", out pUserId);
                result_dic.TryGetValue("productUid", out productUid);
                result_dic.TryGetValue("userType", out userType);
                result_dic.TryGetValue("status", out status);
                result_dic.TryGetValue("aliasName", out aliasName);
                result_dic.TryGetValue("provinceId", out provinceId);
                result_dic.TryGetValue("cityId", out cityId);

                account.userName = o_UserName;
                account.zhUserName = zhUserName;
                account.pUserId = pUserId;
                account.productUid = productUid;
                try {
                    account.userId = Convert.ToInt64(userId);
                    account.userType = Convert.ToInt16(userType);
                    account.status = Convert.ToInt16(status);
                }catch(Exception et)
                {
                    strMsg.Append(et.ToString());
                }
                account.aliasName = aliasName;
                account.province = provinceId;
                account.city = cityId;
            }
            catch (Exception e)
            {
                strMsg.AppendFormat("�쳣:{0}\r\n", e.ToString());
            }
            finally
            {
                WriteLog(strMsg.ToString(), "UnifyPlatformUserAuth");
            }
        }
Ejemplo n.º 2
0
        public Int32 UnifyPlatformLoginByImsi(String appId, String appSecret, String version, String clientType, String imsi, String clientIp, String clientAgent, out UnifyAccountInfo accountInfo, out String loginNum, out String accessToken, out long expiresIn,out String ErrMsg)
        {
            Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            accountInfo = new UnifyAccountInfo();
            loginNum = String.Empty;
            accessToken = String.Empty;
            expiresIn = 0;

            StringBuilder strMsg = new StringBuilder();
            strMsg.AppendFormat("ʱ��:{0}\r\n",DateTime.Now.ToString("u"));
            strMsg.AppendFormat("����,appId:{0},appSecret:{1},version:{2},clientType:{3},imsi:{4},clientIp:{5},clientAgent:{6}\r\n",appId,appSecret,version,clientType,imsi,clientIp,clientAgent);
            String jsonResult = String.Empty;
            string sign = String.Empty;
            try
            {

                #region
                string paras = String.Empty;
                string format = "json";
                string parameters = "imsi=" + imsi + "&clientIp=" + clientIp + "&clientAgent=" + clientAgent;
                strMsg.AppendFormat("parameters:={0}\r\n", parameters);
                paras = CryptographyUtil.XXTeaEncrypt(parameters, appSecret);
                strMsg.AppendFormat("paras:={0}\r\n", paras);
                sign = CryptographyUtil.HMAC_SHA1(appId + clientType + format + version + paras, appSecret);
                strMsg.AppendFormat("sign:={0}\r\n", sign);
                NameValueCollection postData = new NameValueCollection();
                postData.Add("appId", appId);
                postData.Add("version", version);
                postData.Add("clientType", clientType);
                postData.Add("paras", paras);
                postData.Add("sign", sign);
                postData.Add("format", format);

                WebClient webclient = new WebClient();
                webclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//��ȡPOST��ʽ����ӵ�header�������ΪGET��ʽ�Ļ���ȥ����仰����
                byte[] responseData = webclient.UploadValues(UDBConstDefinition.DefaultInstance.UnifyPlatformLoginByIMSIUrl, "POST", postData);
                jsonResult = System.Text.Encoding.UTF8.GetString(responseData);
                strMsg.AppendFormat("jsonResult:{0}\r\n", jsonResult);
                #endregion

                Dictionary<string, string> result_dic = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonResult);

                long userId = 0;//    Long 18
                String strUserId = String.Empty;
                String pUserId = String.Empty;//  String 12  UDB �˺ŵ�ID
                String productUid = String.Empty;// String 30  �����˺�ԭuserId  ����Ϊ�� ��appId�й�
                int userType = 0;//  Integer 4   �˺�����  ��δʹ��
                String strUserType = String.Empty;
                int status = 0;// Integer 4 �˺�״̬
                String strStatus = String.Empty;
                String userName = String.Empty;// String 30
                String zhUserName = String.Empty;// String 30 �ۺ�ƽ̨UserName
                String mobileName = String.Empty;// String 11 ���ֻ���
                String emailName = String.Empty;// String60 ��������
                String mobileList = String.Empty;// String 300 �󶨵��ֻ����б�  181000001,181....
                String emailList = String.Empty;// String 300 �󶨵������б�
                String aliasName = String.Empty;// String 30  ���ֻ��ű���
                String nickName = String.Empty;// String 30 �dz�
                int gender = 0;// Integer  1 �Ա�
                String strGender = String.Empty;
                String province = String.Empty;//  String 30 ����ʡ
                String city = String.Empty;//  String 60 ������
                String birthday = String.Empty;//  Striing 8   yyyy-MM-dd
                String address = String.Empty;//  String 300 ��ϵ��ַ
                String mail = String.Empty;// String 60  ��ϵ����
                String qq = String.Empty;//  String 50 qq�˺�
                String position = String.Empty;//  String ְλ
                String intro = String.Empty;// String 300 ���˽���
                String userIconUrl1 = String.Empty;//  String 256 �û�ͷ������  150*150
                String userIconUrl2 = String.Empty;//  String 256 �û�ͷ������  50*50
                String msg = String.Empty;//  String 256  ��ȡ������Ϣ
                int result = 0;// Integer 10
                String strResult = String.Empty;

                //ȡֵ
                result_dic.TryGetValue("userId", out strUserId);
                result_dic.TryGetValue("pUserId", out pUserId);
                result_dic.TryGetValue("productUid", out productUid);
                result_dic.TryGetValue("userType", out strUserType);
                result_dic.TryGetValue("status", out strStatus);
                result_dic.TryGetValue("userName", out userName);
                result_dic.TryGetValue("zhUserName", out zhUserName);
                result_dic.TryGetValue("mobileName", out mobileName);
                result_dic.TryGetValue("emailName", out emailName);
                result_dic.TryGetValue("mobileList", out mobileList);
                result_dic.TryGetValue("emailList", out emailList);
                result_dic.TryGetValue("aliasName", out aliasName);
                result_dic.TryGetValue("nickName", out nickName);
                result_dic.TryGetValue("gender", out strGender);
                result_dic.TryGetValue("province", out province);
                result_dic.TryGetValue("city", out city);
                result_dic.TryGetValue("birthday", out birthday);
                result_dic.TryGetValue("address", out address);
                result_dic.TryGetValue("mail", out mail);
                result_dic.TryGetValue("qq", out qq);
                result_dic.TryGetValue("position", out position);
                result_dic.TryGetValue("intro", out intro);
                result_dic.TryGetValue("userIconUrl1", out userIconUrl1);
                result_dic.TryGetValue("userIconUrl2", out userIconUrl2);
                result_dic.TryGetValue("msg", out msg);
                result_dic.TryGetValue("result", out strResult);

                result_dic.TryGetValue("accessToken",out accessToken);
                result_dic.TryGetValue("loginNum",out loginNum);
                string t_exp = String.Empty;
                result_dic.TryGetValue("expiresIn", out t_exp);
                if (!String.IsNullOrEmpty(t_exp))
                {
                    expiresIn = Convert.ToInt64(t_exp);
                }
                if (!String.IsNullOrEmpty(strUserId))
                {
                    userId = Convert.ToInt64(strUserId);
                }
                if (!String.IsNullOrEmpty(strUserType))
                {
                    userType = Convert.ToInt32(strUserType);
                }

                if (!String.IsNullOrEmpty(strStatus))
                {
                    status = Convert.ToInt32(strStatus);
                }

                if (!String.IsNullOrEmpty(strGender))
                {
                    gender = Convert.ToInt32(strGender);
                }
                if (!String.IsNullOrEmpty(strResult))
                {
                    result = Convert.ToInt32(strResult);
                }
                Result = result;
                ErrMsg = msg;
                if (result == 0)
                {
                    accountInfo.address = address;
                    accountInfo.aliasName = aliasName;
                    accountInfo.birthday = birthday;
                    accountInfo.city = city;
                    accountInfo.emailList = emailList;
                    accountInfo.emailName = emailName;
                    accountInfo.gender = gender;
                    accountInfo.intro = intro;
                    accountInfo.mail = mail;
                    accountInfo.mobileList = mobileList;
                    accountInfo.mobileName = mobileName;

                    accountInfo.nickName = nickName;
                    accountInfo.productUid = productUid;
                    accountInfo.province = province;
                    accountInfo.pUserId = pUserId;
                    accountInfo.qq = qq;
                    accountInfo.position = position;

                    accountInfo.status = status;
                    accountInfo.userIconUrl1 = userIconUrl1;
                    accountInfo.userIconUrl2 = userIconUrl2;
                    accountInfo.userId = userId;
                    accountInfo.userName = userName;
                    accountInfo.userType = userType;
                    accountInfo.zhUserName = zhUserName;
                }

            }
            catch (Exception ex)
            {
                ErrMsg += ex.Message;
                strMsg.AppendFormat(",ErrMsg:{0}", ErrMsg);
            }
            finally
            {
                WriteLog(strMsg.ToString(),"UnifyPlatformLoginByImsi");
            }
            return Result;
        }
    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();
    }
Ejemplo n.º 4
0
        /// <summary>
        /// 5.1.10	�޸��û���Ϣ�ӿ�
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="appSecret"></param>
        /// <param name="version"></param>
        /// <param name="clientType"></param>
        /// <param name="accessToken"></param>
        /// <param name="clientIp"></param>
        /// <param name="clientAgent"></param>
        /// <param name="accountInfo"></param>
        /// <param name="ErrMsg"></param>
        /// <returns></returns>
        public Int32 UnifyPlatformUpdateUserInfo(String appId, String appSecret, String version, String clientType, String accessToken, String clientIp, String clientAgent, UnifyAccountInfo accountInfo, out String ErrMsg)
        {
            Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            accountInfo = new UnifyAccountInfo();
            StringBuilder strMsg = new StringBuilder();
            String jsonResult = String.Empty;
            strMsg.AppendFormat("��UnifyPlatformUpdateUserInfo,DateTime:{3}��accessToken:{0},clientIp:{1},clientAgent:{2}\r\n", accessToken, clientIp, clientAgent, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            string sign = String.Empty;

            try
            {
                // get��ʽ
                #region
                //resultJson = HttpMethods.HttpGet(UDBConstDefinition.DefaultInstance.UnifyPlatformGetUserInfoUrl + "?accessToken=" + accessToken + "&clientIp=" + clientIp + "&clientAgent=" + clientAgent );
                //strMsg.AppendFormat("resultJson:{0}", resultJson);
                #endregion
                // ������post��ʽ
                #region
                string paras = String.Empty;
                string format = "json";
                string parameters = "accessToken=" + accessToken + "&gender="+accountInfo.gender
                +  "&birthday="+accountInfo.birthday+"&province="+accountInfo.province+"&city="+accountInfo.city
                + "&address=" + accountInfo.address + "&mail=" + accountInfo.mail + "&qq="+accountInfo.qq
                + "&position=" + accountInfo.position + "&intro=" + accountInfo.intro + "&nickName="+accountInfo.nickName
                +  "&clientIp=" + clientIp + "&clientAgent=" + clientAgent;
                strMsg.AppendFormat("parameters:={0}\r\n", parameters);
                paras = CryptographyUtil.XXTeaEncrypt(parameters, appSecret);
                strMsg.AppendFormat("paras:={0}\r\n", paras);
                sign = CryptographyUtil.HMAC_SHA1(appId + clientType + format + version + paras, appSecret);
                strMsg.AppendFormat("sign:={0}\r\n", sign);
                NameValueCollection postData = new NameValueCollection();
                postData.Add("appId", appId);
                postData.Add("version", version);
                postData.Add("clientType", clientType);
                postData.Add("paras", paras);
                postData.Add("sign", sign);
                postData.Add("format", format);

                WebClient webclient = new WebClient();
                webclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//��ȡPOST��ʽ����ӵ�header�������ΪGET��ʽ�Ļ���ȥ����仰����
                byte[] responseData = webclient.UploadValues(UDBConstDefinition.DefaultInstance.UnifyPlatformUpdateUserInfoUrl, "POST", postData);
                jsonResult = System.Text.Encoding.UTF8.GetString(responseData);
                strMsg.AppendFormat("jsonResult:{0}\r\n", jsonResult);
                #endregion

                Dictionary<string, string> result_dic = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonResult);

                String msg = String.Empty;//  String 256  ��ȡ������Ϣ
                int result = 0;// Integer 10
                String strResult = String.Empty;

                //ȡֵ

                result_dic.TryGetValue("msg", out msg);
                result_dic.TryGetValue("result", out strResult);
                result = Convert.ToInt16(strResult);
                Result = result;
                ErrMsg = msg;
            }
            catch (Exception ex)
            {
                ErrMsg += ex.Message;
                strMsg.AppendFormat(",ErrMsg:{0}", ErrMsg);
            }
            finally
            {
                WriteLog(strMsg.ToString(),"UnifyPlatformUpdateUserInfo");
            }
            return Result;
        }
Ejemplo n.º 5
0
    public UnifyAccountRegisterResult UnifyAccountRegister(string SPID, string phone, string password, string captcha, string ExtendField)
    {
        UnifyAccountRegisterResult Result = new UnifyAccountRegisterResult();
        Result.Result = ErrorDefinition.IError_Result_UnknowError_Code;
        Result.ErrorDescription = "";
        Result.ExtendField = "";
        StringBuilder strLog = new StringBuilder();
        strLog.Append("====================================\r\n");
        strLog.Append("综合平台登录账号显示注册\r\n");
        strLog.AppendFormat("时间:{0}\r\n", DateTime.Now.ToString("u"));
        strLog.AppendFormat("参数:SPID:{0},phone:{1},password:{2},captcha:{3},ExtendField:{4}", SPID, phone, password, captcha, ExtendField);

        try
        {
            #region 数据校验
            if (CommonUtility.IsEmpty(SPID))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrorDescription = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + ",不能为空";
                return Result;
            }

            if (CommonUtility.IsEmpty(password))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrorDescription = "密码" + ",不能为空";
                return Result;
            }

            if (CommonUtility.IsEmpty(phone))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrorDescription = "电话号码" + ",不能为空";
                return Result;
            }

            if (CommonUtility.IsEmpty(captcha))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrorDescription = "手机验证码" + ",不能为空";
                return Result;
            }
            //IP是否允许访问
            Result.Result = CommonBizRules.CheckIPLimit(SPID, HttpContext.Current.Request.UserHostAddress, this.Context, out Result.ErrorDescription);
            if (Result.Result != 0)
            {
                return Result;
            }

            #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;
            strLog.AppendFormat("获取综合平台接入参数:appId:{0},appSecret:{1},version:{2},clientType:{3},clientIp:{4},clientAgent:{5}\r\n", appId, appSecret, version, clientType, clientIp, clientAgent);
            String jsonResult = String.Empty;
            string sign = String.Empty;

            string paras = String.Empty;
            string format = "json";
            string parameters = "userName="******"&password="******"&captcha=" + captcha + "&clientIp=" + clientIp + "&clientAgent=" + clientAgent;
            strLog.AppendFormat("parameters:={0}\r\n", parameters);
            paras = CryptographyUtil.XXTeaEncrypt(parameters, appSecret);
            strLog.AppendFormat("paras:={0}\r\n", paras);
            sign = CryptographyUtil.HMAC_SHA1(appId + clientType + format + version + paras, appSecret);
            strLog.AppendFormat("sign:={0}\r\n", sign);
            System.Collections.Specialized.NameValueCollection postData = new System.Collections.Specialized.NameValueCollection();
            postData.Add("appId", appId);
            postData.Add("version", version);
            postData.Add("clientType", clientType);
            postData.Add("paras", paras);
            postData.Add("sign", sign);
            postData.Add("format", format);

            System.Net.WebClient webclient = new System.Net.WebClient();
            webclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可
            byte[] responseData = webclient.UploadValues(UDBConstDefinition.DefaultInstance.UnifyAccountRegisterUrl, "POST", postData);
            jsonResult = System.Text.Encoding.UTF8.GetString(responseData);
            strLog.AppendFormat("jsonResult:{0}\r\n", jsonResult);
            Dictionary<string, string> result_dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonResult);

            String userName = String.Empty;
            String accessToken = String.Empty;
            String expiresIn = String.Empty;

            String result = String.Empty;
            String msg = String.Empty;
            result_dic.TryGetValue("userName", out userName);
            result_dic.TryGetValue("accessToken", out accessToken);
            result_dic.TryGetValue("expiresIn", out expiresIn);
            result_dic.TryGetValue("msg", out msg);
            result_dic.TryGetValue("result", out result);
            Result.Result = Convert.ToInt64(result);
            Result.ErrorDescription = msg;

            ///////////////////////////////////////////
            if (Result.Result == 0 && !String.IsNullOrEmpty(accessToken))
            {
                strLog.Append("天翼账号注册成功\r\n");
                strLog.Append("处理结果 - " + Result.Result);
                strLog.Append("; 错误描述 - " + Result.ErrorDescription);
                strLog.Append(": SPID - " + Result.SPID);

                strLog.Append("建立天翼账号和号百账号绑定关系!\r\n");
                UDBMBOSS _UDBMBoss = new UDBMBOSS();
                UnifyAccountInfo accountInfo = new UnifyAccountInfo();
                string Unify_ErrMsg = String.Empty;
                int Unify_Result = _UDBMBoss.UnifyPlatformGetUserInfo(appId, appSecret, version, clientType, accessToken, clientIp, clientAgent, out accountInfo, out Unify_ErrMsg);
                strLog.AppendFormat("先查询综合平台返回:Unify_Result:{0},ErrMsg:{1},UserID:{2}\r\n", Unify_Result, Unify_ErrMsg, Convert.ToString(accountInfo.userId));

                if (Unify_Result == 0 && !String.IsNullOrEmpty(Convert.ToString(accountInfo.userId)))
                {
                    strLog.Append("然后开始注册或者绑定号百客户\r\n");

                    #region 开始注册到号百
                    String MobileName = String.Empty;
                    String EmailName = String.Empty;
                    String RealName = String.Empty;

                    if (!String.IsNullOrEmpty(accountInfo.nickName))
                    {
                        RealName = accountInfo.nickName;
                    }

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

                    if (!String.IsNullOrEmpty(accountInfo.mobileName))
                    {
                        MobileName = accountInfo.mobileName;
                    }
                    if (!String.IsNullOrEmpty(accountInfo.emailName))
                    {
                        EmailName = accountInfo.emailName;
                    }
                    String EncrytpPassWord = CryptographyUtil.Encrypt(password);
                    String OperType = "5";  // 接口注册 , 天翼账号注册成功后绑定
                    if (!String.IsNullOrEmpty(MobileName) || !String.IsNullOrEmpty(EmailName))
                    {

                        String OuterID, Status, CustType, CustLevel, NickName, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                        Result.CustID = String.Empty;
                        Result.Result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", MobileName, EmailName, RealName, EncrytpPassWord, accountInfo.userId, SPID, OperType, out Result.CustID, out Result.ErrorDescription);
                        strLog.Append("【开始注册或者绑定到号百的结果】:\r\n");
                        strLog.AppendFormat("Result:{0},CustID:{1},ErrMsg:{2}\r\n", Result.Result, Result.CustID, Result.ErrorDescription);

                        if (Result.Result == 0 && !String.IsNullOrEmpty(Result.CustID))
                        {
                            String UserName = String.Empty;
                            String CertificateCode = String.Empty;
                            String CertificateType = String.Empty;
                            String Sex = String.Empty;
                            Result.Result = CustBasicInfo.getCustInfo(SPID, Result.CustID, out Result.ErrorDescription, 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.Append(" 处理结果 - " + Result.Result);
                            strLog.Append("; 错误描述 - " + Result.ErrorDescription);
                            strLog.Append(": SPID - " + Result.SPID);
                            strLog.Append("; CustID - " + Result.CustID);
                            CommonBizRules.WriteTraceIpLog(Result.CustID, phone, Result.SPID, HttpContext.Current.Request.UserHostAddress.ToString(), "mall_zc");
                            CIP2BizRules.InsertCustInfoNotify(Result.CustID, "2", SPID, "", "0", out Result.ErrorDescription);
                        }
                    }
                    else
                    {
                        Result.Result = -7766;
                        Result.ErrorDescription = "MobileName,或者EmailName为空,所以不注册号百客户";
                        strLog.Append("MobileName,或者EmailName为空,所以不注册号百客户\r\n");
                    }
                    #endregion
                }
                else
                { //查询综合平台客户信息失败,或者account.userid为空
                    strLog.Append("查询综合平台客户信息失败,或者account.userid为空,放弃注册或绑定动作\r\n");
                }
            }
        }
        catch (Exception e)
        {
            Result.Result = -19988;
            Result.ErrorDescription = e.ToString();
            strLog.AppendFormat("系统异常:{0}\r\n",e.ToString());

        }
        finally
        {
            strLog.Append("====================================\r\n");
            BTUCenterInterfaceLog.CenterForBizTourLog("UnifyAccountRegister", strLog);
        }
        return Result;
    }
Ejemplo n.º 6
0
    public UserRegistryV2Result UserRegistryV2(string SPID, string UserType, string CardID, string Password, string UProvinceID, string AreaCode,
                                               string RealName, string UserName, string AuthenPhone, string ContactTel, string IsNeedTourCard,
                                               string CertificateCode, string CertificateType, string Sex, string ExtendField)
    {
        StringBuilder strLog = new StringBuilder();
        UserRegistryV2Result Result = new UserRegistryV2Result();
        strLog.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n\r\n");
        strLog.Append("注册接口(soap)" + DateTime.Now.ToString("u") + "\r\n");
        strLog.Append(";SPID - " + SPID);
        strLog.Append(":UserType - " + UserType);
        strLog.Append(":CardID - " + CardID);
        strLog.Append(":Password - " + Password);
        strLog.Append(":UProvinceID - " + UProvinceID);
        strLog.Append(":AreaCode - " + AreaCode);
        strLog.Append(":RealName - " + RealName);
        strLog.Append(":UserName - " + UserName);
        strLog.Append(":AuthenPhone - " + AuthenPhone);
        strLog.Append(":ContactTel - " + ContactTel);
        strLog.Append(":IsNeedTourCard - " + IsNeedTourCard);
        strLog.Append(":CertificateCode - " + CertificateCode);
        strLog.Append(":CertificateType - " + CertificateType);
        strLog.Append(":Sex - " + Sex);
        strLog.Append(":IP - " + HttpContext.Current.Request.UserHostAddress);
        strLog.Append(";ExtendField - " + ExtendField + "\r\n");

        String PwdType = "";

        Result.SPID = SPID;
        Result.TimeStamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        Result.CustID = "";
        //商旅卡9位
        Result.TourCardID = "";
        Result.Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        Result.ErrMsg = "";
        int Unify_Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
        string Unify_ErrMsg = "";

        //商旅卡16位
        string sCardID = "";
        try
        {

            if (CommonUtility.IsEmpty(SPID))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + "不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            if (SPID.Length != ConstDefinition.Length_SPID)
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + "长度有误";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            //IP是否允许访问
            Result.Result = CommonBizRules.CheckIPLimit(SPID, HttpContext.Current.Request.UserHostAddress, this.Context, out Result.ErrMsg);
            if (Result.Result != 0)
            {
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            //接口访问权限判断
            Result.Result = CommonBizRules.CheckInterfaceLimit(SPID, "UserRegistryV2", this.Context, out Result.ErrMsg);
            if (Result.Result != 0)
            {
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            if (CommonUtility.IsEmpty(Password))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + ",密码不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            if (CommonUtility.IsEmpty(AuthenPhone))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code; ;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + "认证电话不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            //这里有疑问
            if (CommonUtility.IsEmpty(UProvinceID))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + ",不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            //这里有疑问
            if (CommonUtility.IsEmpty(AreaCode))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + ",不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            //这里有疑问
            if (CommonUtility.IsEmpty(RealName))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + ",不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            string phone = "";
            if (!CommonBizRules.PhoneNumValid(this.Context, AuthenPhone, out phone))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidPhoneNum_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidPhoneNum_Msg;
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            if (CommonUtility.IsEmpty(IsNeedTourCard))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + ",不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            if (CommonUtility.IsEmpty(Sex))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + ",不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }
            //注册天翼账号
            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 userId = String.Empty;
            String o_userName = String.Empty;
            String accessToken = String.Empty;
            String host = System.Configuration.ConfigurationManager.AppSettings["host"];
            strLog.AppendFormat("注册天翼账号{0}:\r\n",host);
            Unify_Result = CIP2BizRules.RegisterUnifyPlatformAccount(appId, appSecret, version, clientType, clientIp, clientAgent, AuthenPhone, Password, sendSms, out userId, out o_userName, out accessToken, out Unify_ErrMsg);
            Result.Result = Unify_Result;
            Result.ErrMsg = Unify_ErrMsg;
            strLog.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))
            {
                strLog.Append("天翼账号注册成功\r\n");
                strLog.Append("处理结果 - " + Result.Result);
                strLog.Append("; 错误描述 - " + Result.ErrMsg);
                strLog.Append(": SPID - " + Result.SPID);
                strLog.Append(": TimeStamp - " + Result.TimeStamp);
                strLog.Append("; CustID - " + Result.CustID);
                strLog.Append(": sCardID - " + sCardID);
                strLog.Append(": password - " + Password);
                strLog.Append("; TourCardID - " + Result.TourCardID + "\r\n");

                strLog.Append("建立天翼账号和号百账号绑定关系!\r\n");
                UDBMBOSS _UDBMBoss = new UDBMBOSS();
                UnifyAccountInfo accountInfo = new UnifyAccountInfo();
                Unify_Result = _UDBMBoss.UnifyPlatformGetUserInfo(appId, appSecret, version, clientType, accessToken, clientIp, clientAgent, out accountInfo, out Unify_ErrMsg);
                strLog.AppendFormat("先查询综合平台返回:Unify_Result:{0},ErrMsg:{1},UserID:{2}\r\n", Unify_Result, Unify_ErrMsg, Convert.ToString(accountInfo.userId));

                if (Unify_Result == 0 && !String.IsNullOrEmpty(Convert.ToString(accountInfo.userId)))
                {
                    strLog.Append("然后开始注册或者绑定号百客户\r\n");

                    #region 开始注册到号百
                    String MobileName = String.Empty;
                    String EmailName = String.Empty;
                    if (String.IsNullOrEmpty(RealName) )
                    {
                        if (!String.IsNullOrEmpty(accountInfo.nickName))
                        {
                            RealName = accountInfo.nickName;
                        }

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

                    if (!String.IsNullOrEmpty(accountInfo.mobileName))
                    {
                        MobileName = accountInfo.mobileName;
                    }
                    if (!String.IsNullOrEmpty(accountInfo.emailName))
                    {
                        EmailName = accountInfo.emailName;
                    }
                    String EncrytpPassWord = CryptographyUtil.Encrypt(Password);
                    String OperType = "5";  // 接口注册 , 天翼账号注册成功后绑定
                    if (!String.IsNullOrEmpty(MobileName) || !String.IsNullOrEmpty(EmailName))
                    {

                        String OuterID, Status, CustType, CustLevel, NickName, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                        Result.CustID = String.Empty;

                        Result.Result = CIP2BizRules.BindCustInfoUnifyPlatform(UProvinceID, AreaCode, MobileName, EmailName, RealName, EncrytpPassWord, accountInfo.userId, SPID, OperType, out Result.CustID, out Result.ErrMsg);
                        strLog.Append("【开始注册或者绑定到号百的结果】:\r\n");
                        strLog.AppendFormat("Result:{0},CustID:{1},ErrMsg:{2}\r\n", Result.Result, Result.CustID, Result.ErrMsg);

                        if (Result.Result == 0 && !String.IsNullOrEmpty(Result.CustID))
                        {
                            Result.Result = CustBasicInfo.getCustInfo(SPID, Result.CustID, out Result.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);
                            string TourCardErrorMsg = "";
                            int TourCardResult = -1;
                            if ("0".Equals(IsNeedTourCard))
                            {

                                TourCardResult = UserRegistry.GetTourCard(Result.CustID, CardID, UProvinceID, AreaCode, 1, CustLevel, "01", "1", out Result.TourCardID, out sCardID, out TourCardErrorMsg);
                            }
                            strLog.Append(" 处理结果 - " + Result.Result);
                            strLog.Append("; 错误描述 - " + Result.ErrMsg);
                            strLog.Append(": SPID - " + Result.SPID);
                            strLog.Append(": TimeStamp - " + Result.TimeStamp);
                            strLog.Append("; TourCardResult - " + TourCardResult);
                            strLog.Append("; TourCardErrorMsg - " + TourCardErrorMsg);
                            strLog.Append("; CustID - " + Result.CustID);
                            strLog.Append("; TourCardID - " + Result.TourCardID + "\r\n");
                            CommonBizRules.WriteTraceIpLog(Result.CustID, AuthenPhone, Result.SPID, HttpContext.Current.Request.UserHostAddress.ToString(), "jk_zc");
                            CIP2BizRules.InsertCustInfoNotify(Result.CustID, "2", SPID, "", "0", out Result.ErrMsg);
                        }
                    }
                    else
                    {
                        Result.Result = -7766;
                        Result.ErrMsg = "MobileName,或者EmailName为空,所以不注册号百客户";
                        strLog.Append("MobileName,或者EmailName为空,所以不注册号百客户\r\n");
                    }
                    #endregion
                }
                else
                { //查询综合平台客户信息失败,或者account.userid为空
                    strLog.Append("查询综合平台客户信息失败,或者account.userid为空,放弃注册或绑定动作\r\n");
                }
            }
            else
            {   //51109  && Unify_ErrMsg.Equals("用户名已经存在")   //51224  用户名必须是手机号码或邮箱地址
                //if (Convert.ToString(Unify_Result).Equals("51109") )
                //{
                    strLog.AppendFormat("综合平台注册结果:{0},ErrMsg:{1}\r\n",Unify_Result,Unify_ErrMsg);
                    long t_userId = 0;
                    Result.Result = CIP2BizRules.GetUnifyPlatformUserInfoByName(appId, appSecret, version, clientType, clientIp, clientAgent, AuthenPhone, out t_userId, out Result.ErrMsg);
                    strLog.AppendFormat("GetUnifyPlatformUserInfoByName:Result:{0},ErrMsg:{1},UserID:{2}\r\n",Result.Result,Result.ErrMsg,Convert.ToString(t_userId));
                    if (Result.Result == 0 && t_userId != 0)
                    {
                        string T_CustID = "";
                        strLog.Append("是否已经是号码百事通账户?\r\n");
                        if (!CommonBizRules.HasBesttoneAccount(this.Context, AuthenPhone, out T_CustID, out Result.ErrMsg))
                        {
                            if (!String.IsNullOrEmpty(T_CustID))
                            {
                                strLog.AppendFormat("已经是CustID:{0}这个客户的号码百事通账户,放弃注册,放弃绑定\r\n", T_CustID);
                                Result.Result = ErrorDefinition.BT_IError_Result_InValidPhoneNum_Code;
                                Result.ErrMsg = "该手机号码已经为号码百事通账户!";
                                return Result;
                            }
                            else
                            {
                                strLog.Append("不是号百百事通账户\r\n");
                            }
                        }
                        strLog.Append("开始注册号码百事通登录账号\r\n");
                        Result.Result = UserRegistry.getUserRegistry(SPID, UserType, CardID, Password, UProvinceID, AreaCode, RealName, UserName, AuthenPhone, ContactTel, IsNeedTourCard, CertificateCode, CertificateType, Sex, ExtendField, out Result.ErrMsg, out Result.CustID, out Result.TourCardID, out sCardID);
                        strLog.AppendFormat("注册号码百事通登录账号结果,Result:{0},CustId:{1},ErrMsg:{2}\r\n", Result.Result, Result.CustID, Result.ErrMsg);
                        if (Result.Result == 0 && !String.IsNullOrEmpty(Result.CustID))
                        {
                            String EncrytpPassWord = CryptographyUtil.Encrypt(Password);
                            String OperType = "6";  //天翼账号通过接口注册失败后,号百登录账号注册成功,后绑定成功
                            Result.Result = CIP2BizRules.BindCustInfoUnifyPlatform(UProvinceID, AreaCode, AuthenPhone, "", RealName, EncrytpPassWord, t_userId, SPID, OperType, out Result.CustID, out Result.ErrMsg);
                            strLog.AppendFormat("绑定结果:{0},{1},{2}<->{3}\r\n", Result.Result, Result.ErrMsg, Convert.ToString(t_userId), Result.CustID);

                            CommonBizRules.WriteTraceIpLog(Result.CustID, AuthenPhone, Result.SPID, HttpContext.Current.Request.UserHostAddress.ToString(), "jk_zc");
                            CIP2BizRules.InsertCustInfoNotify(Result.CustID, "2", SPID, "", "0", out Result.ErrMsg);

                        }
                    }
                    else
                    {
                        //非手机,邮箱注册(按道理不应该再让纯用户名的用户注册进来,否则数据导入综合平台又会发生问题,他们不接收纯用户名,但是纯用户名用户语音方式注册这种情况会很多,1天日志查下来大概有20-30笔,)
                        strLog.Append("开始注册号码百事通登录账号,纯用户名\r\n");

                    }
                //}
            }
        }
        catch (Exception e)
        {
            Result.Result = ErrorDefinition.IError_Result_System_UnknowError_Code;
            Result.ErrMsg = ErrorDefinition.IError_Result_System_UnknowError_Msg + e.Message;
            strLog.AppendFormat("异常:{0}\r\n", e.ToString());
        }
        finally
        {
            BTUCenterInterfaceLog.CenterForBizTourLog("UserRegistryV2", strLog);
        }
        return Result;
    }
Ejemplo n.º 7
0
    public LoginByIMSIResult LoginByIMSI(string SPID, string imsi)
    {
        LoginByIMSIResult Result = new LoginByIMSIResult();
        StringBuilder strLog = new StringBuilder();
        strLog.AppendFormat("imsi登录认证,时间:{0}\r\n",DateTime.Now.ToString("u"));
        strLog.AppendFormat("SPID:{0},IMSI:{1}\r\n",SPID,imsi);
        try
        {
            if (CommonUtility.IsEmpty(SPID))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + "不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            if (SPID.Length != ConstDefinition.Length_SPID)
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrMsg = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + "长度有误";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            if (CommonUtility.IsEmpty(imsi))
            {
                Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
                Result.ErrMsg = "imsi号不能为空";
                strLog.Append(Result.ErrMsg + "\r\n");
                return Result;
            }

            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;

            strLog.Append("IMSI登录认证!\r\n");
            UDBMBOSS _UDBMBoss = new UDBMBOSS();
            UnifyAccountInfo accountInfo = new UnifyAccountInfo();
            string Unify_ErrMsg = String.Empty;
            string loginNum = String.Empty;
            string accessToken = String.Empty;
            long expiresIn = 0;
            //                                                                                    appId, appSecret, version, clientType, imsi, clientIp, clientAgent, out accountInfo, out loginNum, out accessToken, out expiresIn,out  ErrMsg
            int Unify_Result = _UDBMBoss.UnifyPlatformLoginByImsi(appId, appSecret, version, clientType,imsi, clientIp, clientAgent, out  Result.unifyAccount,out Result.loginNum,out Result.AccessToken, out Result.expiresIn, out Unify_ErrMsg);
            strLog.AppendFormat("登录认证:Unify_Result:{0},ErrMsg:{1},loginNum:{2},accessToken:{3}\r\n", Unify_Result, Unify_ErrMsg, loginNum,accessToken);
            if (Unify_Result == 0 && Result.unifyAccount != null )
            {
                //增加绑定动作 根据loginnum
                #region
                String CustID, OuterID, Status, CustType, CustLevel, RealName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                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_\-.]+$");
                String MobileName = String.Empty;
                String EmailName = String.Empty;
                RealName = String.Empty;
                if (Result.unifyAccount != null)
                {
                    RealName = Result.unifyAccount.userName;
                }

                if (regMobile.IsMatch(Result.unifyAccount.userName))
                {
                    MobileName = Result.unifyAccount.userName;
                }

                if (regEmail.IsMatch(Result.unifyAccount.userName))
                {
                    EmailName = Result.unifyAccount.userName;
                }
                String EncrytpPassWord = CryptographyUtil.Encrypt("123456");
                String OperType = "2";

                strLog.Append("【开始绑定号百】:\r\n");
                Result.Result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", MobileName, EmailName, RealName, EncrytpPassWord, Result.unifyAccount.userId, SPID, OperType, out Result.CustID, out Result.ErrMsg);
                strLog.Append("【开始绑定到号百的结果】:\r\n");
                strLog.AppendFormat("Result:{0},CustID:{1}<->UserID:{2}ErrMsg:{3}\r\n", Result.Result, CustID, Result.unifyAccount.userId, Result.ErrMsg);
                #endregion

                //保存accessToken
                if (Result.Result == 0 && !String.IsNullOrEmpty(CustID))  //绑定成功
                {
                    Result.CustID = CustID;
                    strLog.Append("绑定成功,记录Accesstoken\r\n");
                    String Description = "接口登录";
                    Result.Result = CIP2BizRules.InsertAccessToken(SPID, HttpContext.Current.Request.UserHostAddress.ToString(), accessToken, Convert.ToString(Result.unifyAccount.userId), CustID, RealName, Result.unifyAccount.nickName, Result.loginNum, OperType, Description, out Result.ErrMsg);
                    strLog.AppendFormat("记录AccessToken结果,Result:{0},CustID:{1}<->AccessToken:{2}\r\n", Result.Result, CustID, accessToken);
                }
                else
                {
                    strLog.Append("绑定失败,无法记录AccessToken,\r\n");
                }
                strLog.AppendFormat("userid:{0}\r\n", Result.unifyAccount.userId);
            }
            else
            {
                strLog.Append("imsi登录失败\r\n");
            }
        }
        catch (Exception e)
        {
            strLog.AppendFormat("异常:{0}\r\n",e.Message);
        }
        finally
        {
            BTUCenterInterfaceLog.CenterForBizTourLog("LoginByIMSIResult", strLog);
        }
        return Result;
    }
Ejemplo n.º 8
0
    public UnifyAccountAuthResult UnifyAccountAuth(String SPID,String UserName,String PassWord,String ExtendField)
    {
        UnifyAccountAuthResult Result = new UnifyAccountAuthResult();
        Result.result = ErrorDefinition.IError_Result_UnknowError_Code;
        Result.msg = ErrorDefinition.IError_Result_UnknowError_Msg;
        String PwdType = "";
        StringBuilder msg = new StringBuilder();
        msg.AppendFormat("SPID:{0},UserName:{1},PassWord:{2},ExtendField:{3}\r\n",SPID,UserName,PassWord,ExtendField);
        #region 数据校验
        if (CommonUtility.IsEmpty(SPID))
        {
            Result.result = ErrorDefinition.BT_IError_Result_InValidSPID_Code;
            Result.msg = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + ",不能为空";
            return Result;
        }

        if (CommonUtility.IsEmpty(UserName))
        {
            Result.result = ErrorDefinition.BT_IError_Result_InValidRealName_Code;
            Result.msg = "用户名不能为空";
            return Result;
        }

        if (!CommonUtility.IsEmpty(ExtendField))
        {
            PwdType = CommonBizRules.GetValueFromXmlStr(ExtendField, "PwdType");

        }

        if (CommonUtility.IsEmpty(PassWord))
        {
            Result.result = ErrorDefinition.BT_IError_Result_InValidRealName_Code;
            Result.msg = "密码不能为空";
            return Result;
        }

        #endregion
        String MobileName = String.Empty;
        String EmailName = String.Empty;
        #region  综合平台认证
        try
        {
            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;
            msg.AppendFormat("获取综合平台接入参数:appkey:{0},appSecret:{1},version:{2},clientType:{3},clientIp:{4},clientAgent:{5}\r\n",appId,appSecret,version,clientType,clientIp,clientAgent);
            if (String.IsNullOrEmpty(appId) || String.IsNullOrEmpty(appSecret) || String.IsNullOrEmpty(version) || String.IsNullOrEmpty(clientType) || String.IsNullOrEmpty(clientAgent))
            {
                Result.result = ErrorDefinition.BT_IError_Result_InValidRealName_Code;
                Result.msg = "综合平台参数获取失败";
                return Result;
            }

            UnifyAccountInfo account = new UnifyAccountInfo();
            String accessToken = String.Empty;
            msg.Append("开始登录天翼账号\r\n");
            Result.result = CIP2BizRules.LoginUnifyPlatform(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, HttpUtility.UrlEncode(PassWord), out  Result.unifyAccountInfo, out  Result.accessToken, out Result.loginNum, out  Result.expiresIn, out  Result.msg);
            msg.AppendFormat("登录天翼账号返回:Result.result:{0},msg:{1},accesstoken:{2},loginnum:{3}\r\n",Result.result,Result.msg,Result.accessToken,Result.loginNum);
            if (Result.unifyAccountInfo != null && !String.IsNullOrEmpty(Result.loginNum))
            {
                //增加绑定动作 根据loginnum
                #region
                String CustID, OuterID, Status, CustType, CustLevel, RealName, NickName, CertificateCode, CertificateType, Sex, Email, EnterpriseID, ProvinceID, AreaID, RegistrationSource;
                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_\-.]+$");

                RealName = Result.loginNum;
                if (regMobile.IsMatch(Result.loginNum))
                {
                    MobileName = Result.loginNum;
                }

                if (regEmail.IsMatch(Result.loginNum))
                {
                    EmailName = Result.loginNum;
                }
                String EncrytpPassWord = CryptographyUtil.Encrypt(PassWord);
                String OperType = "2";

                msg.Append("【开始绑定号百】:\r\n");
                Result.result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", MobileName, EmailName, RealName, EncrytpPassWord, Result.unifyAccountInfo.userId, SPID, OperType, out CustID, out Result.msg);
                msg.Append("【开始绑定到号百的结果】:\r\n");
                msg.AppendFormat("Result:{0},CustID:{1}<->UserID:{2}ErrMsg:{3}\r\n", Result.result, CustID, Result.unifyAccountInfo.userId,Result.msg);
                #endregion

                //保存accessToken
                if (Result.result == 0 && !String.IsNullOrEmpty(CustID))  //绑定成功
                {
                    Result.CustID = CustID;
                    msg.Append("绑定成功,记录Accesstoken\r\n");
                    String Description = "接口登录";
                    //Result.result = CIP2BizRules.InsertAccessToken(SPID, HttpContext.Current.Request.UserHostAddress.ToString(), Result.accessToken, Convert.ToString(Result.unifyAccountInfo.userId), CustID, RealName, Result.unifyAccountInfo.nickName, Result.loginNum, OperType, Description, out Result.msg);
                    Result.result = CIP2BizRules.InsertUnifyAccessToken(SPID, HttpContext.Current.Request.UserHostAddress.ToString(), Result.accessToken, Convert.ToString(Result.unifyAccountInfo.userId), CustID, RealName, Result.unifyAccountInfo.nickName, Result.loginNum,PassWord, OperType, Description, out Result.msg);

                    //InsertUnifyAccessToken
                    msg.AppendFormat("记录AccessToken结果,Result:{0},CustID:{1}<->AccessToken:{2}\r\n",Result.result,CustID,accessToken);
                }
                else
                {
                    msg.Append("绑定失败,无法记录AccessToken,\r\n");
                }
                msg.AppendFormat("userid:{0}\r\n", Result.unifyAccountInfo.userId);
            }
            //else
            //{
                #region 天翼账号认证失败(可能因为同一个号码,天翼账号的密码和本地密码不一致导致,也可能是天翼账号根本不存在)本地数据查询认证
        //                String Unify_deadline = System.Configuration.ConfigurationManager.AppSettings["Unify_deadline"];

                //try
                //{

                //    SqlCommand cmd = new SqlCommand();
                //    cmd.CommandTimeout = 15;
                //    cmd.CommandType = CommandType.StoredProcedure;
                //    cmd.CommandText = "dbo.up_Customer_OV3_Interface_UserAuthV2";

                //    SqlParameter parSPID = new SqlParameter("@SPID", SqlDbType.VarChar, 8);
                //    parSPID.Value = SPID;
                //    cmd.Parameters.Add(parSPID);

                //    SqlParameter parAuthenName = new SqlParameter("@AuthenName", SqlDbType.VarChar, 256);
                //    parAuthenName.Value = UserName;
                //    cmd.Parameters.Add(parAuthenName);

                //    SqlParameter parAuthenType = new SqlParameter("@AuthenType", SqlDbType.VarChar, 2);
                //    parAuthenType.Value = "2";
                //    cmd.Parameters.Add(parAuthenType);

                //    SqlParameter parPwd = new SqlParameter("@Pwd", SqlDbType.VarChar, 100);
                //    parPwd.Value = CryptographyUtil.Encrypt(PassWord);
                //    cmd.Parameters.Add(parPwd);

                //    if (String.IsNullOrEmpty(PwdType))
                //    {
                //        PwdType = "1";
                //    }

                //    SqlParameter parPwdType = new SqlParameter("@PwdType", SqlDbType.VarChar, 100);
                //    parPwdType.Value = PwdType;
                //    cmd.Parameters.Add(parPwdType);

                //    SqlParameter parResult = new SqlParameter("@Result", SqlDbType.Int);
                //    parResult.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parResult);

                //    SqlParameter parErrMsg = new SqlParameter("@ErrMsg ", SqlDbType.VarChar, 256);
                //    parErrMsg.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parErrMsg);

                //    SqlParameter parCustID = new SqlParameter("@CustID ", SqlDbType.VarChar, 16);
                //    parCustID.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parCustID);

                //    SqlParameter parUserAccount = new SqlParameter("@UserAccount ", SqlDbType.VarChar, 16);
                //    parUserAccount.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parUserAccount);

                //    SqlParameter parCustType = new SqlParameter("@CustType ", SqlDbType.VarChar, 2);
                //    parCustType.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parCustType);

                //    SqlParameter parUProvinceID = new SqlParameter("@UProvinceID ", SqlDbType.VarChar, 2);
                //    parUProvinceID.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parUProvinceID);

                //    SqlParameter parSysID = new SqlParameter("@SysID ", SqlDbType.VarChar, 8);
                //    parSysID.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parSysID);

                //    SqlParameter parAreaID = new SqlParameter("@AreaID ", SqlDbType.VarChar, 3);
                //    parAreaID.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parAreaID);

                //    SqlParameter parOuterID = new SqlParameter("@outerid ", SqlDbType.VarChar, 30);
                //    parOuterID.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parOuterID);

                //    SqlParameter parUserName = new SqlParameter("@UserName ", SqlDbType.VarChar, 30);
                //    parUserName.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parUserName);

                //    SqlParameter parRealName = new SqlParameter("@RealName ", SqlDbType.VarChar, 30);
                //    parRealName.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parRealName);

                //    SqlParameter parNickName = new SqlParameter("@NickName ", SqlDbType.VarChar, 30);
                //    parNickName.Direction = ParameterDirection.Output;
                //    cmd.Parameters.Add(parNickName);

                //    DBUtility.Execute(cmd, DBUtility.BestToneCenterConStr);

                //    Result.result = int.Parse(parResult.Value.ToString());
                //    Result.msg = parErrMsg.Value.ToString();
                //    Result.CustID = parCustID.Value.ToString();
                //    String hbUserAccount = parUserAccount.Value.ToString();
                //    String hbCustType = parCustType.Value.ToString();
                //    String hbUProvinceID = parUProvinceID.Value.ToString();
                //    String hbSysID = parSysID.Value.ToString();
                //    String hbAreaID = parAreaID.Value.ToString();
                //    String hbouterid = parOuterID.Value.ToString();
                //    String ProvinceID1 = hbUProvinceID;
                //    String hbRealName = parRealName.Value.ToString();
                //    String hbUserName = parUserName.Value.ToString();
                //    String hbNickName = parNickName.Value.ToString();

                //    msg.AppendFormat("本地认证结果:{0},{1}\r\n", Result.result, Result.msg);
                    #region  如果天翼不存在该手机账号,则去天翼注册一把,回来绑定关系建立,如果存在,直接根据userid绑定custid

                    //if (Result.result == 0)
                    //{
                        //msg.Append("本地认证成功!\r\n");
                        //try
                        //{
                            //long t_userId = 0;
                            //msg.Append("检查该手机是否是天翼账号?\r\n");
                            //Result.result = CIP2BizRules.GetUnifyPlatformUserInfoByName(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, out t_userId, out Result.msg);
                            //msg.AppendFormat("检查结果GetUnifyPlatformUserInfoByName:Result:{0},ErrMsg:{1},UserID:{2}\r\n", Result.result, Result.msg, Convert.ToString(t_userId));
                            //if (t_userId > 0)
                            //{
                            //    //天翼存在
                            //    msg.Append("该手机号码存在于天翼账号库\r\n建立绑定关系\r\n");
                            //    Result.result = CIP2BizRules.BindCustId2UserId(SPID, "1", Result.CustID, t_userId, out Result.msg);
                            //    msg.AppendFormat("绑定结果:Result:{0},CustID:{1}<->UserID:{2}\r\n", Result.result, Result.CustID, t_userId);
                            //}
                            //else
                            //{
                                //天翼不存在
                                //msg.Append("该手机号码不存在于天翼账号库\r\n注册天翼账号\r\n");
                                //string o_userId = String.Empty;
                                //string o_userName = String.Empty;

                                //Result.result = CIP2BizRules.RegisterUnifyPlatformAccount(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, PassWord, "false", out o_userId, out o_userName, out accessToken, out Result.msg);
                                //msg.AppendFormat("注册结果:Result:{0},ErrMsg:{1},UserID:{2}\r\n", Result.result, Result.msg, o_userId);
                                //if (Result.result == 0 && !String.IsNullOrEmpty(o_userId))
                                //{
                                //    long l_userId = 0;
                                //    try
                                //    {
                                //        l_userId = Convert.ToInt64(o_userId);
                                //    }
                                //    catch (Exception ee)
                                //    {
                                //        msg.AppendFormat("异常ee:{0}\r\n", ee.Message);
                                //    }

                                //    if (l_userId != 0)
                                //    {
                                //        msg.Append("建立绑定关系\r\n");
                                //        Result.result = CIP2BizRules.BindCustId2UserId(SPID, "1", Result.CustID, l_userId, out Result.msg);
                                //        Result.msg = Result.msg + ",天翼账号认证不成功,本地认证成功!";
                                //        msg.AppendFormat("绑定结果:Result:{0},CustID{1}<->UserID{2}\r\n", Result.result, Result.CustID, l_userId);
                                //    }
                                //}

                            //}
                        //}
                        //catch (Exception et)
                        //{
                        //    msg.AppendFormat("异常:{0}\r\n", et.Message);
                        //}
                    //}
                    #endregion
                //}
                //catch (Exception excep)
                //{
                //    msg.AppendFormat("登录失败,发生异常:{0}\r\n", excep.Message);
                //}
                #endregion
            //}
        }
        catch (Exception e)
        {
            msg.AppendFormat("登录失败,发生异常:{0}"+e.ToString());
        }
        finally
        {
            BTUCenterInterfaceLog.CenterForBizTourLog("UnifyAccountAuth", msg);
        }
        #endregion
        return Result;
    }
    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去匹配
                {
                    strLog.Append("注册为号百客户\r\n");
                    ///////////////
                    #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());
        }
    }
    /// <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());
        }
    }
Ejemplo n.º 11
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();
    }
Ejemplo n.º 12
0
        /// <summary>
        /// UDB�û�ע����µ��Ű�
        /// </summary>
        public static Int32 getUserRegistryUnifyPlatform(UnifyAccountInfo accountInfo, out String CustID, out String ErrMsg)
        {
            Int32 Result = ErrorDefinition.BT_IError_Result_UnknowError_Code;
            ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
            CustID = String.Empty;
            String province = String.Empty;
            String city = String.Empty;

            try
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.CommandText = "up_Customer_V3_Interface_UserRegistryV2UnifyPlatform";
                    cmd.CommandText = "up_Customer_V3_Interface_UserRegistryV2UnifyPlatform";
                    //up_Customer_V3_Interface_UserRegistryV2UDB

                    SqlParameter parProvince = new SqlParameter("@Province", SqlDbType.VarChar);
                    parProvince.Value = accountInfo.province;  // ����Ҫ��ת��

                    cmd.Parameters.Add(parProvince);

                    SqlParameter parCity = new SqlParameter("@City", SqlDbType.VarChar);
                    parCity.Value = accountInfo.city;
                    cmd.Parameters.Add(parCity);

                    SqlParameter parAuthenName = new SqlParameter("@AuthenName", SqlDbType.VarChar);
                    parAuthenName.Value = accountInfo.mobileName;
                    cmd.Parameters.Add(parAuthenName);

                    SqlParameter parAuthenType = new SqlParameter("@AuthenType", SqlDbType.VarChar);
                    //parAuthenType.Value = UDBBusiness.ConvertAuthenType(Convert.ToString(accountInfo.userType));
                    parAuthenType.Value = "2";  // ��д��,��Ϊ����ֻ���ֻ�

                    cmd.Parameters.Add(parAuthenType);

                    SqlParameter parCustType = new SqlParameter("@CustType", SqlDbType.VarChar);
                    parCustType.Value = "42";
                    cmd.Parameters.Add(parCustType);

                    SqlParameter parRealName = new SqlParameter("@RealName", SqlDbType.VarChar);
                    parRealName.Value = String.IsNullOrEmpty(accountInfo.aliasName) ? accountInfo.nickName : accountInfo.zhUserName;
                    cmd.Parameters.Add(parRealName);

                    SqlParameter parUserName = new SqlParameter("@UserName", SqlDbType.VarChar);
                    parUserName.Value = accountInfo.userName;
                    cmd.Parameters.Add(parUserName);

                    SqlParameter parNickName = new SqlParameter("@NickName", SqlDbType.VarChar);
                    parNickName.Value = accountInfo.nickName;
                    cmd.Parameters.Add(parNickName);

                    Random random = new Random();
                    String randomPwd = random.Next(100000, 999999).ToString();
                    SqlParameter parPassword = new SqlParameter("@Password", SqlDbType.VarChar);
                    parPassword.Value = CryptographyUtil.Encrypt(randomPwd);
                    cmd.Parameters.Add(parPassword);

                    SqlParameter parOuterID = new SqlParameter("@OuterID", SqlDbType.VarChar);
                    parOuterID.Value = accountInfo.pUserId;
                    cmd.Parameters.Add(parOuterID);

                    SqlParameter parSourceSPID = new SqlParameter("@SourceSPID", SqlDbType.VarChar);
                    parSourceSPID.Value = "35999998";
                    cmd.Parameters.Add(parSourceSPID);

                    SqlParameter parOutCustID = new SqlParameter("@OCustID", SqlDbType.VarChar, 16);
                    parOutCustID.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(parOutCustID);

                    SqlParameter parResult = new SqlParameter("@Result", SqlDbType.Int);
                    parResult.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(parResult);

                    SqlParameter parErrMsg = new SqlParameter("@ErrMsg", SqlDbType.VarChar, 256);
                    parErrMsg.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(parErrMsg);

                    DBUtility.Execute(cmd, DBUtility.BestToneCenterConStr);

                    Result = Convert.ToInt32(parResult.Value);
                    ErrMsg = parErrMsg.Value.ToString();
                    CustID = parOutCustID.Value.ToString();

                }
            }
            catch (Exception ex)
            {
                ErrMsg += ex.Message;
            }

            return Result;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// �ۺ�ƽ̨��֤�ӿ�
 /// </summary>
 /// <param name="appId"></param>
 /// <param name="appSecret"></param>
 /// <param name="version"></param>
 /// <param name="clientType"></param>
 /// <param name="clientIp"></param>
 /// <param name="clientAgent"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <param name="account"></param>
 /// <param name="accessToken"></param>
 /// <param name="expiresIn"></param>
 /// <param name="ErrMsg"></param>
 /// <returns></returns>
 public static int LoginUnifyPlatform(String appId, String appSecret, String version, String clientType, String clientIp, String clientAgent, String userName, String password, out UnifyAccountInfo account, out String accessToken, out String loginNum,out long expiresIn,out String ErrMsg)
 {
     int Result = ErrorDefinition.IError_Result_UnknowError_Code;
     ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg;
     account = new UnifyAccountInfo();
     accessToken = String.Empty;
     loginNum = String.Empty;
     expiresIn = 0;
     int _result = -1;
     String msg = String.Empty;
     UDBMBOSS unifyPlatformService = new UDBMBOSS();
     try
     {
         unifyPlatformService.UnifyPlatformUserAuth(appId, appSecret, version, clientType, clientIp, clientAgent, userName, password, out  account, out  accessToken, out loginNum,out  expiresIn, out  _result, out  msg);
         ErrMsg = msg;
     }
     catch (Exception e)
     {
         msg = e.ToString();
         ErrMsg = msg;
     }
     Result = _result;
     return Result;
 }
Ejemplo n.º 14
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();
    }
Ejemplo n.º 15
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},SPID:{3}\r\n",appId,paras,sign,SPID);

        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", "客户不存在");
                        }

                        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();
                        if (accountInfo.userId != null && accountInfo.userId != 0)
                        {
                            OuterID = "123456";
                        }
                        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);
                        //埋综合平台token   6.1 add
                        //String UnifyPlatformCookieName = ConfigurationManager.AppSettings["UnifyPlatformCookieName"];
                        //PageUtility.SetCookie(UserTokenValue, UnifyPlatformCookieName, this.Page);
                        //埋综合平台token   6.1 end
                        //ReturnUrl = Request["ReturnUrl"] ;
                        strMsg.AppendFormat("ReturnUrl: {0}\r\n", ReturnUrl + "?UnifyAccountCheckResult=0");
                        strMsg.AppendFormat("Response.Redirect to {0}\r\n", ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000");
                        Response.Redirect(ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000", false);
                    }
                    else
                    {
                        strMsg.Append(",ErrMsg:用户注册到号百失败");
                        string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
                        PageUtility.ExpireCookie(CookieName, this.Page);
                        //清综合平台token   6.1 add
                        //String UnifyPlatformCookieName = ConfigurationManager.AppSettings["UnifyPlatformCookieName"];
                        //PageUtility.ExpireCookie(UnifyPlatformCookieName, this.Page);
                        //清综合平台token   6.1 end
                        Response.Redirect(ReturnUrl + "?UnifyAccountCheckResult=0&SPID=35000000", false);
                    }
                }

            }
            else  // 未登录
            {
                //清楚cookie (登录状态)
                string CookieName = System.Configuration.ConfigurationManager.AppSettings["CookieName"];
                PageUtility.ExpireCookie(CookieName, this.Page);
                //清综合平台token   6.1 add
                //String UnifyPlatformCookieName = ConfigurationManager.AppSettings["UnifyPlatformCookieName"];
                //PageUtility.ExpireCookie(UnifyPlatformCookieName, this.Page);
                //清综合平台token   6.1 end
                Response.Redirect(ReturnUrl + "?UnifyAccountCheckResult=1&SPID=35000000", false);

            }

        }
        catch (Exception excp)
        {
            strMsg.AppendFormat("异常:{0}\r\n",excp.ToString());
        }
        finally
        {
            WriteLog(strMsg.ToString());
        }
        //WriteLog(strMsg.ToString());
    }