资源简介
js加签一般都没有问题,我就是加签之后上传的问题弄了两个礼拜,最后弄清楚了。
以下是数据上报海关方法,我用的是.net的web方式:
1.添加三个引用,见dll文件夹。
2.加载我写的类:两个cs文件(放到web目录下)
3.组织上报数据实体格式如下
public class payExchangeInfoLists
{
public string orderNo { get; set; }//String 订单编号
public List goodsInfo { get; set; }// List 商品信息
public string recpAccount { get; set; }// String 收款账号
public string recpCode { get; set; }// String 收款企业代码
public string recpName { get; set; }// String 收款企业名称
}
public class goodsInfo
{
public string gname { get; set; }// String 商品名称
public string itemLink { get; set; }// String 商品展示链接地址
}
public class payExchangeInfoHead
{
public string guid { get; set; }// String 系统唯一序号
public string initalRequest { get; set; }// String 原始请求
public string initalResponse { get; set; }// String 原始响应
public string ebpCode { get; set; }// String 电商平台代码
public string payCode { get; set; }// String 支付企业代码
public string payTransactionId { get; set; }// String 交易流水号
public double totalAmount { get; set; }// double 交易金额
public string currency { get; set; }// String 币制
public string verDept { get; set; }// String 验核机构
public string payType { get; set; }// String 支付类型
public string tradingTime { get; set; }// String 交易成功时间
public string note { get; set; }// String 备注
}
public class payExInfoStr
{
public string sessionID { get; set; }// string Y In 海关发起请求时,平台接收的会话ID。
public payExchangeInfoHead payExchangeInfoHead { get; set; }// String Y In 支付原始数据表头
public List payExchangeInfoLists { get; set; }// List Y In 支付原始数据表体
public string serviceTime { get; set; }// Long Y In 返回时的系统时间
public string certNo { get; set;
代码片段和文件信息
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using System.Text.Regularexpressions;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Gate179Sign
{
public class _179report
{
public class CustomsPaymentReport
{
private readonly string _customsPaymentReportUrl = “https://swapptest.singlewindow.cn/ceb2grab/grab/realTimeDataUpload“;
// private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
private static ConcurrentDictionary CertCache = new ConcurrentDictionary();
private static Func GetCertCacheKey = (url certKey) => $“{url}{certKey}“;
private static HttpClient HttpClient = new HttpClient(GetCertificateHandler());
private static HttpClientHandler GetCertificateHandler()
{
var handler = new WebRequestHandler();
var provider = new CustomsReportSettingProvider();
var setting = provider.GetCustomsReportSetting();
var key = GetCertCacheKey(setting.CertFilePath setting.CertPassword);
var certStream = CertCache.GetOrAdd(key ReadCertFile(setting.CertFilePath));
X509Certificate2 cert = new X509Certificate2(certStream setting.CertPassword);
handler.ClientCertificates.Add(cert);
return handler;
}
private static byte[] ReadCertFile(string file)
{
using (var fileStream = new FileStream(System.Web.HttpContext.Current.Server.MapPath(file) FileMode.Open))
{
var fileSize = fileStream.Length;
var buffer = new byte[fileSize];
fileStream.Read(buffer 0 buffer.Length);
return buffer;
}
}
///
/// 上报数据
///
///
public async Task Report(Utility.OMSApi.omsclass.payExInfoStr input)// Report(PaymentReportData input)
{
var data = input.ToSpecFormatJsonString();
Utility.LogMgr.Info($“海关上报支付数据:[上报] {data} “);
using (var msg = new HttpRequestMessage(HttpMethod.Post _customsPaymentReportUrl))
{
msg.Content = new FormUrlEncodedContent(new[] { new KeyValuePair(“payExInfoStr“ data) });
var response = await HttpClient.SendAsync(msg);
var resp = await response.Content.ReadAsStringAsync();
var result = JsonConvert.Deserializeobject(resp);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8311 2019-04-23 11:17 179report.cs
文件 1398 2019-04-23 11:05 AsyncHelper.cs
文件 2598 2019-04-23 11:21 readme.txt
文件 27648 2017-01-29 15:38 dll\Nito.AsyncEx.Concurrent.dll
文件 29722 2017-01-29 15:38 dll\Nito.AsyncEx.Concurrent.xm
文件 96256 2017-01-29 15:38 dll\Nito.AsyncEx.dll
文件 8192 2017-01-29 15:38 dll\Nito.AsyncEx.Enlightenment.dll
文件 583 2017-01-29 15:38 dll\Nito.AsyncEx.Enlightenment.xm
文件 246620 2017-01-29 15:38 dll\Nito.AsyncEx.xm
目录 0 2019-04-23 11:09 dll
----------- --------- ---------- ----- ----
421328 10
- 上一篇:Qt:利用ntp服务器获取网络时间
- 下一篇:分布式的PCA
评论
共有 条评论