/// <summary> /// 解析支付信息. /// </summary> /// <returns>Json数据对象.</returns> /// <param name="iJsonDetail">Json详细.</param> /// <param name="iOnPaymentSuccessed">支付成功回调函数.</param> public SDKPaymentBaseInfo ParserPayResponseInfo( string iJsonDetail, Action <SDKAccountBaseInfo, string> iOnPaymentSuccessed) { if (null == iOnPaymentSuccessed) { this.Warning("SDKParserPaymentInfo()::OnPaymentSuccessed is null!!!"); } this.UpdateStatus(SDKStatus.PurchaseCompleted); this.Info("ParserPayResponseInfo()::Detail:{0}", iJsonDetail); SFJSONObject _sfjson = new SFJSONObject(iJsonDetail); if (null == _sfjson) { this.Error("ParserPayResponseInfo()::(SFJSONObject)Memory New Error!!!!"); return(null); } string _status = (string)_sfjson.get("result"); if (true == string.IsNullOrEmpty(_status)) { this.Error("ParserPayResponseInfo()::Data Format Invalid!!!!(Detail:{0})", iJsonDetail); return(null); } string _data = (string)_sfjson.get("data"); if (true == string.IsNullOrEmpty(_data)) { this.Error("ParserPayResponseInfo()::Data Format Invalid!!!!(Detail:{0})", iJsonDetail); return(null); } if (null == this._payment) { this._payment = new OneSDKPaymentInfo(); this._payment.Reset(); } if (null == this._payment) { this.Error("ParserPayResponseInfo()::(OneSDKPaymentInfo)Memory New Error!!!!"); return(null); } if (true == S_PAY_SUCCESS.Equals(_status)) { this.UpdateStatus(SDKStatus.PurchaseSuccessed); this._payment.Successed = true; if (null != iOnPaymentSuccessed) { iOnPaymentSuccessed(this._userInfo, this._payment.OrderNo); } else { this.Warning("ParserPayResponseInfo()::OnPaymentSuccessed is null!!!!"); } } else if (true == S_PAY_FAILED.Equals(_status)) { this.UpdateStatus(SDKStatus.PurchaseFailed); this._payment.Successed = false; } else if (true == S_PAY_ORDER_NO.Equals(_status)) { this.UpdateStatus(SDKStatus.PurchaseOrdered); this._payment.Successed = true; this._payment.OrderNo = _data; } this.Info("ParserPayResponseInfo()::PayInfo:{0}", this._payment.ToString()); return(this._payment); }
/// <summary> /// 解析登录信息. /// </summary> /// <returns>Json数据对象.</returns> /// <param name="iJsonDetail">Json详细.</param> public SDKAccountBaseInfo ParserLoginResponseInfo(string iJsonDetail) { // 登录完成 this.UpdateStatus(SDKStatus.LoginCompleted); if (null == this._userInfo) { this._userInfo = new OneSDKUserInfo(); } if (null == this._userInfo) { this.Error("ParserLoginResponseInfo()::Memory New Error!!!!"); return(this._userInfo); } this._userInfo.Reset(); SFJSONObject _sfjson = new SFJSONObject(iJsonDetail); if (null == _sfjson) { return(null); } string _status = (string)_sfjson.get("result"); string _customParams = (string)_sfjson.get("customParams"); this.Info("ParserLoginResponseInfo()::CustomParams:{0}", _customParams); // 登出 if (true == S_LOGOUT.Equals(_status)) { this._sfUserInfo = null; this.UpdateStatus(SDKStatus.Logouted); // 重登录 if (true == this._isLogin) { this.ReLogin(); } // 登录成功 } else if (true == S_LOGIN_SUCCESS.Equals(_status)) { this.UpdateStatus(SDKStatus.LoginCompleted); SFJSONObject _userinfoTmp = (SFJSONObject)_sfjson.get("userinfo"); if (null != _userinfoTmp) { this._userInfo.UserID = long.Parse((string)_userinfoTmp.get("id")); this._userInfo.ChannelId = (string)_userinfoTmp.get("channelid"); this._userInfo.ChannelUserId = (string)_userinfoTmp.get("channeluserid"); this._userInfo.UserName = (string)_userinfoTmp.get("username"); this._userInfo.Token = (string)_userinfoTmp.get("token"); this._userInfo.ProductCode = (string)_userinfoTmp.get("productcode"); this._sfUserInfo = new SFOnlineUser( this._userInfo.UserID, this._userInfo.ChannelId, this._userInfo.ChannelUserId, this._userInfo.UserName, this._userInfo.Token, this._userInfo.ProductCode); } if (null != this._loginCheckCallback) { // 校验数据 string _checkInfo = GetLoginCheckInfoJson(this._userInfo); if (true == string.IsNullOrEmpty(_checkInfo)) { this.Error("ParserLoginResponseInfo():JsonConvert Failed!!!(Data:{0})", this._userInfo.ToString()); this.UpdateStatus(SDKStatus.LoginCheckFailed); return(null); } this.Info("ParserLoginResponseInfo()::CheckInfo:{0}", _checkInfo); this._loginCheckCallback(_checkInfo, this._loginCheckSuccessed, this._loginCheckFailed); } else { // 登录校验&更新状态 loginCheck(this._userInfo); } // 登录失败 } else if (true == S_LOGIN_FAILED.Equals(_status)) { this.UpdateStatus(SDKStatus.LoginFailed); // 重登录 if (true == this._isLogin) { this.ReLogin(); } } this.Info("ParserLoginResponseInfo()::UserResultInfo:{0}", this._userInfo.ToString()); return(this._userInfo); }