コード例 #1
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());
    }
コード例 #2
0
    public String UpdateUserInfo(String SPID, String AccessToken, UnifyAccountInfo accountInfo)
    {
        StringBuilder strLog      = new StringBuilder();
        StringBuilder ResponseMsg = new StringBuilder();

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

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

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

        #endregion

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

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


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

                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", Result);
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", ":" + ErrMsg);
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }
            catch (Exception e)
            {
                strLog.AppendFormat("ex:{0}\r\n", e.ToString());
                ResponseMsg.Length = 0;
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "修改信息失败:" + e.ToString());
                ResponseMsg.Append("}");
                return(ResponseMsg.ToString());
            }
        }
        catch (Exception ex)
        {
            strLog.AppendFormat("ex:{0}\r\n", ex.ToString());
            ResponseMsg.Length = 0;
            ResponseMsg.Append("{");
            ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "999");
            ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "修改信息失败:" + ex.ToString());
            ResponseMsg.Append("}");
            return(ResponseMsg.ToString());
        }
        finally
        {
            log(strLog.ToString());
        }
        return(ResponseMsg.ToString());
    }
コード例 #3
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());
    }
コード例 #4
0
    public String UnifyAccountBinding(String SPID, String CustID, String AccessToken, String OperType)
    {
        StringBuilder strLog      = new StringBuilder();
        StringBuilder ResponseMsg = new StringBuilder();

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

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

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


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


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

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


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

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

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

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

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