/// <summary> /// 连连支付请求 /// </summary> /// <returns></returns> private SupportBankQuery GetSupportBank() { //var setid = new Guid("E27798C9-9301-4176-AC0B-6F3916F389EA"); var webSetting = new TuanDai.PortalSystem.BLL.WebSettingBLL().GetWebSettingInfo("E27798C9-9301-4176-AC0B-6F3916F389EA"); SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("oid_partner", webSetting.Param1Value.Trim()); sParaTemp.Add("api_version", "1.0"); sParaTemp.Add("sign_type", "RSA"); sParaTemp.Add("product_type", "1"); sParaTemp.Add("pay_chnl", "10"); var sign = PaymentUtil.AddSign(sParaTemp, webSetting.Param3Value, webSetting.Param2Value); sParaTemp.Add("sign", sign); var reqJson = PaymentUtil.DictToJson(sParaTemp); var url = "https://yintong.com.cn/queryapi/supportbankquery.htm"; var responseJson = postJson(url, reqJson); var responseResult = JsonConvert.DeserializeObject <SupportBankQuery>(responseJson); //记录充值请求参数 //BusinessDll.NetLog.WriteLoginHandler( "记录连连支付银行卡卡bin查询", "请求报文:" + reqJson + ";返回报文" + responseJson,"触屏版"); if (responseResult.ret_code != "0000") { responseResult = null; } return(responseResult); }
public void GetBankBin() { ResultModel result = new ResultModel(); Dictionary <String, String> bankPath = new Dictionary <String, String>(); bankPath.Add("01020000", "3"); // 中国工商银行 bankPath.Add("01030000", "5"); // 中国农业银行 bankPath.Add("01040000", "2"); // 中国银行 bankPath.Add("01050000", "4"); // 中国建设银行 bankPath.Add("03100000", "7"); // 浦发银行 bankPath.Add("01000000", "16"); // 中国邮政银行 //bankPath.Add("03040000", "16"); // 华夏银行 bankPath.Add("03050000", "8"); // 民生银行 bankPath.Add("03060000", "14"); // 广东发展银行 bankPath.Add("03070000", "15"); // 平安银行 bankPath.Add("03030000", "10"); // 光大银行 bankPath.Add("03080000", "1"); // 招商银行 bankPath.Add("03090000", "9"); // 兴业银行 bankPath.Add("03020000", "13"); // 中信银行 bankPath.Add("03010000", "6"); // 交通银行 bankPath.Add("04031000", "12"); // 北京银行 string strCardNo = Context.Request["CardNo"]; Guid userId = WebUserAuth.UserId.Value; if (string.IsNullOrEmpty(strCardNo)) { result.status = 2; result.msg = "卡号不能为空"; } SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); //var id = Guid.Parse("E27798C9-9301-4176-AC0B-6F3916F389EA"); //var webSetting = db.WebSetting.FirstOrDefault(x => x.Id == id); var webSetting = new WebSettingBLL().GetWebSettingInfo("E27798C9-9301-4176-AC0B-6F3916F389EA"); var partnerConfig = new PartnerConfig(webSetting.Param1Value, webSetting.Param2Value, webSetting.Param3Value, webSetting.Param4Value); string timestamp = PaymentUtil.GetCurrentDateTimeStr(); //基本请求参数 sParaTemp.Add("oid_partner", partnerConfig.OidPartner); sParaTemp.Add("sign_type", "RSA"); //业务参数 sParaTemp.Add("card_no", strCardNo); //卡号 //加签 string sign = PaymentUtil.AddSign(sParaTemp, partnerConfig.TraderPriKey, partnerConfig.MD5Key); sParaTemp.Add("sign", sign); var reqJson = PaymentUtil.DictToJson(sParaTemp); //LogEnum.Batchwithdraw.WriteLog("连连银行卡卡BIN查询-请求报文", "[" + reqJson + "]"); string responseJSON = postJson("https://yintong.com.cn/traderapi/bankcardquery.htm", reqJson); //LogEnum.Batchwithdraw.WriteLog("连连银行卡卡BIN查询-响应报文", "[" + responseJSON + "]"); SortedDictionary <string, string> sArray = JsonConvert.DeserializeObject <SortedDictionary <string, string> >(responseJSON); if (sArray.Count > 0) { //查询成功 if (sArray["ret_code"].ToString().Trim() == "0000") { string strBankCode = sArray["bank_code"].ToString().Trim(); string strBandPath; if (!bankPath.ContainsKey(strBankCode)) { strBandPath = "9999"; } else { strBandPath = bankPath[strBankCode]; } BankBin bankBin = new BankBin(); bankBin.card_no = strCardNo; bankBin.bank_code = strBandPath; bankBin.bank_name = sArray["bank_name"].ToString().Trim(); bankBin.card_type = sArray["card_type"].ToString().Trim(); bankBin.card_bound = BankNoExists(strCardNo, userId) ? "true" : "false"; result.status = 1; result.msg = "查询成功"; result.model = bankBin; } else { result.status = 0; result.msg = "查询信息失败,连连返回错误号:" + sArray["ret_code"].ToString().Trim() + ",错误信息:" + sArray["ret_msg"].ToString().Trim(); } } else { result.status = -1; result.msg = "未查询到信息"; } var sbq = GetSupportBank(); if (sbq == null) { result.status = -2; result.msg = "手机支付不支持该卡"; } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"; string resultJson = Newtonsoft.Json.JsonConvert.SerializeObject(result, timeConverter); Context.Response.Write(resultJson); }
private BankCardBin GetSupportBank() { BankCardBin bindCard = new BankCardBin(); bindCard.single_amt = "0"; bindCard.day_amt = "0"; try { WebSettingInfo webSetting = new TuanDai.PortalSystem.DAL.WebSettingDAL().GetWebSettingInfo("E27798C9-9301-4176-AC0B-6F3916F389EA"); SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("oid_partner", webSetting.Param1Value.Trim()); sParaTemp.Add("api_version", "1.0"); sParaTemp.Add("sign_type", "RSA"); sParaTemp.Add("product_type", "1"); sParaTemp.Add("pay_chnl", "10"); var sign = PaymentUtil.AddSign(sParaTemp, webSetting.Param3Value, webSetting.Param2Value); sParaTemp.Add("sign", sign); var reqJson = PaymentUtil.DictToJson(sParaTemp); var url = "https://yintong.com.cn/queryapi/supportbankquery.htm"; string json = postJson(url, reqJson); SupportBankQuery responseResult = new SupportBankQuery(); responseResult = Newtonsoft.Json.JsonConvert.DeserializeObject <SupportBankQuery>(json); //记录充值请求参数 // BusinessDll.NetLog.WriteBatchwithdrawHandler("记录连连支付银行卡卡bin查询", "请求报文:" + reqJson + ";返回报文" + json, "触屏版"); if (responseResult == null) { responseResult = new SupportBankQuery(); } if (responseResult.ret_code == "0000") { var sqlParamBankCode = new Dapper.DynamicParameters(); sqlParamBankCode.Add("@bankType", userModel.BankType); var sqlBankCode = @"select BankCode,BankDesc from [dbo].[Bank_Code] with(nolock) where bankType=@bankType"; var bank_code = TuanDai.DB.TuanDaiDB.QueryFirstOrDefault <Bank_Code>(TdConfig.DBRead, sqlBankCode, ref sqlParamBankCode); var backCode = string.Empty; if (bank_code != null) { bindCard.BankDesc = bank_code.BankDesc; backCode = bank_code.BankCode; } backCode = string.IsNullOrEmpty(backCode) ? string.Empty : backCode.Trim(); var _supportBank = responseResult.support_banklist.FirstOrDefault(x => x.bank_code == backCode); if (null != _supportBank) { bindCard.single_amt = _supportBank.single_amt; bindCard.day_amt = _supportBank.day_amt; if (_supportBank.bank_status == "0") { bindCard.IsBankMaintain = false; } else { bindCard.IsBankMaintain = true; } } } if (decimal.Parse(bindCard.single_amt) >= 10000) { bindCard.SingleAmt = (decimal.Parse(bindCard.single_amt) / 10000).ToString("n0") + "万"; } else { bindCard.SingleAmt = decimal.Parse(bindCard.single_amt).ToString("n0") + "元"; } if (decimal.Parse(bindCard.day_amt) >= 10000) { bindCard.DayAmt = (decimal.Parse(bindCard.day_amt) / 10000).ToString("n0") + "万"; } else { bindCard.DayAmt = decimal.Parse(bindCard.day_amt).ToString("n0") + "元"; } return(bindCard); } catch (Exception ex) { // BusinessDll.NetLog.WriteLoginHandler("查询卡限额时出错", Tool.ExceptionHelper.GetExceptionMessage(ex), "触屏版"); bindCard.IsBankMaintain = true; return(bindCard); } }