12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061 |
- using System.Net.Mime;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- using Library;
- using System.Net;
- using System.IO;
- using Aop.Api.Util;
- using LitJson;
- namespace MySystem
- {
-
-
-
- public class HaoDaHelper
- {
- public readonly static HaoDaHelper Instance = new HaoDaHelper();
- private HaoDaHelper()
- {
- }
- #region 盒易付
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public string AddNewMerchant(AddNewMerchant request, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1)
- {
- BoxRequestUrl = HaodaParam.BoxRequestUrl;
- string oprInvitedCode = "";
- if (BrandId == 1)
- {
- if(string.IsNullOrEmpty(RedisDbconn.Instance.Get<string>("AgentInvitedCode:" + AgentTag)))
- {
- oprInvitedCode = RedisDbconn.Instance.Get<string>("AgentInvitedCode:1");
- }
- else
- {
- oprInvitedCode = RedisDbconn.Instance.Get<string>("AgentInvitedCode:" + AgentTag);
- }
- }
- request.oprInvitedCode = oprInvitedCode;
- }
-
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒新创建商户");
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(request);
- LogHelper.Instance.WriteLog(req, "好哒新创建商户");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒新创建商户");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒新创建商户");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/inst/mcht/new_create_mcht", "好哒新创建商户");
- string result = PostWebRequest(BoxRequestUrl + "/api/inst/mcht/new_create_mcht", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒新创建商户");
- return result;
- }
-
-
-
-
-
-
- public string QueryMerchantStatus(string instId, string mchtNo, int BrandId = 0, string AgentTag = "1")
- {
- if(string.IsNullOrEmpty(mchtNo))
- {
- return "{}";
- }
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒查询商户审核状态");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("instId", instId);
- reqdic.Add("mchtNo", mchtNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒查询商户审核状态");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒查询商户审核状态");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒查询商户审核状态");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/inst/mcht/query_mcht_audit", "好哒查询商户审核状态");
- string result = PostWebRequest(BoxRequestUrl + "/api/inst/mcht/query_mcht_audit", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒查询商户审核状态");
- return result;
- }
-
-
-
-
-
-
- public string QueryAuthStatus(string mchtNo, string storeNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒查询实名认证状态");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒查询实名认证状态");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒查询实名认证状态");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒查询实名认证状态");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/wechat/queryVerifiedResult.json", "好哒查询实名认证状态");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/wechat/queryVerifiedResult.json", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒查询实名认证状态");
- return result;
- }
-
-
-
-
-
-
- public string QueryAuthQRcode(string mchtNo, string storeNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒查询实名认证二维码");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒查询实名认证二维码");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒查询实名认证二维码");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒查询实名认证二维码");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/wechat/queryVerifiedQrcode.json", "好哒查询实名认证二维码");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/wechat/queryVerifiedQrcode.json", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒查询实名认证二维码");
- return result;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public string WeChatPay(string mchtNo, string storeNo, string outOrderNo, string transAmount, string callbackUrl, string subOpenId, string confirmCode, string subAppId, string subAppIdType, string ledgerModel, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒微信公众号和小程序支付");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- reqdic.Add("outOrderNo", outOrderNo);
- reqdic.Add("transAmount", transAmount);
- reqdic.Add("callbackUrl", callbackUrl);
- reqdic.Add("subOpenId", subOpenId);
- reqdic.Add("confirmCode", confirmCode);
- reqdic.Add("subAppId", subAppId);
- reqdic.Add("subAppIdType", subAppIdType);
- reqdic.Add("ledgerModel", ledgerModel);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒微信公众号和小程序支付");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒微信公众号和小程序支付");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒微信公众号和小程序支付");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", "好哒微信公众号和小程序支付");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒微信公众号和小程序支付");
- return result;
- }
-
-
-
-
-
-
-
-
-
-
-
- public string Alipay(string mchtNo, string storeNo, string outOrderNo, string transAmount, string callbackUrl, string subOpenId, string confirmCode, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒支付宝服务窗支付");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- reqdic.Add("outOrderNo", outOrderNo);
- reqdic.Add("transAmount", transAmount);
- reqdic.Add("callbackUrl", callbackUrl);
- reqdic.Add("subOpenId", subOpenId);
- reqdic.Add("confirmCode", confirmCode);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒支付宝服务窗支付");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒支付宝服务窗支付");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒支付宝服务窗支付");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", "好哒支付宝服务窗支付");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒支付宝服务窗支付");
- return result;
- }
-
-
-
-
-
-
-
-
-
- public string AggregatedPayRefund(string mchtNo, string storeNo, string outRefundNo, string outOrderNo, string refundAmount, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒聚合支付退款");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- reqdic.Add("outRefundNo", outRefundNo);
- reqdic.Add("outOrderNo", outOrderNo);
- reqdic.Add("refundAmount", refundAmount);
- reqdic.Add("refundReason", "门店消费补贴");
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒聚合支付退款");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒聚合支付退款");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒聚合支付退款");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/refund", "好哒聚合支付退款");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/refund", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒聚合支付退款");
- return result;
- }
-
-
-
-
-
-
- public string OpenDivideAccounts(string mchtNo, string storeNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒开通分账");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒开通分账");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒开通分账");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒开通分账");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/part/mcht/reg", "好哒开通分账");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/mcht/reg", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒开通分账");
- return result;
- }
-
-
-
-
-
-
-
- public string DivideAccountsSign(string acctNo, string mchtNo, string storeNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账接收方签约");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("acctNo", acctNo);
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒分账接收方签约");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒分账接收方签约");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒分账接收方签约");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/part/acct/bind_mcht", "好哒分账接收方签约");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/bind_mcht", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账接收方签约");
- return result;
- }
-
-
-
-
-
- public string AddOpenDivideAccounts(AddOpenDivideAccounts request, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒添加分账接收方账户");
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(request);
- LogHelper.Instance.WriteLog(req, "好哒添加分账接收方账户");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒添加分账接收方账户");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒添加分账接收方账户");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/part/acct/register", "好哒添加分账接收方账户");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/register", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒添加分账接收方账户");
- return result;
- }
-
-
-
-
-
-
- public string QueryOrderDivideAccounts(string mchtNo, string orderNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账交易详情查询");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("orderNo", orderNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒分账交易详情查询");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒分账交易详情查询");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒分账交易详情查询");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/part/acct/bind_mcht", "好哒分账交易详情查询");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/bind_mcht", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账交易详情查询");
- return result;
- }
-
-
-
-
-
-
- public string QueryOrderDivideDetail(string mchtNo, string orderNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账交易详情查询");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("orderNo", orderNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒分账交易详情查询");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒分账交易详情查询");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒分账交易详情查询");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/part/trade/clear/get", "好哒分账交易详情查询");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/trade/clear/get", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账交易详情查询");
- return result;
- }
-
-
-
-
-
-
- public string OrderDivideAccounts(OrderDivideAccounts request, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒订单分账申请");
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(request);
- LogHelper.Instance.WriteLog(req, "好哒订单分账申请");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒订单分账申请");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒订单分账申请");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/part/order/apply", "好哒订单分账申请");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/order/apply", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒订单分账申请");
- return result;
- }
-
-
-
-
-
-
- public string OrderDivideAccountsQuery(string applyNo, string mchtNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒订单分账结果查询");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("applyNo", applyNo);
- reqdic.Add("mchtNo", mchtNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒订单分账结果查询");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒订单分账结果查询");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒订单分账结果查询");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/part/apply/query", "好哒订单分账结果查询");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/apply/query", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒订单分账结果查询");
- return result;
- }
-
-
-
-
-
- public string ChangeMerchantCard(ChangeMerchantCard request, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒商户修改银行卡");
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(request);
- LogHelper.Instance.WriteLog(req, "好哒商户修改银行卡");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒商户修改银行卡");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒商户修改银行卡");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/inst/mcht/update_acct", "好哒商户修改银行卡");
- string result = PostWebRequest(BoxRequestUrl + "/api/inst/mcht/update_acct", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒商户修改银行卡");
- return result;
- }
-
-
-
-
-
-
- public string QueryChangeCardStatus(string mchtNo, string taskId, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒查询修改银行卡任务审核状态");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("taskId", taskId);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒查询修改银行卡任务审核状态");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒查询修改银行卡任务审核状态");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒查询修改银行卡任务审核状态");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/inst/mcht/query_acct_task", "好哒查询修改银行卡任务审核状态");
- string result = PostWebRequest(BoxRequestUrl + "/api/inst/mcht/query_acct_task", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒查询修改银行卡任务审核状态");
- return result;
- }
-
-
-
-
-
-
-
- public string BindWeChatAppId(string mchtNo, string storeNo, string subAppId, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒绑定微信appid接口");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- reqdic.Add("subAppId", subAppId);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒绑定微信appid接口");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒绑定微信appid接口");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒绑定微信appid接口");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/wechat/add_sub_config", "好哒绑定微信appid接口");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/wechat/add_sub_config", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒绑定微信appid接口");
- return result;
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public string QueryAccountList(string mchtNo, string startTime, string endTime, string tradeMchtNo, string cardNo, string settleStatus, string page = "1", string rows = "10", int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒到账记录查询");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("startTime", startTime);
- reqdic.Add("endTime", endTime);
- reqdic.Add("tradeMchtNo", tradeMchtNo);
- reqdic.Add("cardNo", cardNo);
- reqdic.Add("settleStatus", settleStatus);
- reqdic.Add("page", page);
- reqdic.Add("rows", rows);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒到账记录查询");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒到账记录查询");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒到账记录查询");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/accb/to_account/query", "好哒到账记录查询");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/accb/to_account/query", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒到账记录查询");
- return result;
- }
-
-
-
-
-
-
- public string QueryAccountDetail(string mchtNo, string id, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒到账记录详情");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("id", id);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒到账记录详情");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒到账记录详情");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒到账记录详情");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/accb/to_account/get", "好哒到账记录详情");
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/accb/to_account/get", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒到账记录详情");
- return result;
- }
-
-
-
-
-
-
- public string QueryTradeDetail(string mchtNo, string outOrderNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒聚合支付查询");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("outOrderNo", outOrderNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒聚合支付查询");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒聚合支付查询");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒聚合支付查询");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/query_status", "好哒聚合支付查询");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/query_status", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒聚合支付查询");
- return result;
- }
-
-
-
-
-
-
-
- public string QueryRefundDetail(string mchtNo, string storeNo, string outRefundNo, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒退款查询");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("mchtNo", mchtNo);
- reqdic.Add("storeNo", storeNo);
- reqdic.Add("outRefundNo", outRefundNo);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒退款查询");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒退款查询");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒退款查询");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/refund_query", "好哒退款查询");
- string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/refund_query", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒退款查询");
- return result;
- }
-
-
-
-
-
- public string SetFee(string mchtNo, string feeRate, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒商户修改费率");
-
- Dictionary<string, object> request = new Dictionary<string, object>();
- request.Add("mchtNo", mchtNo);
- request.Add("alipayRate", feeRate);
- request.Add("wechatPayRate", feeRate);
- request.Add("unionPayRate", feeRate);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(request);
- LogHelper.Instance.WriteLog(req, "好哒商户修改费率");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒商户修改费率");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒商户修改费率");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/inst/mcht/update_disc", "好哒商户修改费率");
- string result = PostWebRequest(BoxRequestUrl + "/api/inst/mcht/update_disc", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒商户修改费率");
- return result;
- }
- public Dictionary<string, string> GetHeader(string req, int BrandId = 0, string Agent = "1")
- {
- var BoxAppId = HaodaUnionParam.BoxAppId;
- var BoxAppSecret = HaodaUnionParam.BoxAppSecret;
- if (BrandId == 1)
- {
- if(string.IsNullOrEmpty(RedisDbconn.Instance.Get<string>("AgentAppId:" + Agent)))
- {
- BoxAppId = RedisDbconn.Instance.Get<string>("AgentAppId:1");
- BoxAppSecret = RedisDbconn.Instance.Get<string>("AgentAppSecret:1");
- }
- else
- {
- BoxAppId = RedisDbconn.Instance.Get<string>("AgentAppId:" + Agent);
- BoxAppSecret = RedisDbconn.Instance.Get<string>("AgentAppSecret:" + Agent);
- }
- }
- Dictionary<string, string> headdic = new Dictionary<string, string>();
- string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-
-
- headdic.Add("X-Up-AppId", BoxAppId);
- headdic.Add("X-Timestamp", timestamp);
- headdic.Add("X-Sign-Type", "SHA-256");
- headdic.Add("X-Sign", SHA256Sign(timestamp + BoxAppSecret + req));
- return headdic;
- }
- public string SHA256Sign(string toSignStr)
- {
- byte[] toSignByte = Encoding.UTF8.GetBytes(toSignStr);
- SHA256 sha256 = SHA256.Create();
- byte[] signByte = sha256.ComputeHash(toSignByte);
- string sign = Convert.ToBase64String(signByte);
- return sign;
- }
- public bool VerifySign(string toSignStr, string signStr, int BrandId = 0, string AgentTag = "1")
- {
- var BoxPublicKey = HaodaUnionParam.BoxPublicKey;
- if (BrandId == 1) BoxPublicKey = HaodaParam.BoxPublicKey;
- byte[] toSignByte = Encoding.Default.GetBytes(toSignStr);
- byte[] signByte = Convert.FromBase64String(signStr);
- var toKey = Convert.FromBase64String(BoxPublicKey);
- var rsaroot = RSA.Create();
- rsaroot.ImportSubjectPublicKeyInfo(toKey, out _);
- var publicKeyParameters = rsaroot.ExportParameters(false);
- using (var rsa = RSA.Create())
- {
- rsa.ImportParameters(publicKeyParameters);
- var sha256 = SHA256.Create();
- var hash = sha256.ComputeHash(toSignByte);
- return rsa.VerifyHash(hash, signByte, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
- }
- }
- public string SignData(string toSignStr, int BrandId = 0, string AgentTag = "1")
- {
- var BoxPublicKey = HaodaUnionParam.BoxPublicKey;
- if (BrandId == 1) BoxPublicKey = HaodaParam.BoxPublicKey;
- byte[] toSignByte = Encoding.UTF8.GetBytes(toSignStr);
- var toKey = Convert.FromBase64String(BoxPublicKey);
- var rsaroot = RSA.Create();
- rsaroot.ImportSubjectPublicKeyInfo(toKey, out _);
- var publicKeyParameters = rsaroot.ExportParameters(false);
- using (var rsa = RSA.Create())
- {
- rsa.ImportParameters(publicKeyParameters);
- var sha256 = SHA256.Create();
- var hash = sha256.ComputeHash(toSignByte);
- byte[] endByte = rsa.SignData(toSignByte, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
- return Convert.ToBase64String(endByte);
- }
- }
- private string PostWebRequest(string postUrl, string paramData, Dictionary<string, string> headers)
- {
- string ret = string.Empty;
- try
- {
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "请求好哒API日志");
- LogHelper.Instance.WriteLog(postUrl, "请求好哒API日志");
- LogHelper.Instance.WriteLog(paramData, "请求好哒API日志");
- byte[] postData = System.Text.Encoding.UTF8.GetBytes(paramData);
-
- System.Net.HttpWebRequest request = System.Net.WebRequest.Create(postUrl) as System.Net.HttpWebRequest;
- System.Text.Encoding myEncoding = System.Text.Encoding.UTF8;
- request.Method = "POST";
- request.KeepAlive = false;
- request.AllowAutoRedirect = true;
- request.ContentType = "application/json";
- foreach (string key in headers.Keys)
- {
- request.Headers.Add(key, headers[key]);
- }
- request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
- request.ContentLength = postData.Length;
-
- System.IO.Stream outputStream = request.GetRequestStream();
- outputStream.Write(postData, 0, postData.Length);
- outputStream.Close();
- System.Net.HttpWebResponse response;
- System.IO.Stream responseStream;
- System.IO.StreamReader reader;
- string srcString;
- response = request.GetResponse() as System.Net.HttpWebResponse;
- responseStream = response.GetResponseStream();
- reader = new System.IO.StreamReader(responseStream, System.Text.Encoding.UTF8);
- srcString = reader.ReadToEnd();
- ret = srcString;
- reader.Close();
- LogHelper.Instance.WriteLog(srcString, "请求好哒API日志");
- }
- catch (System.Net.WebException ex)
- {
- System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)ex.Response;
- System.IO.Stream myResponseStream = response.GetResponseStream();
-
- System.IO.StreamReader myStreamReader = new System.IO.StreamReader(myResponseStream);
- ret = myStreamReader.ReadToEnd();
- myResponseStream.Close();
- }
- catch (Exception ex)
- {
- ret = "fail";
- LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "请求好哒API异常");
- }
- return ret;
- }
-
-
-
-
-
-
- public string GetToken(string fileName, string action, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒获取文件令牌接口");
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
- reqdic.Add("fileName", fileName);
- reqdic.Add("action", action);
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
- LogHelper.Instance.WriteLog(req, "好哒获取文件令牌接口");
- Dictionary<string, string> headdic = GetHeader(req, BrandId, AgentTag);
- string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
- LogHelper.Instance.WriteLog("请求头\n" + head, "好哒获取文件令牌接口");
- LogHelper.Instance.WriteLog("请求参数\n" + req, "好哒获取文件令牌接口");
- LogHelper.Instance.WriteLog("请求地址:" + BoxRequestUrl + "/api/auth/v1/get_file_token", "好哒获取文件令牌接口");
- string result = PostWebRequest(BoxRequestUrl + "/api/auth/v1/get_file_token", req, headdic);
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒获取文件令牌接口");
- return result;
- }
-
-
-
-
-
-
-
-
- public string DoPost(string url, string token, IDictionary<string, string> textParams, IDictionary<string, FileItem> fileParams, string charset = "utf-8")
- {
-
- if (fileParams == null || fileParams.Count == 0)
- {
- return "";
- }
- string boundary = DateTime.Now.Ticks.ToString("X");
- HttpWebRequest req = GetWebRequest(url, "POST");
- req.Headers.Add("X-File-Token", token);
- req.ContentType = "multipart/form-data;charset=" + charset + ";boundary=" + boundary;
- Stream reqStream = req.GetRequestStream();
- byte[] itemBoundaryBytes = Encoding.GetEncoding(charset).GetBytes("\r\n--" + boundary + "\r\n");
- byte[] endBoundaryBytes = Encoding.GetEncoding(charset).GetBytes("\r\n--" + boundary + "--\r\n");
-
- string textTemplate = "Content-Disposition:form-data;name=\"{0}\"\r\nContent-Type:text/plain\r\n\r\n{1}";
- IEnumerator<KeyValuePair<string, string>> textEnum = textParams.GetEnumerator();
- while (textEnum.MoveNext())
- {
- string textEntry = string.Format(textTemplate, textEnum.Current.Key, textEnum.Current.Value);
- byte[] itemBytes = Encoding.GetEncoding(charset).GetBytes(textEntry);
- reqStream.Write(itemBoundaryBytes, 0, itemBoundaryBytes.Length);
- reqStream.Write(itemBytes, 0, itemBytes.Length);
- }
-
- string fileTemplate = "Content-Disposition:form-data;name=\"{0}\";filename=\"{1}\"\r\nContent-Type:{2}\r\n\r\n";
- IEnumerator<KeyValuePair<string, FileItem>> fileEnum = fileParams.GetEnumerator();
- while (fileEnum.MoveNext())
- {
- string key = fileEnum.Current.Key;
- FileItem fileItem = fileEnum.Current.Value;
- string fileEntry = string.Format(fileTemplate, key, fileItem.GetFileName(), fileItem.GetMimeType());
- byte[] itemBytes = Encoding.GetEncoding(charset).GetBytes(fileEntry);
- reqStream.Write(itemBoundaryBytes, 0, itemBoundaryBytes.Length);
- reqStream.Write(itemBytes, 0, itemBytes.Length);
- byte[] fileBytes = fileItem.GetContent();
- reqStream.Write(fileBytes, 0, fileBytes.Length);
- }
- reqStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
- reqStream.Close();
- HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
- Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet);
- return GetResponseAsString(rsp, encoding);
- }
- public HttpWebRequest GetWebRequest(string url, string method)
- {
- HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
- req.ServicePoint.Expect100Continue = false;
- req.Method = method;
- req.KeepAlive = true;
- req.Timeout = 100000;
- return req;
- }
-
-
-
-
-
-
- public string GetResponseAsString(HttpWebResponse rsp, Encoding encoding)
- {
- StringBuilder result = new StringBuilder();
- Stream stream = null;
- StreamReader reader = null;
- try
- {
-
- stream = rsp.GetResponseStream();
- reader = new StreamReader(stream, encoding);
-
- int ch = -1;
- while ((ch = reader.Read()) > -1)
- {
-
- char c = (char)ch;
- if (c != '\0')
- {
- result.Append(c);
- }
- }
- }
- finally
- {
-
- if (reader != null) reader.Close();
- if (stream != null) stream.Close();
- if (rsp != null) rsp.Close();
- }
- return result.ToString();
- }
-
-
-
-
-
-
- public string ReturnFileName(string token, string value, int BrandId = 0, string AgentTag = "1")
- {
- var BoxRequestUrl = HaodaUnionParam.BoxRequestUrl;
- if (BrandId == 1) BoxRequestUrl = HaodaParam.BoxRequestUrl;
- Dictionary<string, string> file = new Dictionary<string, string>();
- file.Add("fileName", value.Substring(value.LastIndexOf("/")).Trim('/'));
- if (string.IsNullOrEmpty(value.Split(',')[0]))
- {
- return "";
- }
- FileItem item = PublicFunction.GetNetFileItem(AppConfig.Base.OssHost + value.Split(',')[0]);
-
- Dictionary<string, FileItem> files = new Dictionary<string, FileItem>();
- files.Add("file", item);
- var upLoadInfo = JsonMapper.ToObject(HaoDaHelper.Instance.DoPost(BoxRequestUrl + "/api/file/v1/upload_file", token, file, files, "utf-8"));
- if (upLoadInfo["code"].ToString() == "1")
- {
- return upLoadInfo["data"]["fileName"].ToString();
- }
- else
- {
- return "false";
- }
- }
- #endregion
- }
- }
|