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(); }
public GetUserInfoByNameResult UnifyGetUserInfoByName(string SPID, string UserName) { GetUserInfoByNameResult Result = new GetUserInfoByNameResult(); StringBuilder strLog = new StringBuilder(); strLog.AppendFormat("{0}\r\n", DateTime.Now.ToString("u")); strLog.AppendFormat("参数:SPID:{0},UserName:{1}\r\n", SPID, UserName); Result.Result = ErrorDefinition.BT_IError_Result_UnknowError_Code; Result.ErrMsg = ""; Result.userId = ""; Result.custId = ""; 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; } 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; try { UDBMBOSS _udbBoss = new UDBMBOSS(); _udbBoss.GetUserInfoByName(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, out Result.Result, out Result.userId, out Result.ErrMsg); strLog.AppendFormat("结果:{0},{1},{2}\r\n", Result.Result, Result.ErrMsg,Result.userId); if (Result.Result == 0) { Result.Result = CIP2BizRules.BindCustInfoUnifyPlatform("02", "021", UserName, "", "", "", Convert.ToInt64(Result.userId), SPID, "2", out Result.custId, out Result.ErrMsg); } } catch (Exception e) { Result.ErrMsg = e.Message; strLog.AppendFormat("异常:{0}\r\n", e.Message); } finally { BTUCenterInterfaceLog.CenterForBizTourLog("UnifyGetUserInfoByName", strLog); } return Result; }
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; }
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; }
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; }
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 + "®isterCustId=" + 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®isterCustId=134664179 //"http://116.228.55.13:8113/facadeHome.do?actions=facadeHome&method=sendCouponToShare&wt=json&from=ios®isterCustId= } 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(); }
public IsUserNameExistResult IsUserNameExist(string SPID, string UserName) { IsUserNameExistResult Result = new IsUserNameExistResult(); StringBuilder strLog = new StringBuilder(); strLog.AppendFormat("{0}\r\n",DateTime.Now.ToString("u")); strLog.AppendFormat("参数:SPID:{0},UserName:{1}\r\n",SPID,UserName); Result.Result = ErrorDefinition.BT_IError_Result_UnknowError_Code; Result.ErrMsg = ""; Result.isExist = ""; 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; } 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; try { UDBMBOSS _udbBoss = new UDBMBOSS(); _udbBoss.IsUserNameExists(appId, appSecret, version, clientType, clientIp, clientAgent, UserName, out Result.Result, out Result.isExist,out Result.ErrMsg); strLog.AppendFormat("结果:{0},{1}\r\n",Result.Result,Result.ErrMsg); } catch (Exception e) { Result.ErrMsg = e.Message; strLog.AppendFormat("异常:{0}\r\n",e.Message); } finally { BTUCenterInterfaceLog.CenterForBizTourLog("IsUserNameExist", strLog); } return Result; }
public static int GetUnifyPlatformUserInfoByName(String appId, String appSecret, String version, String clientType, String clientIp, String clientAgent, String userName, out String userId, out String ErrMsg) { int Result = ErrorDefinition.IError_Result_UnknowError_Code; ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg; userId = ""; ErrMsg = ""; String msg = String.Empty; int _result = -1; try { UDBMBOSS unifyPlatformService = new UDBMBOSS(); unifyPlatformService.GetUserInfoByName(appId, appSecret, version, clientType, clientIp, clientAgent, userName, out _result, out userId, out msg); ErrMsg = msg; } catch (Exception e) { msg = e.ToString(); ErrMsg = msg; } Result = _result; return Result; }
public static int UpdateUnifyPassWord(String appId,String appSecret,String version,String clientType,String AccessToken, String PassWord, String nPassWord, String ClientIp, String ClientAgent,out String ErrMsg) { int Result = ErrorDefinition.IError_Result_UnknowError_Code; ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg; UDBMBOSS udbBoss = new UDBMBOSS(); try { Result = udbBoss.UnifyPlatformUpdatePwd(appId, appSecret, version, clientType, AccessToken, PassWord, nPassWord, ClientIp, ClientAgent, out ErrMsg); } catch (Exception e) { Result = ErrorDefinition.BT_IError_Result_System_UnknowError_Code; ErrMsg = ErrorDefinition.BT_IError_Result_System_UnknowError_Msg + "," + e.Message; } return Result; }
/// <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="sendSms"></param> /// <param name="ErrMsg"></param> /// <returns></returns> public static int RegisterUnifyPlatformAccount(String appId,String appSecret,String version,String clientType,String clientIp,String clientAgent, String userName,String password,String sendSms,out String userId,out String o_userName,out String accessToken,out String ErrMsg) { int Result = ErrorDefinition.IError_Result_UnknowError_Code; ErrMsg = ErrorDefinition.BT_IError_Result_UnknowError_Msg; userId = String.Empty; o_userName = String.Empty; accessToken = String.Empty; long expiresIn = 0; int _result = -1; String msg = String.Empty; UDBMBOSS unifyPlatformService = new UDBMBOSS(); try { unifyPlatformService.UnifyPlatformRegisterAccount(appId, appSecret, version, clientType, clientIp, clientAgent, userName, password, sendSms, out userId, out o_userName, out accessToken, out expiresIn, out _result, out msg); ErrMsg = msg; } catch (Exception e) { msg = e.ToString(); ErrMsg = msg; } Result = _result; return Result; }
/// <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; }
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(); }