/// <summary> /// 燃气读卡器判断,06=CRT,未知=GG /// </summary> /// <returns></returns> public static string GasJudge() { SerialPort sPort = new SerialPort(); try { sPort.PortName = "com" + SysConfigHelper.readerNode("CJ201"); //串口的portname sPort.BaudRate = 9600; //串口的波特率 sPort.Open(); byte[] data = new byte[] { 0x02, 0x00, 0x02, 0x30, 0x30, 0x03, 0x03 }; sPort.Write(data, 0, 7); Thread.Sleep(1000); byte[] data3 = new byte[1]; sPort.ReadTimeout = 3000; sPort.Read(data3, 0, 1); return(SysBLL.byteToHexStr(data3)); }catch (Exception ex) { return(""); } finally { if (sPort.IsOpen) { sPort.Close(); } } }
public static void LklWtSign() { PasswordBLL pwdBLL = new PasswordBLL(); bool ret = pwdBLL.OpenDevice(SysConfigHelper.readerNode("ZT598Port"), "9600"); if (ret) { if (!SysBLL.WantongSign()) { SysBLL.wangtonSignResult = false; log.Write("警告:万通签到失败"); } else { SysBLL.wangtonSignResult = true; log.Write("万通签到成功"); } if (!SysBLL.LakalaSign()) { SysBLL.lakalaSignResult = false; log.Write("警告:拉卡拉签到失败"); } else { SysBLL.lakalaSignResult = true; log.Write("拉卡拉签到成功"); } } else { log.Write("警告:键盘打开失败"); } }
/// <summary> /// 冲正 /// </summary> /// <returns></returns> public static Dictionary <string, ResultData> correct(WintopPayParam param) { Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); data.Add(3, "000000"); data.Add(4, countPrice(param.price)); data.Add(11, SysBLL.padLeft(getOrder(), 6)); data.Add(25, "00"); data.Add(39, "17"); data.Add(41, SysConfigHelper.readerNode("ClientNo")); data.Add(42, SysConfigHelper.readerNode("ShopNo")); data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(63, "01"); byte[] sendData = EncryptWT.EncryptData("0400", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0400"))); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); if (result.Length > 0) { return(lk.analysis(result)); //发送数据 } else { return(null); } }
/// <summary> /// 消费 /// </summary> /// <param name="mackey"></param> /// <returns></returns> public static Dictionary <string, ResultData> pay(WintopPayParam param) { Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); //万通卡号 data.Add(3, "000000"); data.Add(4, countPrice(param.price)); //交易金额 data.Add(11, SysBLL.padLeft(getOrder(), 6)); //POS终端交易流水 data.Add(25, "00"); data.Add(41, SysConfigHelper.readerNode("ClientNo")); //终端代码 data.Add(42, SysConfigHelper.readerNode("ShopNo")); //商户代码 data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(62, getPin(param.pwd, param.wintopNo));//明文,卡号 data.Add(63, "01"); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0200"))); //Console.WriteLine(); string datasss = BCDUtil.byteArrToString(sendData); //Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); if (result.Length > 0) { return(lk.analysis(result)); //发送数据 } else { return(null); } }
public static void print(PrintParam param) { StringBuilder outMsg = new StringBuilder(); Print.TT_OpenDevice(new StringBuilder("COM" + SysConfigHelper.readerNode("PrintPort")), new StringBuilder("38400"), outMsg); Print.TT_GetDeviceStatus(outMsg); // Print.TT_PrintText(new StringBuilder("三维终端 快捷支付 便利生活\n"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_PrintText(new StringBuilder(" 兰州三维便民服务终端交易凭条 \n"), outMsg); Print.TT_PrintText(new StringBuilder("--------------------------------"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_PrintText(new StringBuilder("交易类型:" + SysBLL.payTypeName + "\n"), outMsg); Print.TT_PrintText(new StringBuilder("缴费类型:" + param.payType + "缴费\n"), outMsg); Print.TT_PrintText(new StringBuilder("缴费账号:" + param.account + "\n"), outMsg); Print.TT_PrintText(new StringBuilder("交易卡号:" + hideCardNo(param.cardNo) + "\n"), outMsg); Print.TT_PrintText(new StringBuilder("交易终端:" + ConfigurationManager.AppSettings["MechineNo"] + "\n"), outMsg); Print.TT_PrintText(new StringBuilder("交易时间:" + SysBLL.getTimeFormat() + "\n"), outMsg); Print.TT_PrintText(new StringBuilder("支付金额:¥" + param.amout + "\n"), outMsg); Print.TT_PrintText(new StringBuilder("订单编号:" + param.orderno + "\n"), outMsg); // Print.TT_PrintText(new StringBuilder("流水号:" + param.resqn + "\n"), outMsg); Print.TT_PrintText(new StringBuilder("备注:\n"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_PrintText(new StringBuilder("-----------持卡人存根--------\n"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_PrintText(new StringBuilder(" \n"), outMsg); Print.TT_CutPaper(1, outMsg); Print.TT_CloseDevice(outMsg); }
public static string getOrder() { int num = Convert.ToInt32(SysConfigHelper.readerNode("orderNo")); num++; SysBLL.SetAppConfig("orderNo", num.ToString()); return(num.ToString()); }
/// <summary> /// 读卡 /// </summary> /// <returns></returns> public static string readCard() { SysBLL.RunCmd(mainPath + "\\Rd.exe " + SysConfigHelper.readerNode("baggRdPort") + " read"); Thread.Sleep(2000); string cardNo = readerBAGGNode("beianCard"); writeBAGGNode(""); return(cardNo); }
/// <summary> /// 写卡 /// </summary> /// <param name="payType"></param> /// <param name="amount"></param> public static void writeCard(string payType, string amount) { if (payType.Equals("01")) { payType = "00"; } if (payType.Equals("02")) { payType = "01"; } SysBLL.RunCmd(mainPath + "\\BAGG\\Rd.exe " + SysConfigHelper.readerNode("baggRdPort") + " write " + payType + " " + amount + ""); Thread.Sleep(2000); writeBAGGNode(""); }
private static void copyImg(string mainPath, string copyPath) { if (System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "/image/GCImage/leftImg/" + mainPath + "/1.png")) { SysBLL.deleteDirFile("D://payMedia//leftImg//" + copyPath + "//" + getImgMaxPath("D://payMedia//leftImg//" + copyPath)); for (int i = 1; i <= 6; i++) { if (System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "/image/GCImage/leftImg/" + mainPath + "/" + i + ".png")) { System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + "/image/GCImage/leftImg/" + mainPath + "/" + i + ".png", "D://payMedia//leftImg//" + copyPath + "//" + "//" + getImgMaxPath("D://payMedia//leftImg//" + copyPath + "//") + "//" + i + ".png"); } } SysBLL.deleteDirFile(System.AppDomain.CurrentDomain.BaseDirectory + "/image/GCImage/leftImg/" + mainPath); } }
/// <summary> /// 电动读卡器退卡 /// </summary> public static void backCard() { int handle = 0; try { string port = SysConfigHelper.readerNode("CRT310Port"); StringBuilder info = new StringBuilder(1024); handle = CRT310.CommOpen("COM" + port); //进卡控制,不进卡 CRT310.CRT310_CardSetting(handle, 0x1, 0x1); //读卡器状态 Byte atPosition = new byte(); Byte frontSetting = new byte(); Byte rearSetting = new byte(); //读取状态 int hasCard = CRT310.CRT310_GetStatus(handle, ref atPosition, ref frontSetting, ref rearSetting); if ((atPosition == 0x4a) || (atPosition == 0x4b) || (atPosition == 0x4c) || (atPosition == 0x4d) || (atPosition == 0x46) || (atPosition == 0x47) || (atPosition == 0x48)) { //弹卡 CRT310.CRT310_Reset(handle, 1); SysBLL.Player("请保管好您的卡片.wav"); } //进卡控制,不进卡 CRT310.CRT310_CardSetting(handle, 0x1, 0x1); CRT310.TT_EjectCard(0, new StringBuilder()); } catch (ThreadAbortException ex) { log.Write("error:电动读卡器退卡:" + ex.Message); } catch (Exception e) { throw new Exception("系统异常"); } finally { CRT310.CommClose(handle); } }
/// <summary> /// 视频广告路径是否存在 /// </summary> public static void GcMp4FileIsExists() { string filePath = mp4Path; if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); SysBLL.deleteDirFile(filePath); for (int i = 1; i <= 6; i++) { if (System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "/mp4/" + i + ".mp4")) { System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + "/mp4/" + i + ".mp4", mp4Path + "//" + i + ".mp4"); } } SysBLL.deleteDirFile(System.AppDomain.CurrentDomain.BaseDirectory + "/mp4"); } else { //if ("1".Equals(ReadGCStateID())) //{ if (System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "/mp4/1.mp4")) { SysBLL.deleteDirFile(filePath); for (int i = 1; i <= 6; i++) { if (System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "/mp4/" + i + ".mp4")) { System.IO.File.Copy(System.AppDomain.CurrentDomain.BaseDirectory + "/mp4/" + i + ".mp4", mp4Path + "//" + i + ".mp4"); } } SysBLL.deleteDirFile(System.AppDomain.CurrentDomain.BaseDirectory + "/mp4"); } //} } }
public static Boolean Sign(int type, string mackeyExpress, string pinKeyExpress) { PasswordBLL pwdBLL = new PasswordBLL(); //bool ret = pwdBLL.OpenDevice(SysConfigHelper.readerNode("ZT598Port"), "9600"); //if (!ret) //{ // return false; //} try { bool setMode = true; if (type == 0) { setMode = pwdBLL.SetCryptMode(0); if (!setMode) { return(false); } //激活万通主密钥 /* if (!pwdBLL.ActivWorkKey(0, 0)) * { * return false; * }*/ bool pingSuccess = pwdBLL.DownloadWorkKey(0, 0, pinKeyExpress); if (!pingSuccess) { return(false); } bool macSuccess = pwdBLL.DownloadWorkKey(0, 1, mackeyExpress); if (!macSuccess) { return(false); } SysBLL.RebuildBatchNo(); } else if (type == 1) { setMode = pwdBLL.SetCryptMode(1); if (!setMode) { return(false); } //激活万通主密钥 /*if(!pwdBLL.ActivWorkKey(1, 0)) * { * return false; * }*/ bool pingSuccess = pwdBLL.DownloadWorkKey(1, 2, pinKeyExpress); if (!pingSuccess) { return(false); } bool macSuccess = pwdBLL.DownloadWorkKey(1, 3, mackeyExpress); if (!macSuccess) { return(false); } } pwdBLL.closeKey(); return(true); } catch { return(false); } }