|
@@ -1,20 +1,15 @@
|
|
|
-using System.Net.Mime;
|
|
|
|
|
-using System;
|
|
|
|
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
|
+using System.Net;
|
|
|
using System.Security.Cryptography;
|
|
using System.Security.Cryptography;
|
|
|
using System.Text;
|
|
using System.Text;
|
|
|
-using Library;
|
|
|
|
|
-using System.Net;
|
|
|
|
|
-using System.IO;
|
|
|
|
|
using Aop.Api.Util;
|
|
using Aop.Api.Util;
|
|
|
-using LitJson;
|
|
|
|
|
|
|
+using Library;
|
|
|
|
|
|
|
|
namespace MySystem
|
|
namespace MySystem
|
|
|
{
|
|
{
|
|
|
- /// <summary>
|
|
|
|
|
- /// 好哒相关接口
|
|
|
|
|
- /// </summary>
|
|
|
|
|
public class HaoDaHelper
|
|
public class HaoDaHelper
|
|
|
{
|
|
{
|
|
|
public readonly static HaoDaHelper Instance = new HaoDaHelper();
|
|
public readonly static HaoDaHelper Instance = new HaoDaHelper();
|
|
@@ -22,6 +17,7 @@ namespace MySystem
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
#region 盒易付
|
|
#region 盒易付
|
|
|
|
|
|
|
|
//测试环境
|
|
//测试环境
|
|
@@ -36,98 +32,160 @@ namespace MySystem
|
|
|
string BoxAppId = "AP7175619323825451008";
|
|
string BoxAppId = "AP7175619323825451008";
|
|
|
string BoxAppSecret = "hUfR53gdjyfiZTBR5bILanMqRD1dXD7y";
|
|
string BoxAppSecret = "hUfR53gdjyfiZTBR5bILanMqRD1dXD7y";
|
|
|
string BoxPublicKey = "";
|
|
string BoxPublicKey = "";
|
|
|
- public static string BrhCode = "030145";
|
|
|
|
|
|
|
+ string BrhCode = "030145";
|
|
|
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// 分账接收方账户余额查询
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- /// <param name="acctNo">账户号</param>
|
|
|
|
|
- /// <returns></returns>
|
|
|
|
|
- public string QueryAccountBalance(string acctNo)
|
|
|
|
|
|
|
+ public string BoxServiceFee(string SnList, string ServiceFee)
|
|
|
{
|
|
{
|
|
|
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账接收方账户余额查询");
|
|
|
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString(), "设置盒易付机具服务费");
|
|
|
|
|
+ function.WriteLog(SnList, "设置盒易付机具服务费");
|
|
|
Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
+ string batchNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
|
|
|
|
|
|
|
|
- reqdic.Add("acctNo", acctNo); // 账户号
|
|
|
|
|
-
|
|
|
|
|
|
|
+ reqdic.Add("snList", SnList.Split(',').ToList());//终端列表
|
|
|
|
|
+ if (ServiceFee != "0")
|
|
|
|
|
+ {
|
|
|
|
|
+ ServiceFee += "00";
|
|
|
|
|
+ }
|
|
|
|
|
+ reqdic.Add("depositGear", ServiceFee);//押金档位
|
|
|
|
|
+ reqdic.Add("modelId", "MHN10916");//费率,固定0.6
|
|
|
|
|
+ reqdic.Add("brhCode", BrhCode);//机构号
|
|
|
|
|
+ reqdic.Add("batchNo", batchNo);//批次号
|
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
- LogHelper.Instance.WriteLog(req, "好哒分账接收方账户余额查询");
|
|
|
|
|
- Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
- 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/balance/get", "好哒分账接收方账户余额查询");
|
|
|
|
|
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/balance/get", req, headdic);
|
|
|
|
|
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账接收方账户余额查询");
|
|
|
|
|
|
|
|
|
|
|
|
+ Dictionary<string, string> headdic = GetHeader(reqdic);
|
|
|
|
|
+ string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
|
|
|
|
|
+ function.WriteLog("请求头\n" + head, "设置盒易付机具服务费");
|
|
|
|
|
+ function.WriteLog("请求参数\n" + req, "设置盒易付机具服务费");
|
|
|
|
|
+ function.WriteLog("请求地址:" + BoxRequestUrl + "/inst/register/terms", "设置盒易付机具服务费");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/inst/register/terms", req, headdic);
|
|
|
|
|
+ function.WriteLog("返回\n" + result + "\n\n", "设置盒易付机具服务费");
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ #region 上传图片接口
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 分账接收方提现申请
|
|
|
|
|
|
|
+ /// 执行带文件上传的HTTP POST请求。
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- /// <param name="applyNo">申请批次号</param>
|
|
|
|
|
- /// <param name="acctNo">账户号</param>
|
|
|
|
|
- /// <param name="amount">提现金额(分)</param>
|
|
|
|
|
- /// <returns></returns>
|
|
|
|
|
- public string ApplyWithdrawal(string applyNo, string acctNo, string amount)
|
|
|
|
|
|
|
+ /// <param name="url">请求地址</param>
|
|
|
|
|
+ /// <param name="textParams">请求文本参数</param>
|
|
|
|
|
+ /// <param name="fileParams">请求文件参数</param>
|
|
|
|
|
+ /// <param name="charset">编码字符集</param>
|
|
|
|
|
+ /// <returns>HTTP响应</returns>
|
|
|
|
|
+ public string DoPost(string url, string token, IDictionary<string, string> textParams, IDictionary<string, FileItem> fileParams, string charset = "utf-8")
|
|
|
{
|
|
{
|
|
|
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账接收方提现申请");
|
|
|
|
|
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
|
|
+ // 如果没有文件参数,则走普通POST请求
|
|
|
|
|
+ if (fileParams == null || fileParams.Count == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- reqdic.Add("applyNo", applyNo); // 申请批次号
|
|
|
|
|
- reqdic.Add("acctNo", acctNo); // 账户号
|
|
|
|
|
- reqdic.Add("amount", amount); // 提现金额(分)
|
|
|
|
|
|
|
+ string boundary = DateTime.Now.Ticks.ToString("X"); // 随机分隔线
|
|
|
|
|
|
|
|
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
- LogHelper.Instance.WriteLog(req, "好哒分账接收方提现申请");
|
|
|
|
|
- Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
- 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/withdrawal/apply", "好哒分账接收方提现申请");
|
|
|
|
|
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/withdrawal/apply", req, headdic);
|
|
|
|
|
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账接收方提现申请");
|
|
|
|
|
|
|
+ HttpWebRequest req = GetWebRequest(url, "POST");
|
|
|
|
|
+ req.Headers.Add("X-File-Token", token);
|
|
|
|
|
+ req.ContentType = "multipart/form-data;charset=" + charset + ";boundary=" + boundary;
|
|
|
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ 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;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 分账接收方提现结果查询
|
|
|
|
|
|
|
+ /// 把响应流转换为文本。
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- /// <param name="applyNo">申请批次号</param>
|
|
|
|
|
- /// <param name="acctNo">账户号</param>
|
|
|
|
|
- /// <returns></returns>
|
|
|
|
|
- public string QueryApplyWithdrawalStatus(string applyNo, string acctNo)
|
|
|
|
|
|
|
+ /// <param name="rsp">响应流对象</param>
|
|
|
|
|
+ /// <param name="encoding">编码方式</param>
|
|
|
|
|
+ /// <returns>响应文本</returns>
|
|
|
|
|
+ public string GetResponseAsString(HttpWebResponse rsp, Encoding encoding)
|
|
|
{
|
|
{
|
|
|
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账接收方提现结果查询");
|
|
|
|
|
- Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
|
|
+ StringBuilder result = new StringBuilder();
|
|
|
|
|
+ Stream stream = null;
|
|
|
|
|
+ StreamReader reader = null;
|
|
|
|
|
|
|
|
- reqdic.Add("applyNo", applyNo); // 申请批次号
|
|
|
|
|
- reqdic.Add("acctNo", acctNo); // 账户号
|
|
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ // 以字符流的方式读取HTTP响应
|
|
|
|
|
+ stream = rsp.GetResponseStream();
|
|
|
|
|
+ reader = new StreamReader(stream, encoding);
|
|
|
|
|
|
|
|
- string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
- LogHelper.Instance.WriteLog(req, "好哒分账接收方提现结果查询");
|
|
|
|
|
- Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
- 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/withdrawal/query", "好哒分账接收方提现结果查询");
|
|
|
|
|
- string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/withdrawal/query", req, headdic);
|
|
|
|
|
- LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账接收方提现结果查询");
|
|
|
|
|
|
|
+ // 按字符读取并写入字符串缓冲
|
|
|
|
|
+ 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;
|
|
|
|
|
|
|
+ return result.ToString();
|
|
|
}
|
|
}
|
|
|
|
|
+ #endregion
|
|
|
|
|
|
|
|
- public Dictionary<string, string> GetHeader(string req)
|
|
|
|
|
|
|
+ public Dictionary<string, string> GetHeader(Dictionary<string, object> reqdic)
|
|
|
{
|
|
{
|
|
|
Dictionary<string, string> headdic = new Dictionary<string, string>();
|
|
Dictionary<string, string> headdic = new Dictionary<string, string>();
|
|
|
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
- // headdic.Add("appid", BoxAppId);//开发者id
|
|
|
|
|
- // headdic.Add("appsecret", BoxAppSecret);//开发者密码
|
|
|
|
|
|
|
+ headdic.Add("appid", BoxAppId);//开发者id
|
|
|
|
|
+ headdic.Add("appsecret", BoxAppSecret);//开发者密码
|
|
|
headdic.Add("X-Up-AppId", BoxAppId);
|
|
headdic.Add("X-Up-AppId", BoxAppId);
|
|
|
headdic.Add("X-Timestamp", timestamp);
|
|
headdic.Add("X-Timestamp", timestamp);
|
|
|
headdic.Add("X-Sign-Type", "SHA-256");
|
|
headdic.Add("X-Sign-Type", "SHA-256");
|
|
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
headdic.Add("X-Sign", SHA256Sign(timestamp + BoxAppSecret + req));
|
|
headdic.Add("X-Sign", SHA256Sign(timestamp + BoxAppSecret + req));
|
|
|
return headdic;
|
|
return headdic;
|
|
|
}
|
|
}
|
|
@@ -180,9 +238,9 @@ namespace MySystem
|
|
|
string ret = string.Empty;
|
|
string ret = string.Empty;
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "请求好哒API日志");
|
|
|
|
|
- LogHelper.Instance.WriteLog(postUrl, "请求好哒API日志");
|
|
|
|
|
- LogHelper.Instance.WriteLog(paramData, "请求好哒API日志");
|
|
|
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString(), "好哒API日志");
|
|
|
|
|
+ function.WriteLog(postUrl, "好哒API日志");
|
|
|
|
|
+ function.WriteLog(paramData, "好哒API日志");
|
|
|
byte[] postData = System.Text.Encoding.UTF8.GetBytes(paramData);
|
|
byte[] postData = System.Text.Encoding.UTF8.GetBytes(paramData);
|
|
|
// 设置提交的相关参数
|
|
// 设置提交的相关参数
|
|
|
System.Net.HttpWebRequest request = System.Net.WebRequest.Create(postUrl) as System.Net.HttpWebRequest;
|
|
System.Net.HttpWebRequest request = System.Net.WebRequest.Create(postUrl) as System.Net.HttpWebRequest;
|
|
@@ -213,7 +271,7 @@ namespace MySystem
|
|
|
srcString = reader.ReadToEnd();
|
|
srcString = reader.ReadToEnd();
|
|
|
ret = srcString; //返回值赋值
|
|
ret = srcString; //返回值赋值
|
|
|
reader.Close();
|
|
reader.Close();
|
|
|
- LogHelper.Instance.WriteLog(srcString, "请求好哒API日志");
|
|
|
|
|
|
|
+ function.WriteLog(srcString, "好哒API日志");
|
|
|
}
|
|
}
|
|
|
catch (System.Net.WebException ex)
|
|
catch (System.Net.WebException ex)
|
|
|
{
|
|
{
|
|
@@ -227,180 +285,256 @@ namespace MySystem
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|
|
|
ret = "fail";
|
|
ret = "fail";
|
|
|
- LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "请求好哒API异常");
|
|
|
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "好哒API异常");
|
|
|
}
|
|
}
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 获取文件令牌接口
|
|
|
|
|
|
|
+ /// 微信公众号和小程序支付接口
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- /// <param name="fileName">文件名</param>
|
|
|
|
|
- /// <param name="action">操作类型 0 上传图片</param>
|
|
|
|
|
|
|
+ /// <param name="mchtNo">盒子的商户编号</param>
|
|
|
|
|
+ /// <param name="storeNo">盒子的门店编码</param>
|
|
|
|
|
+ /// <param name="outOrderNo">商户订单号</param>
|
|
|
|
|
+ /// <param name="transAmount">交易金额,单位:分</param>
|
|
|
|
|
+ /// <param name="callbackUrl">交易完成之后,商户接收交易结果通知的地址</param>
|
|
|
|
|
+ /// <param name="subOpenId">用户子标识</param>
|
|
|
|
|
+ /// <param name="confirmCode">支付确认码</param>
|
|
|
|
|
+ /// <param name="subAppId">公众号或者小程序appId</param>
|
|
|
|
|
+ /// <param name="subAppIdType">对应的类型,默认为公众号, SUBSCRIPTION: 公众号 MINI_PROGRAM: 小程序</param>
|
|
|
|
|
+ /// <param name="ledgerModel">分账类型:1不分账 2分账,注意只有开通了分账才能传这个字段</param>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
- public string GetToken(string fileName, string action)
|
|
|
|
|
|
|
+ public string WeChatPay(string mchtNo, string storeNo, string outOrderNo, decimal transAmount, string callbackUrl, string subOpenId, string confirmCode, string subAppId, string subAppIdType, string ledgerModel)
|
|
|
{
|
|
{
|
|
|
- LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒获取文件令牌接口");
|
|
|
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString(), "好哒微信公众号和小程序支付");
|
|
|
Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
-
|
|
|
|
|
- reqdic.Add("fileName", fileName); // 文件名
|
|
|
|
|
- reqdic.Add("action", action); // 操作类型 0 上传图片
|
|
|
|
|
|
|
+ reqdic.Add("mchtNo", mchtNo); //盒子的商户编号
|
|
|
|
|
+ reqdic.Add("storeNo", storeNo); //盒子的门店编码
|
|
|
|
|
+ reqdic.Add("outOrderNo", outOrderNo); //商户订单号
|
|
|
|
|
+ int payAmount = (int)(transAmount * 100);
|
|
|
|
|
+ reqdic.Add("transAmount", payAmount); //交易金额,单位:分
|
|
|
|
|
+ reqdic.Add("callbackUrl", callbackUrl); //交易完成之后,商户接收交易结果通知的地址
|
|
|
|
|
+ reqdic.Add("subOpenId", subOpenId); //用户子标识
|
|
|
|
|
+ reqdic.Add("confirmCode", confirmCode); //支付确认码,由4位纯数字组成,每次请求时随机生成
|
|
|
|
|
+ reqdic.Add("subAppId", subAppId); //公众号或者小程序appId
|
|
|
|
|
+ reqdic.Add("subAppIdType", subAppIdType); //subAppId 对应的类型,默认为公众号, SUBSCRIPTION: 公众号 MINI_PROGRAM: 小程序
|
|
|
|
|
+ reqdic.Add("ledgerModel", ledgerModel); //分账类型:1不分账 2分账,注意只有开通了分账才能传这个字段
|
|
|
|
|
|
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
- LogHelper.Instance.WriteLog(req, "好哒获取文件令牌接口");
|
|
|
|
|
|
|
+ function.WriteLog(req, "好哒微信公众号和小程序支付");
|
|
|
Dictionary<string, string> headdic = GetHeader(req);
|
|
Dictionary<string, string> headdic = GetHeader(req);
|
|
|
string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
|
|
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", "好哒获取文件令牌接口");
|
|
|
|
|
|
|
+ function.WriteLog("请求头\n" + head, "好哒微信公众号和小程序支付");
|
|
|
|
|
+ function.WriteLog("请求参数\n" + req, "好哒微信公众号和小程序支付");
|
|
|
|
|
+ function.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", "好哒微信公众号和小程序支付");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/wechat_js_pay", req, headdic);
|
|
|
|
|
+ function.WriteLog("返回\n" + result + "\n\n", "好哒微信公众号和小程序支付");
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 执行带文件上传的HTTP POST请求。
|
|
|
|
|
|
|
+ /// 支付宝服务窗支付接口
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- /// <param name="url">请求地址</param>
|
|
|
|
|
- /// <param name="textParams">请求文本参数</param>
|
|
|
|
|
- /// <param name="fileParams">请求文件参数</param>
|
|
|
|
|
- /// <param name="charset">编码字符集</param>
|
|
|
|
|
- /// <returns>HTTP响应</returns>
|
|
|
|
|
- public string DoPost(string url, string token, IDictionary<string, string> textParams, IDictionary<string, FileItem> fileParams, string charset = "utf-8")
|
|
|
|
|
|
|
+ /// <param name="mchtNo">盒子的商户编号</param>
|
|
|
|
|
+ /// <param name="storeNo">盒子的门店编码</param>
|
|
|
|
|
+ /// <param name="outOrderNo">商户订单号</param>
|
|
|
|
|
+ /// <param name="transAmount">交易金额,单位:分</param>
|
|
|
|
|
+ /// <param name="callbackUrl">交易完成之后,商户接收交易结果通知的地址</param>
|
|
|
|
|
+ /// <param name="subOpenId">支付宝用户标识</param>
|
|
|
|
|
+ /// <param name="confirmCode">支付确认码,由4位纯数字组成,每次请求时随机生成</param>
|
|
|
|
|
+ /// <param name="ledgerModel">分账类型:1不分账 2分账,注意只有开通了分账才能传这个字段</param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ public string Alipay(string mchtNo, string storeNo, string outOrderNo, decimal transAmount, string callbackUrl, string subOpenId, string confirmCode, string ledgerModel)
|
|
|
{
|
|
{
|
|
|
- // 如果没有文件参数,则走普通POST请求
|
|
|
|
|
- if (fileParams == null || fileParams.Count == 0)
|
|
|
|
|
- {
|
|
|
|
|
- return "";
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString(), "好哒支付宝服务窗支付");
|
|
|
|
|
+ Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
+ reqdic.Add("mchtNo", mchtNo); //盒子的商户编号
|
|
|
|
|
+ reqdic.Add("storeNo", storeNo); //盒子的门店编码
|
|
|
|
|
+ reqdic.Add("outOrderNo", outOrderNo); //商户订单号
|
|
|
|
|
+ int payAmount = (int)(transAmount * 100);
|
|
|
|
|
+ reqdic.Add("transAmount", payAmount); //交易金额,单位:分
|
|
|
|
|
+ reqdic.Add("callbackUrl", callbackUrl); //交易完成之后,商户接收交易结果通知的地址
|
|
|
|
|
+ reqdic.Add("subOpenId", subOpenId); //支付宝用户标识
|
|
|
|
|
+ reqdic.Add("confirmCode", confirmCode); //支付确认码,由4位纯数字组成,每次请求时随机生成
|
|
|
|
|
+ reqdic.Add("ledgerModel", ledgerModel); //分账类型:1不分账 2分账,注意只有开通了分账才能传这个字段
|
|
|
|
|
|
|
|
- string boundary = DateTime.Now.Ticks.ToString("X"); // 随机分隔线
|
|
|
|
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
+ function.WriteLog(req, "好哒支付宝服务窗支付");
|
|
|
|
|
+ Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
+ string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
|
|
|
|
|
+ function.WriteLog("请求头\n" + head, "好哒支付宝服务窗支付");
|
|
|
|
|
+ function.WriteLog("请求参数\n" + req, "好哒支付宝服务窗支付");
|
|
|
|
|
+ function.WriteLog("请求地址:" + BoxRequestUrl + "/api/hzg/v2/unitedtrade/ali_js_pay", "好哒支付宝服务窗支付");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/api/hzg/v2/unitedtrade/ali_js_pay", req, headdic);
|
|
|
|
|
+ function.WriteLog("返回\n" + result + "\n\n", "好哒支付宝服务窗支付");
|
|
|
|
|
|
|
|
- HttpWebRequest req = GetWebRequest(url, "POST");
|
|
|
|
|
- req.Headers.Add("X-File-Token", token);
|
|
|
|
|
- req.ContentType = "multipart/form-data;charset=" + charset + ";boundary=" + boundary;
|
|
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- 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");
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 好哒到账记录查询
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="mchtNo">商户号</param>
|
|
|
|
|
+ /// <param name="startTime">查询开始时间(yyyy-MM-dd)</param>
|
|
|
|
|
+ /// <param name="endTime">查询结束时间(yyyy-MM-dd),最大查询时间区间31天</param>
|
|
|
|
|
+ /// <param name="tradeMchtNo">收单商户号(15位)</param>
|
|
|
|
|
+ /// <param name="cardNo">结算卡号</param>
|
|
|
|
|
+ /// <param name="settleStatus">出款状态(0:入账成功、1:入账失败、2:结算超时、3:入账受理成功、4:已提交结算请求)</param>
|
|
|
|
|
+ /// <param name="page">当前页数,默认1</param>
|
|
|
|
|
+ /// <param name="rows">每页大小,默认10,最大500</param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ public string CardInComeRecord(string mchtNo, string startTime, string endTime, string tradeMchtNo, string cardNo, string settleStatus, string page, string rows)
|
|
|
|
|
+ {
|
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString(), "好哒到账记录查询");
|
|
|
|
|
+ Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
+ reqdic.Add("mchtNo", mchtNo); //商户号
|
|
|
|
|
+ reqdic.Add("startTime", startTime); //查询开始时间(yyyy-MM-dd)
|
|
|
|
|
+ reqdic.Add("endTime", endTime); //查询结束时间(yyyy-MM-dd),最大查询时间区间31天
|
|
|
|
|
+ reqdic.Add("tradeMchtNo", tradeMchtNo); //收单商户号(15位)
|
|
|
|
|
+ reqdic.Add("cardNo", cardNo); //结算卡号
|
|
|
|
|
+ reqdic.Add("settleStatus", settleStatus); //出款状态(0:入账成功、1:入账失败、2:结算超时、3:入账受理成功、4:已提交结算请求)
|
|
|
|
|
+ reqdic.Add("page", page); //当前页数,默认1
|
|
|
|
|
+ reqdic.Add("rows", rows); //每页大小,默认10,最大500
|
|
|
|
|
|
|
|
- // 组装文本请求参数
|
|
|
|
|
- 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 req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
+ function.WriteLog(req, "好哒到账记录查询");
|
|
|
|
|
+ Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
+ string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
|
|
|
|
|
+ function.WriteLog("请求头\n" + head, "好哒到账记录查询");
|
|
|
|
|
+ function.WriteLog("请求参数\n" + req, "好哒到账记录查询");
|
|
|
|
|
+ function.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/accb/to_account/query", "好哒到账记录查询");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/accb/to_account/query", req, headdic);
|
|
|
|
|
+ function.WriteLog("返回\n" + result + "\n\n", "好哒到账记录查询");
|
|
|
|
|
|
|
|
- // 组装文件请求参数
|
|
|
|
|
- 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);
|
|
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- byte[] fileBytes = fileItem.GetContent();
|
|
|
|
|
- reqStream.Write(fileBytes, 0, fileBytes.Length);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 好哒到账记录详情
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="mchtNo">商户号</param>
|
|
|
|
|
+ /// <param name="id">id</param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ public string CardInComeDetail(string mchtNo, string id)
|
|
|
|
|
+ {
|
|
|
|
|
+ function.WriteLog(DateTime.Now.ToString(), "好哒到账记录详情");
|
|
|
|
|
+ Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
+ reqdic.Add("mchtNo", mchtNo); //商户号
|
|
|
|
|
+ reqdic.Add("id", id); //id
|
|
|
|
|
|
|
|
- reqStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
|
|
|
|
|
- reqStream.Close();
|
|
|
|
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
+ function.WriteLog(req, "好哒到账记录详情");
|
|
|
|
|
+ Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
+ string head = Newtonsoft.Json.JsonConvert.SerializeObject(headdic);
|
|
|
|
|
+ function.WriteLog("请求头\n" + head, "好哒到账记录详情");
|
|
|
|
|
+ function.WriteLog("请求参数\n" + req, "好哒到账记录详情");
|
|
|
|
|
+ function.WriteLog("请求地址:" + BoxRequestUrl + "/api/v3/hzg/accb/to_account/get", "好哒到账记录详情");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/accb/to_account/get", req, headdic);
|
|
|
|
|
+ function.WriteLog("返回\n" + result + "\n\n", "好哒到账记录详情");
|
|
|
|
|
|
|
|
- HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
|
|
|
|
|
- Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet);
|
|
|
|
|
- return GetResponseAsString(rsp, encoding);
|
|
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public HttpWebRequest GetWebRequest(string url, string method)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 分账接收方账户余额查询
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="acctNo">账户号</param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ public string QueryAccountBalance(string acctNo)
|
|
|
{
|
|
{
|
|
|
- HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
|
|
|
|
- req.ServicePoint.Expect100Continue = false;
|
|
|
|
|
- req.Method = method;
|
|
|
|
|
- req.KeepAlive = true;
|
|
|
|
|
- req.Timeout = 100000;
|
|
|
|
|
- return req;
|
|
|
|
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账接收方账户余额查询");
|
|
|
|
|
+ Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
+
|
|
|
|
|
+ reqdic.Add("acctNo", acctNo); // 账户号
|
|
|
|
|
+
|
|
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
+ LogHelper.Instance.WriteLog(req, "好哒分账接收方账户余额查询");
|
|
|
|
|
+ Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
+ 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/balance/get", "好哒分账接收方账户余额查询");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/balance/get", req, headdic);
|
|
|
|
|
+ LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账接收方账户余额查询");
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 把响应流转换为文本。
|
|
|
|
|
|
|
+ /// 分账接收方提现申请
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- /// <param name="rsp">响应流对象</param>
|
|
|
|
|
- /// <param name="encoding">编码方式</param>
|
|
|
|
|
- /// <returns>响应文本</returns>
|
|
|
|
|
- public string GetResponseAsString(HttpWebResponse rsp, Encoding encoding)
|
|
|
|
|
|
|
+ /// <param name="applyNo">申请批次号</param>
|
|
|
|
|
+ /// <param name="acctNo">账户号</param>
|
|
|
|
|
+ /// <param name="amount">提现金额(分)</param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ public string ApplyWithdrawal(string applyNo, string acctNo, string amount)
|
|
|
{
|
|
{
|
|
|
- StringBuilder result = new StringBuilder();
|
|
|
|
|
- Stream stream = null;
|
|
|
|
|
- StreamReader reader = null;
|
|
|
|
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账接收方提现申请");
|
|
|
|
|
+ Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- // 以字符流的方式读取HTTP响应
|
|
|
|
|
- stream = rsp.GetResponseStream();
|
|
|
|
|
- reader = new StreamReader(stream, encoding);
|
|
|
|
|
|
|
+ reqdic.Add("applyNo", applyNo); // 申请批次号
|
|
|
|
|
+ reqdic.Add("acctNo", acctNo); // 账户号
|
|
|
|
|
+ reqdic.Add("amount", amount); // 提现金额(分)
|
|
|
|
|
|
|
|
- // 按字符读取并写入字符串缓冲
|
|
|
|
|
- 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();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
+ LogHelper.Instance.WriteLog(req, "好哒分账接收方提现申请");
|
|
|
|
|
+ Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
+ 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/withdrawal/apply", "好哒分账接收方提现申请");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/withdrawal/apply", req, headdic);
|
|
|
|
|
+ LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账接收方提现申请");
|
|
|
|
|
|
|
|
- return result.ToString();
|
|
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// 获取好哒开放平台文件名
|
|
|
|
|
|
|
+ /// 分账接收方提现结果查询
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- /// <param name="token">上传图片凭证token</param>
|
|
|
|
|
- /// <param name="value">图片路径</param>
|
|
|
|
|
|
|
+ /// <param name="applyNo">申请批次号</param>
|
|
|
|
|
+ /// <param name="acctNo">账户号</param>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
- public string ReturnFileName(string token, string value)
|
|
|
|
|
|
|
+ public string QueryApplyWithdrawalStatus(string applyNo, string acctNo)
|
|
|
{
|
|
{
|
|
|
- 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 = new FileItem(function.getPath(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";
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ LogHelper.Instance.WriteLog(DateTime.Now.ToString(), "好哒分账接收方提现结果查询");
|
|
|
|
|
+ Dictionary<string, object> reqdic = new Dictionary<string, object>();
|
|
|
|
|
+
|
|
|
|
|
+ reqdic.Add("applyNo", applyNo); // 申请批次号
|
|
|
|
|
+ reqdic.Add("acctNo", acctNo); // 账户号
|
|
|
|
|
+
|
|
|
|
|
+ string req = Newtonsoft.Json.JsonConvert.SerializeObject(reqdic);
|
|
|
|
|
+ LogHelper.Instance.WriteLog(req, "好哒分账接收方提现结果查询");
|
|
|
|
|
+ Dictionary<string, string> headdic = GetHeader(req);
|
|
|
|
|
+ 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/withdrawal/query", "好哒分账接收方提现结果查询");
|
|
|
|
|
+ string result = PostWebRequest(BoxRequestUrl + "/api/v3/hzg/part/acct/withdrawal/query", req, headdic);
|
|
|
|
|
+ LogHelper.Instance.WriteLog("返回\n" + result + "\n\n", "好哒分账接收方提现结果查询");
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public Dictionary<string, string> GetHeader(string req)
|
|
|
|
|
+ {
|
|
|
|
|
+ Dictionary<string, string> headdic = new Dictionary<string, string>();
|
|
|
|
|
+ string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ // headdic.Add("appid", BoxAppId);//开发者id
|
|
|
|
|
+ // headdic.Add("appsecret", BoxAppSecret);//开发者密码
|
|
|
|
|
+ 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;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|