/// <summary> /// 获取用户手机号码及归属地 /// author:白尚德 /// </summary> /// <returns></returns> public MobInfoViewModel MobInfo(string mobilenum) { MobInfoViewModel result = null; string strResult = _sys.PostJsonData($"{_ofpay.Url}{"mobinfo.do"}{"?mobilenum="}{mobilenum}", "", Encoding.GetEncoding("gbk")); if (!StringExtension.IsBlank(strResult)) { var str = strResult.Split("|"); result = new MobInfoViewModel { phone = mobilenum, operators = str[1], region = str[2] }; } return(result); }
public async Task <ResponseViewModel <WeChatResponse> > WeCharPaySign([FromBody] RequestViewModel obj) { ResponseViewModel <WeChatResponse> response = null; WeChatResponse result = null; obj = JsonHelper.DeserializeJsonToObject <RequestViewModel>(Content(User.Identity.Name).Content); var sysCode = SysCode.Ok; bool isLog = _token.VerifyToken(obj.HendInfo.UserOpenId, obj.HendInfo.SessionToken); if (isLog) { string json = RedisHelper.StringGet($"{CacheKey.Token}{obj.HendInfo.UserOpenId}", RedisFolderEnum.token, RedisEnum.Three); var userLog = JsonHelper.DeserializeJsonToObject <UserLoginDto>(json); int itemId = StringExtension.ToInt((string)obj.Data.itemId); //; //商品Id RechargeCommodityDto rechargeCommodity = await _recharge.GetRechargeCommodityByIdAsync(itemId); if (rechargeCommodity == null) { sysCode = SysCode.RechargeCommodityIsNULL; //充值商品不存在, } if (sysCode == SysCode.Ok) { string strUrl = _weChatPay.Url; WeCharRequest weChar = new WeCharRequest(); weChar.userOpenId = obj.HendInfo.UserOpenId; weChar.itemId = (string)obj.Data.itemId; weChar.sessionToken = obj.HendInfo.SessionToken; WeCharRequestList requestList = new WeCharRequestList(); requestList.data = weChar; string strJson = JsonHelper.SerializeObject(requestList); result = JsonHelper.DeserializeJsonToObject <WeChatResponse>(_sys.PostJsonData(strUrl, strJson, Encoding.UTF8)); } } else { /*短令牌失效*/ sysCode = SysCode.SessionTokenLose; } response = new ResponseViewModel <WeChatResponse>(sysCode, sysCode == SysCode.Ok ? result : null, obj.Encrypt, _sys, obj.Secret); return(response); }
/// <summary> /// 验证苹果收据 /// author:陶林辉 /// </summary> /// <param name="receipt"></param> /// <returns></returns> public bool VerifyReceipt(ReceiptDto receipt) { string strJosn = string.Format("{{\"receipt-data\":\"{0}\"}}", receipt.Receipt); //string strResult = CreatePostHttpResponse(strJosn,true); string strResult = _sys.PostJsonData(_applepay.Url, strJosn, Encoding.UTF8); JObject obj = JObject.Parse(strResult); // 判断是否购买成功 if (obj["status"].ToString() == "0") { return(true); } else { return(false); } }
/// <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"); }