Beispiel #1
0
        /// <summary>
        /// 赠币
        /// author:林辉
        /// </summary>
        /// <returns></returns>
        public async Task <bool> GiveCurrencyAsync(GiveCurrencyDto giveCurrency)
        {
            ZhangYuRequest Request = new ZhangYuRequest();

            Request.AppKey = _options.Value.AppKey;
            Request.Data   = _sys.Base64Encode(Encoding.UTF8, JsonHelper.SerializeObject(giveCurrency));
            Request.Sign   = _sys.Sha512Encode($"{Request.AppKey}{_options.Value.AppSecret}{Request.Data}{Request.Nonce}{Request.Timestamp}");
            string strJson = JsonHelper.SerializeObject(Request);
            string strUrl  = string.Format(_options.Value.Url, "v1", "gift");

            _log.Info($"用户赠币请求参数{strJson}");
            var response = JsonHelper.DeserializeJsonToObject <ZhangYuResponse>(_sys.PostJsonData(strUrl, strJson, Encoding.UTF8));
            var result   = JsonHelper.DeserializeJsonToObject <CostStatusResult>(_sys.Base64Decode(response.Data));

            _log.Info($"用户赠币返回值{JsonHelper.SerializeObject(response)}");
            if (result.code == 0)
            {
                GiveCurrencyLogDto giveCurrencyLogDto = new GiveCurrencyLogDto
                {
                    CreateTime = DateTime.Now,
                    Key        = giveCurrency.key,
                    Order      = giveCurrency.forderId,
                    UserId     = long.Parse(giveCurrency.fuserId)
                };
                var entity = _mapper.Map <GiveCurrencyLogDto, GiveCurrencyLogEntity>(giveCurrencyLogDto);
                _context.giveCurrencyLog.Add(entity);
                await _context.SaveChangesAsync();

                return(true);
            }
            return(false);
        }
Beispiel #2
0
        public void InserGive(GiveCurrencyLogDto dto)
        {
            var entity = _mapper.Map <GiveCurrencyLogDto, GiveCurrencyLogEntity>(dto);

            _funHaiNanContext.giveCurrencyLog.Add(entity);
            _funHaiNanContext.SaveChanges();
        }