using Newtonsoft.Json; using PTMedicalInsurance.Variables; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace PTMedicalInsurance.CardReaders { class NationECCodeAPI { private string url { get; set; } //电子凭证 [DllImport("NationECCode.dll", EntryPoint = "NationEcTrans", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] static extern IntPtr NationEcTrans(StringBuilder strUrl, StringBuilder InData, StringBuilder OutData); public NationECCodeAPI(string _url) { url = _url; } public int NationEcTrans(NationECInput nationECInput, out string output ) { StringBuilder sbURL = new StringBuilder(url); StringBuilder sbInput = new StringBuilder(JsonConvert.SerializeObject(nationECInput)); StringBuilder sbOut = new StringBuilder(40960); IntPtr pInt = NationEcTrans(sbURL, sbInput, sbOut); output = sbOut.ToString(); Global.writeLog($"NationEcTrans({url})", JsonConvert.SerializeObject(nationECInput),output); string str = Marshal.PtrToStringAnsi(pInt); if (str == "0000") { return 0; } else { return -1; } } } class NationECInput { /// /// 机构代码 /// public string orgId { get; set; } /// /// 交易类型 /// public string transType { get; set; } /// /// 请求参数 /// public NationECData data { get; set; } /// /// 扩展参数 /// public string extra { get; set; } } class NationECData { /// /// 医保定点机构代码 /// public string orgId { get; set; } /// /// 用码业务类型 /// public string businessType { get; set; } /// /// 用码业务信息 /// public string businessInfo { get; set; } /// /// 收款员编号 /// public object operatorId { get; set; } /// /// 收款员姓名 /// public string operatorName { get; set; } /// /// 医保科室编号 /// public string officeId { get; set; } /// /// 科室名称 /// public string officeName { get; set; } /// /// 人脸照片 字符 100k /// public string photoData { get; set; } /// /// 扩展参数 /// public string extData { get; set; } } class EcQueryData:NationECData { /// /// 设备类型 /// public string deviceType { get; set; } } class QrcodeGetData : NationECData { /// /// 定点医药机构本次业务流水号 /// public string outBizNo { get; set; } /// /// 设备类型 /// public string deviceType { get; set; } } class AuthCheckData : NationECData { /// /// 定点医药机构本次业务流水号 不可重复,每次请求都需要唯一 /// public string outBizNo { get; set; } /// /// 实 人 认证 业 务流水号 医保综合服务终端返回的授权码 /// public string authNo { get; set; } /// /// 设备类型 /// public string deviceType { get; set; } } }