Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 protected readonly ISystems _sys; /**/
 public ExternalResponesViewModel(SysCode sysCode, ISystems sys, T data)
 {
     _sys    = sys;
     Code    = (int)sysCode;
     Message = EnumExtention.GetDescription(sysCode);
     if (data != null)
     {
         this.Data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(data));
     }
 }
Exemplo n.º 3
0
 protected readonly ISystems _sys; /**/
 /// <summary>
 /// 返回值构造函数
 /// author:陶林辉
 /// </summary>
 /// <param name="sysCode">错误枚举</param>
 /// <param name="data">返回业务参数</param>
 /// <param name="encrypt">加密方式</param>
 public ResponseViewModel(SysCode sysCode, T data, string encrypt, ISystems sys, string secret)
 {
     _sys      = sys;
     Code      = (int)sysCode;
     Message   = EnumExtention.GetDescription(sysCode);
     Datetime  = DateTime.Now.ToLocalTime().ToString();
     Timestamp = TimeHelper.ConvertDateTimeToInt(DateTime.Now.ToLocalTime());
     if (encrypt == "0")
     {
         if (data != null)
         {
             this.Data = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(data));
         }
     }
     else if (encrypt == "1")
     {
         if (data != null)
         {
             this.Data = _sys.AesEncrypt(secret, JsonHelper.SerializeObject(data));
         }
     }
     this.Encrypt = encrypt;
 }
Exemplo n.º 4
0
        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";
        }
Exemplo n.º 5
0
        /// <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");
        }