public GameResponesViewModel(SysCode sysCode, T data, ISystems sys, string appkey, string requestId, string nonce) { _sys = sys; string appSecret = _sys.GetAppConfig(appkey).Secret; code = (int)sysCode; message = EnumExtention.GetDescription(sysCode); timestamp = TimeHelper.ConvertDateTimeToInt(DateTime.Now.ToLocalTime()).ToString(); if (data != null) { this.data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(data)); sign = _sys.Sha512Encode($"{appkey}{appSecret}{this.data}{nonce}{timestamp}"); } else { sign = _sys.Sha512Encode($"{appkey}{appSecret}{nonce}{timestamp}"); } this.requestId = requestId; this.appKey = appkey; this.nonce = nonce; page = null; //用不上 signType = "sha_512"; }
/// <summary> /// 查询用户余额 /// author:陶林辉 /// </summary> /// <param name="userId"></param> /// <returns>余额,可兑出</returns> public UserBalanceDto AcquireBalance(long userId) { BalanceReuqest Balance = new BalanceReuqest { FuserId = userId.ToString() }; ZhangYuRequest Request = new ZhangYuRequest(); Request.AppKey = _options.Value.AppKey; Request.Data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(Balance)); Request.Sign = _sys.Sha512Encode($"{Request.AppKey}{_options.Value.AppSecret}{Request.Data}{Request.Nonce}{Request.Timestamp}"); string strUrl = string.Format(_options.Value.Url, "v1", "balance"); string strJson = JsonHelper.SerializeObject(Request); _log.Info($"查询用户余额请求参数{strJson}"); var response = JsonHelper.DeserializeJsonToObject <ZhangYuResponse>(_sys.PostJsonData(strUrl, strJson, Encoding.UTF8)); _log.Info($"查询用户余额返回值{ JsonHelper.SerializeObject(response)}"); if (response.Code == "0") { var vResult = JsonHelper.DeserializeJsonToObject <UserBalanceDto>(_sys.Base64Decode(response.Data)); return(vResult); } return(null); }
/// <summary> /// 账户充值 /// author:白尚德 /// </summary> /// <param name="fuserId"></param> /// <param name="forderId"></param> /// <param name="amount"></param> /// <param name="description"></param> /// <param name="key"></param> /// <returns></returns> public bool Recharge_php(long fuserId, string forderId, double amount, string description, string key) { PHPRequest Request = new PHPRequest { AppKey = _options.Value.AppKey, Data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(new RechargePhpRequest() { amount = amount, forderId = forderId, fuserId = fuserId.ToString(), description = description, rateKey = key, })) }; Request.Sign = _sys.Sha512Encode($"{Request.AppKey}{_options.Value.AppSecret}{Request.Data}{Request.Nonce}{Request.Timestamp}"); string strUrl = string.Format(_options.Value.Url, "v1", "recharge"); string strJson = JsonHelper.SerializeObject(Request); _log.Info($"账户充值请求参数_php{strJson}"); var response = JsonHelper.DeserializeJsonToObject <PHPResponse>(_sys.PostJsonData(strUrl, strJson, Encoding.UTF8)); _log.Info($"账户充值返回值_php{JsonHelper.SerializeObject(response)}" + Request.RequestId); return(response.Code == "0"); }