Пример #1
0
        /// <summary>
        /// 发送订单支付记录
        /// </summary>
        /// <param name="tradeRecord"></param>
        /// <returns></returns>
        public static string SendOrderPayRecord(TradeRecord tradeRecord)
        {
            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();

                parameters.Add("paySerial.id", tradeRecord.id);
                parameters.Add("data", tradeRecord.data_id);
                parameters.Add("paySerial.lkl_wt_state", tradeRecord.lkl_wt_state.ToString());
                parameters.Add("paySerial.termail_no", tradeRecord.termail_no);
                parameters.Add("paySerial.order_no", tradeRecord.order_no);
                parameters.Add("paySerial.batch_no", tradeRecord.batch_no);
                parameters.Add("paySerial.relation_order", tradeRecord.relation_order);
                parameters.Add("paySerial.order_type", tradeRecord.order_type.ToString());
                parameters.Add("paySerial.shop_type", tradeRecord.shop_type.ToString());
                parameters.Add("paySerial.reconc_str", tradeRecord.reconc_str);
                parameters.Add("paySerial.amount", tradeRecord.amount);
                string  url        = SysConfigHelper.readerNode("savePaymentLog");
                string  jsonResult = HttpHelper.getHttp(url, parameters, null);
                JObject jobject    = JObject.Parse(jsonResult);
                return(jobject["data"].ToString());
            }
            catch (Exception e)
            {
                log.Write("向后台发送订单支付记录时出错,订单号:" + tradeRecord.cloud_no + ",错误详情:" + e.Message);
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 发送订单记录
        /// </summary>
        /// <param name="tradeRecord"></param>
        /// <returns></returns>
        public static string SendOrderRecord(TradeRecord tradeRecord)
        {
            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();

                parameters.Add("paySerial.cloud_no", tradeRecord.cloud_no);
                parameters.Add("paySerial.write_card_state", tradeRecord.write_card_stat);
                parameters.Add("paySerial.termail_no", tradeRecord.termail_no);
                parameters.Add("paySerial.order_no", tradeRecord.order_no);
                parameters.Add("paySerial.branch_shop_no", tradeRecord.branch_shop_no);
                parameters.Add("paySerial.branch_termail_no", tradeRecord.branch_termail_no);
                string  url        = SysConfigHelper.readerNode("savePaymentLog");
                string  jsonResult = HttpHelper.getHttp(url, parameters, null);
                JObject jobject    = JObject.Parse(jsonResult);

                tradeRecord.id = jobject["data"].ToString();

                return(tradeRecord.id);
            }
            catch (Exception e)
            {
                log.Write("向后台发送订单记录时出错,订单号:" + tradeRecord.cloud_no + ",错误详情:" + e.Message);
                return(null);
            }
        }
Пример #3
0
        /// <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);
            }
        }
Пример #4
0
        /// <summary>
        /// 电动读卡器吞卡
        /// </summary>
        public static void swallowCard()
        {
            int handle = 0;

            try
            {
                string        port = SysConfigHelper.readerNode("CRT310Port");
                StringBuilder info = new StringBuilder(260);
                handle = CRT310.CommOpen("COM" + port);
                //读卡器状态
                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 == 0x4b) || (atPosition == 0x4a))
                {
                    //进卡控制,不进卡
                    CRT310.CRT310_CardSetting(handle, 0x1, 0x1);
                    //弹卡
                    CRT310.CRT310_Reset(handle, 2);
                    SysBLL.isSwallowCard = "9999";
                }
            }
            catch (Exception e)
            {
                throw new Exception("系统异常");
            }
            finally
            {
                CRT310.CommClose(handle);
            }
        }
Пример #5
0
        public static void waitBankCard()
        {
            StringBuilder info1 = new StringBuilder(260);

            try
            {
                string        port   = SysConfigHelper.readerNode("CRT310Port");
                StringBuilder info   = new StringBuilder(260);
                int           handle = CRT310.TT_OpenDevice(new StringBuilder("COM" + port), new StringBuilder("9600"), new StringBuilder());


                CRT310.TT_SetCardMode(1, info1);

                StringBuilder info2 = new StringBuilder(260);
                CRT310.TT_WaitCard(0, info2).ToString();

                //停卡位置
                CRT310.CRT310_CardPosition(handle, 0x4);
            }
            catch (Exception e)
            {
                throw new Exception("系统异常");
            }
            finally
            {
                //关闭端口
                CRT310.TT_CloseDevice(info1);
            }
        }
Пример #6
0
        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("警告:键盘打开失败");
            }
        }
Пример #7
0
 /// <summary>
 /// 根据icParams获取payCode和terminalNo和万通拉卡拉交易流水
 /// </summary>
 /// <param name="p"></param>
 /// <param name="ShopNo"></param>
 public static void payCode_terminalNo(ref PayParam p)
 {
     try
     {
         //向后台发送订单记录
         if (p.icParams == null)
         {
             //万通
             p.WtLklorderNo = Wanton.GetOrderNo();
             p.ClientNo     = p.MERCHANTNO_shopNo + "|" + SysConfigHelper.readerNode("ClientNo");
             p.payCode      = "Z000000003";
             p.terminalNo   = SysConfigHelper.readerNode("ClientNo");
         }
         else
         {
             //拉卡拉
             p.WtLklorderNo = LKLProcedure.GetOrderNo();
             p.ClientNo     = p.MERCHANTNO_shopNo + "|" + p.TERMINALNO_clientNo;
             //拉卡拉
             p.payCode    = "Z000000005";
             p.terminalNo = SysConfigHelper.readerNode("LklClientNo");
         }
     }catch (Exception ex)
     {
         log.Write("error:发送订单失败:" + ex.Message);
     }
 }
Пример #8
0
        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);
        }
Пример #9
0
        /// <summary>
        /// 获取支付报文
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public static string PayMessage(ref PayParam p)
        {
            string      sendDataStr = "";
            PasswordBLL pwdBLL      = new PasswordBLL();

            if (p.icParams == null)
            {
                log.Write("交易类型:万通交易");
                pwdBLL.SetCryptMode(1);
                log.Write("万通卡号:" + p.WtNo);
                log.Write("交易金额:" + p.rechageAmount);
                log.Write("终端交易流水号" + p.WtLklorderNo);
                log.Write("开始支付");
                Wanton.pay(p, ref sendDataStr);
                p.payType = "1";
                return(sendDataStr);
            }
            else
            {
                log.Write("交易类型:拉卡拉交易");
                //银行卡支付
                pwdBLL.SetCryptMode(0);

                pwdBLL.SetCryptMode(0);//拉卡拉加密方式

                log.Write("银行卡号:" + p.icParams["cardNo"]);
                log.Write("交易金额:" + p.rechageAmount);
                log.Write("终端交易流水号" + p.WtLklorderNo);
                log.Write("开始支付");
                wtPayBLL.LKLProcedure.PayOrder(p, ref sendDataStr);
                p.payType = "0";
                return(sendDataStr);
            }
            p.shopNo = p.WtLklorderNo + "|" + SysConfigHelper.readerNode("ClientNo") + "|" + SysConfigHelper.readerNode("ShopNo");
        }
Пример #10
0
        /// <summary>
        /// 卡机内是否有卡
        /// </summary>
        /// <returns></returns>
        public static bool CardUsable()
        {
            bool iss    = false;
            int  handle = 0;

            try
            {
                string        port = SysConfigHelper.readerNode("CRT310Port");
                StringBuilder info = new StringBuilder(1024);
                handle = CRT310.CommOpen("COM" + port);
                //读卡器状态
                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 == 0x4b) || (atPosition == 0x4a))
                {
                    iss = true;
                }
            }
            catch (Exception e)
            {
                throw new Exception("系统异常");
            }
            finally
            {
                CRT310.CommClose(handle);
            }
            return(iss);
        }
Пример #11
0
        public static string getOrder()
        {
            int num = Convert.ToInt32(SysConfigHelper.readerNode("orderNo"));

            num++;
            SysBLL.SetAppConfig("orderNo", num.ToString());
            return(num.ToString());
        }
Пример #12
0
        /// <summary>
        /// CRT603读万通卡
        /// </summary>
        /// <returns></returns>
        public string GetCardNoByBusReader()
        {
            try
            {
                string port = SysConfigHelper.readerNode("CRT603Port");
                //int openRet = CRT603.CRT603Vx_OpenConnection(Int32.Parse(port), 19200);

                //上电
                int    iOutAtrLen   = 0;
                byte[] byOutAtrData = new byte[1024];
                int    chipRet      = CRT603.CRT603Vx_RF_chipPower(ref iOutAtrLen, byOutAtrData);

                string firstAction = "00A40000023F00";
                Byte[] sendData    = System.Text.Encoding.ASCII.GetBytes(firstAction);

                int[]  exdataLen1 = new int[2];
                Byte[] RxData     = new Byte[1024];

                int ret = CRT603.CRT603Vx_RF_SendApdu(sendData.Length, sendData, exdataLen1, RxData);
                if (ret == 0)
                {
                    string secondAction = "00A40000023F20";
                    sendData = System.Text.Encoding.ASCII.GetBytes(secondAction);
                    int ret2 = CRT603.CRT603Vx_RF_SendApdu(sendData.Length, sendData, exdataLen1, RxData);

                    if (ret2 == 0)
                    {
                        string thirdAction = "00B0950000";
                        sendData = System.Text.Encoding.ASCII.GetBytes(thirdAction);
                        int    ret3     = CRT603.CRT603Vx_RF_SendApdu(sendData.Length, sendData, exdataLen1, RxData);
                        string strRecv3 = "";
                        for (int i = 0; i < exdataLen1[0]; i++)
                        {
                            strRecv3 += string.Format("{0:X2}", RxData[i]);
                        }
                        //CRT603.CRT603Vx_CloseConnection();
                        if (strRecv3.Length == 0)
                        {
                            return(null);
                        }
                        string result = DecryptCardNo(strRecv3);
                        if (result == null)
                        {
                            return(null);
                        }
                        return(result);
                    }
                }
                //CRT603.CRT603Vx_CloseConnection();
                return(null);
            }
            catch (Exception e)
            {
                log.Write("error:读取万通卡异常:" + e.Message);
                return(null);
            }
        }
Пример #13
0
        /// <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);
        }
Пример #14
0
        /// <summary>
        /// 写金卡
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="gasValue"></param>
        /// <returns></returns>
        public bool Recharge(string cardNo, int gasValue)
        {
            CJ201.Close_Com(CJ201.handle);
            try
            {
                //TODO 调用拉卡拉在线缴费
                //TODO 调用拉卡拉在线缴费,如果支付失败,提示支付失败,跳出方法
                //TODO 根据拉卡拉的支付结果,如果支付成功那么执行,写入燃气卡
                StringBuilder vskh = new StringBuilder(1024);
                vskh.Append(cardNo);
                int vlql = gasValue;
                //byte lpInfo = new byte[1024];
                StringBuilder lpInfo = new StringBuilder(1024);
                //lpInfo.Append("0");
                string port = SysConfigHelper.readerNode("CJ201");
                CJ201.handle = CJ201.Open_Com(Int32.Parse(port), 9600, 8, 0, 0);
                //CJ201.lpInfo = new StringBuilder(1024);
                int ret  = -1;
                int info = 0;
                try
                {
                    ret = CJ201.GoldCard_Write_zz(CJ201.handle, vskh, vlql, lpInfo);
                }
                catch (Exception ae)
                {
                    log.Write("error:" + ae.Message);
                }
                finally
                {
                    //ret = 0;
                    CJ201.Close_Com(CJ201.handle);
                }

                //int ret = CJ201.GoldCard_Write_zz(CJ201.handle, vskh, vlql, lpInfo);
                //关闭端口
                CJ201.Close_Com(CJ201.handle);
                if (ret == 0)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                log.Write("error:燃气写卡失败:" + ex.Message);
                return(false);
            }
            finally
            {
                CJ201.Close_Com(CJ201.handle);
            }
        }
Пример #15
0
        public static Boolean WantongSign()
        {
            try
            {
                //签到
                Dictionary <string, ResultData> signResult = null;
                if (signResult == null)
                {
                    return(false);
                }
                //键盘安装工作秘钥
                ResultData _62 = signResult["62"];


                PaySign paySign = new PaySign();
                paySign.mechine_no  = ConfigurationManager.AppSettings["MechineNo"];
                paySign.terminal_no = SysConfigHelper.readerNode("ClientNo");
                paySign.shop_no     = SysConfigHelper.readerNode("ShopNo");
                paySign.sign_type   = "1";


                if (signResult["39"].value.Trim().Equals("00"))
                {
                    //获取44域中的密文密钥
                    string mackeyExpress = _62.value.Substring(_62.value.Length - 40, 40);

                    string pinKeyExpress = _62.value.Substring(0, 40);

                    bool ret = Sign(1, mackeyExpress, pinKeyExpress);

                    if (ret)
                    {
                        paySign.sign_result = "00";
                    }
                    else
                    {
                        paySign.sign_result = "222222";
                    }
                    TradeBLL.SendSignRecord(paySign);
                    return(ret);
                }
                else
                {
                    paySign.sign_result = signResult["39"].value;
                    TradeBLL.SendSignRecord(paySign);
                }


                return(false);
            }
            catch { return(false); }
        }
Пример #16
0
        //public override Card getCardInfo(string cardNo)
        //{
        //    //TODO 查询公交卡信息
        //    return null;
        //}

        //public override bool Recharge(string cardNo, int gasValue)
        //{
        //    throw new NotImplementedException();
        //}

        //public override bool Recharge(string cardNo, double moneyCount)
        //{
        //    //TODO 调用拉卡拉消费
        //    //TODO 调用拉卡拉消费,如果支付失败,提示错误,退出方法
        //    //TODO 调用拉卡拉消费,如果支付成功,调用北科维拓公交缴费接口,完成充值
        //    return false;
        //}

        /// <summary>
        /// 通过读卡器,读取公交卡卡号
        /// </summary>
        /// <returns></returns>
        public string GetCardNo()
        {
            try
            {
                string port = SysConfigHelper.readerNode("CRT603Port");
                //int openRet = CRT603.CRT603Vx_OpenConnection(Int32.Parse(port), 19200);

                //上电
                int    iOutAtrLen   = 0;
                byte[] byOutAtrData = new byte[1024];
                int    chipRet      = CRT603.CRT603Vx_RF_chipPower(ref iOutAtrLen, byOutAtrData);

                string firstAction = "00A40000023F00";
                Byte[] sendData    = System.Text.Encoding.ASCII.GetBytes(firstAction);

                int[]  exdataLen1 = new int[2];
                Byte[] RxData     = new Byte[1024];

                int ret = CRT603.CRT603Vx_RF_SendApdu(sendData.Length, sendData, exdataLen1, RxData);
                if (ret == 0)
                {
                    string secondAction = "00B0850000";
                    sendData = System.Text.Encoding.ASCII.GetBytes(secondAction);
                    int    ret2     = CRT603.CRT603Vx_RF_SendApdu(sendData.Length, sendData, exdataLen1, RxData);
                    string strRecv2 = "";
                    for (int i = 0; i < exdataLen1[0]; i++)
                    {
                        strRecv2 += string.Format("{0:X2}", RxData[i]);
                    }
                    //CRT603.CRT603Vx_CloseConnection();
                    string no = strRecv2.Substring(16, 16);
                    if (no == null)
                    {
                        throw new Exception("系统异常");
                    }
                    return(no);
                }
                throw new Exception();
            }
            catch (WtException e) {
                throw e;
            }
            catch (Exception ex)
            {
                throw new Exception("系统异常");
            }
            finally
            {
                //CRT603.CRT603Vx_CloseConnection();
            }
        }
Пример #17
0
 /// <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("");
 }
Пример #18
0
        public static string getWtLklNoNum(string ope_type, string bus_type, string field_type, string value)
        {
            Dictionary <String, String> parameters = new Dictionary <String, String>();

            parameters.Add("ope_type", ope_type);
            parameters.Add("bus_type", bus_type);
            parameters.Add("field_type", field_type);
            parameters.Add("t_id", ConfigurationManager.AppSettings["MechineNo"]);
            parameters.Add("t_value", value);
            string jsonText = HttpHelper.getHttp(SysConfigHelper.readerNode("operSePcNum"), parameters, null);

            log.Write(jsonText);
            return(jsonText);
        }
Пример #19
0
        /// <summary>
        /// 公交读卡器打卡端口失败时发送状态 ,
        /// </summary>
        public static string SendCRT603State()
        {
            string port = SysConfigHelper.readerNode("CRT603Port");

            CRT603.CRT603Vx_CloseConnection();
            int handle = CRT603.CRT603Vx_OpenConnection(Int32.Parse(port), 19200);

            //CRT603.CRT603Vx_CloseConnection();
            if (handle != 0)
            {
                return("030001");
            }
            return(null);
        }
Пример #20
0
        public static string getHttp(IDictionary <string, string> parameters, Encoding charset)
        {
            string    retString = null;
            Hashtable ht        = new Hashtable();

            foreach (string key in parameters.Keys)
            {
                if (!key.Equals("orderText"))
                {
                    ht.Add(key.ToLower(), parameters[key]);
                }
            }
            string mac = EncryptionMD5.MD5(ht, SysConfigHelper.readerNode("macKey"));

            if (!parameters.ContainsKey("mac"))
            {
                parameters.Add("mac".ToLower(), mac);
            }
            else
            {
                parameters["mac"] = mac;
            }
            string url = SysConfigHelper.readerNode("mechineSign");

            url = url + "?";
            StringBuilder buffer = new StringBuilder();

            //如果需要POST数据
            if (!(parameters == null || parameters.Count == 0))
            {
                int i = 0;
                foreach (string key in parameters.Keys)
                {
                    if (i > 0)
                    {
                        buffer.AppendFormat("&{0}={1}", key, parameters[key]);
                    }
                    else
                    {
                        buffer.AppendFormat("{0}={1}", key, parameters[key]);
                    }
                    i++;
                }
            }
            retString = getHttp2(url, buffer.ToString(), charset);
            return(retString);
        }
Пример #21
0
        //public override Card getCardInfo(string cardNo)
        //{
        //    //TODO 调用万通卡查询余额的方法,返回卡片信息

        //    return null;
        //}

        //public override bool Recharge(string cardNo, int gasValue)
        //{
        //    throw new NotImplementedException();
        //}

        //public override bool Recharge(string cardNo, double moneyCount)
        //{
        //    //TODO 调用拉卡拉消费的方法
        //    //TODO 调用拉卡拉消费的方法,如果失败,提示错误,跳出方法

        //    //TODO 调用拉卡拉消费的方法,如果成功,调用万通卡的充值方法
        //    return false;

        //}

        /// <summary>
        /// 调用读卡器,拿到万通卡卡号
        /// </summary>
        /// <returns></returns>
        public string GetCardNo()
        {
            string        port   = SysConfigHelper.readerNode("CRT310Port");
            StringBuilder info   = new StringBuilder(260);
            int           handle = CRT310.CommOpen("COM" + port);

            try
            {
                //进卡控制
                CRT310.CRT310_CardSetting(handle, 0x3, 0x1);
                //停卡位置
                CRT310.CRT310_CardPosition(handle, 0x4);

                Byte atPosition   = new byte();
                Byte frontSetting = new byte();
                Byte rearSetting  = new byte();

                //读取状态
                int hasCard = CRT310.CRT310_GetStatus(handle, ref atPosition, ref frontSetting, ref rearSetting);//卡没插好,怎么办

                Byte   cpuType   = new byte();
                Byte[] exdata    = new byte[1024];
                int    exdataLen = 0;
                //CPU卡复位
                CRT310.CPU_ColdReset(handle, 0x0, ref cpuType, exdata, ref exdataLen);

                executeAPDU(handle, "00A40000023F00");

                executeAPDU(handle, "00A40000023F20");

                string cardNoSource = executeAPDU(handle, "00B0950000");
                //进卡控制
                CRT310.CRT310_CardSetting(handle, 0x1, 0x1);

                string result = DecryptCardNo(cardNoSource);
                return(result);
            }
            catch (Exception e)
            {
                throw new WtException(WtExceptionCode.Card.WT_READ_CARD, e.Message);
            }
            finally
            {
                //关闭端口
                CRT310.CommClose(handle);
            }
        }
Пример #22
0
        /// <summary>
        /// 电动读卡器异常发送状态
        /// </summary>
        public static string SendCRT310State()
        {
            string        port = SysConfigHelper.readerNode("CRT310Port");
            StringBuilder info = new StringBuilder(1024);

            Thread.Sleep(1000 * 1);
            CRT310.TT_CloseDevice(info);
            CRT310.TT_CloseDevice(info);
            Thread.Sleep(1000 * 1);
            int handle = -1;

            for (int i = 1; i <= 2; i++)
            {
                handle = CRT310.TT_OpenDevice(new StringBuilder("COM" + port), new StringBuilder("9600"), info);
                if (handle == 0)
                {
                    break;
                }
            }
            int jubing = handle;

            if (handle == 0)
            {
                handle = CRT310.TT_GetDeviceStatus(info);
                CRT310.TT_CloseDevice(info);
                if (handle == 4101)
                {
                    return(null);
                }
                if (handle == 4104)
                {
                    return(null);
                }
                if (handle != 0)
                {
                    return("01" + handle.ToString());
                }
            }
            else
            {
                return("01" + handle.ToString());
            }
            return(null);
        }
Пример #23
0
        public static void refund(refundParam param)
        {
            Dictionary <String, String> parameters = new Dictionary <String, String>();

            parameters.Add("servicename", "TK001");             // TK001 not null
            parameters.Add("loginId", param.loginId);           //交互终端的设备编号(用于自助终端)not null
            parameters.Add("authcode", param.authcode);         // 认证码 not null
            parameters.Add("reqsn", param.reqsn);               //请求流水号 not null
            parameters.Add("trandateTime", param.trandateTime); //  交易时间 格式:YYYYMMDDHHMMSS not null
            parameters.Add("orderno", param.orderno);           //订单编号 not null
            parameters.Add("transType", param.transType);       //线上线下 not null
            parameters.Add("conName", param.conName);

            string jsonText = HttpHelper.getHttp(SysConfigHelper.readerNode("refund"), parameters, null);

            //反序列化JSON字符串,将JSON字符串转换成LIST列表
            //gasQueryInfo = JsonConvert.DeserializeObject<GasQueryInfo>(jsonText);

            //return gasQueryInfo;
        }
Пример #24
0
        /// <summary>
        /// 发送拉卡拉万通签到记录
        /// </summary>
        /// <param name="paySign"></param>
        public static void SendSignRecord(PaySign paySign)
        {
            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();

                parameters.Add("paySign.mechine_no", paySign.mechine_no);
                parameters.Add("paySign.terminal_no", paySign.terminal_no);
                parameters.Add("paySign.shop_no", paySign.shop_no);

                parameters.Add("paySign.sign_type", paySign.sign_type);
                parameters.Add("paySign.sign_result", paySign.sign_result);
                string url        = SysConfigHelper.readerNode("lklwtSign");
                string jsonResult = HttpHelper.getHttp(url, parameters, null);
            }
            catch (Exception e)
            {
                log.Write("向后台发送拉卡拉万通签到结果时出错:" + e.Message);
            }
        }
Пример #25
0
        /// <summary>
        /// 读取磁条卡
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> ReadCitiao()
        {
            StringBuilder info4 = new StringBuilder(1000);

            try
            {
                string        port   = SysConfigHelper.readerNode("CRT310Port");
                StringBuilder info   = new StringBuilder(260);
                int           handle = CRT310.TT_OpenDevice(new StringBuilder("COM" + port), new StringBuilder("9600"), new StringBuilder());

                Dictionary <string, string> citiaoParams = new Dictionary <string, string>();

                byte[] data = new byte[1024];
                System.Text.ASCIIEncoding ASCII = new System.Text.ASCIIEncoding();


                byte[] sb = new byte[1024];
                int    TT_GetTrackData = CRT310.TT_GetTrackData(sb, 2, null);
                //byte[] data = Encoding.ASCII.GetBytes(sb.ToString());

                string str = System.Text.Encoding.GetEncoding("gb2312").GetString(sb);
                citiaoParams["cidao2"] = str.Replace("=", "D");

                citiaoParams["cardNo"] = citiaoParams["cidao2"].Substring(0, citiaoParams["cidao2"].IndexOf("D"));

                byte[] data1 = new byte[1024];
                CRT310.TT_GetTrackData(data1, 3, info4);
                str = System.Text.Encoding.GetEncoding("gb2312").GetString(data1).TrimEnd('\0');
                citiaoParams["cidao3"] = str.Replace("=", "D");
                CRT310.TT_CloseDevice(info4);
                return(citiaoParams);
            }
            catch (Exception ex)
            {
                throw new Exception("系统异常");
            }
            finally
            {
                CRT310.TT_CloseDevice(info4);
            }
        }
Пример #26
0
        ///// <summary>
        ///// 禁止用户插卡
        ///// </summary>
        //public static void CancelWaitCard()
        //{

        //    int handle = 0;
        //    try
        //    {
        //        string port = SysConfigHelper.readerNode("CRT310Port");
        //        StringBuilder info = new StringBuilder(260);
        //        handle = CRT310.CommOpen("COM" + port);
        //        CRT310.TT_CancelWait(info);
        //    }
        //    catch (Exception e)
        //    {
        //        throw new WtException(WtExceptionCode.Sys.UNION_READ, e.Message);
        //    }
        //    finally
        //    {
        //        CRT310.CommClose(handle);
        //    }
        //}

        /// <summary>
        /// 禁止用户插卡
        /// </summary>
        public static void CancelWaitCard()
        {
            StringBuilder outMsg = new StringBuilder(260);

            try
            {
                StringBuilder port = new StringBuilder(SysConfigHelper.readerNode("CRT310Port"));
                StringBuilder bote = new StringBuilder("9600");
                StringBuilder info = new StringBuilder(260);

                int openPort = CRT310.TT_OpenDevice(port, bote, info);
                int ret      = CRT310.TT_CancelWait(info);
            }
            catch (Exception e)
            {
            }
            finally
            {
                CRT310.TT_CloseDevice(outMsg);
            }
        }
Пример #27
0
        /// <summary>
        /// 发送云缴费通知记录
        /// </summary>
        /// <param name="tradeRecord"></param>
        /// <returns></returns>
        public static string SendCloudNoticeRecord(TradeRecord tradeRecord)
        {
            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();

                parameters.Add("paySerial.id", tradeRecord.id);
                parameters.Add("paySerial.cloud_state", tradeRecord.cloud_state.ToString());
                parameters.Add("paySerial.order_state", tradeRecord.order_state);
                parameters.Add("paySerial.write_card_state", tradeRecord.write_card_stat);
                parameters.Add("paySerial.reconc_str", tradeRecord.reconc_str);
                string  url        = SysConfigHelper.readerNode("savePaymentLog");
                string  jsonResult = HttpHelper.getHttp(url, parameters, null);
                JObject jobject    = JObject.Parse(jsonResult);
                return(jobject["data"].ToString());
            }
            catch (Exception e)
            {
                log.Write("向后台发送云平台结果时出错,订单号:" + tradeRecord.cloud_no + ",错误详情:" + e.Message);
                return(null);
            }
        }
Пример #28
0
        /// <summary>
        /// 判断支付结果
        /// </summary>
        /// <param name="p"></param>
        /// <param name="map"></param>
        /// <returns></returns>
        public static string PayResult(PayParam p, Dictionary <string, string> map)
        {
            if (map == null)
            {
                throw new Exception();
            }
            PasswordBLL pwdBLL = new PasswordBLL();

            if (!map["recode"].Equals("00"))
            {
                if ("55".Equals(map["recode"]))
                {
                    SysBLL.PasswordErrorInfo = "密码错误,请重新输入!";
                    log.Write("密码错误");
                    log.Write("--------------------交易结束--------------------");
                    if (p.icParams == null)
                    {
                        pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", p.WtNo);
                        return("55");
                    }
                    else
                    {
                        pwdBLL.OpenKeyboard(SysConfigHelper.readerNode("ZT598Port"), "9600", p.icParams["cardNo"]);
                        return("55");
                    }
                }
                else if ("51".Equals(map["recode"]))
                {
                    log.Write("余额不足");
                    return("51");
                }
                else
                {
                    log.Write("支付失败:返回码:" + map["recode"]);
                    return(map["recode"]);
                }
            }
            return(null);
        }
Пример #29
0
        public static Dictionary <string, string> MechineSign(string mechineNo)
        {
            Dictionary <String, String> signResult = new Dictionary <String, String>();

            try
            {
                Dictionary <String, String> parameters = new Dictionary <String, String>();
                parameters.Add("tId", mechineNo);
                string url      = SysConfigHelper.readerNode("mechineSign");
                string jsonText = HttpHelper.getHttp(url, parameters, null);
                log.Write("设备签到返回:" + jsonText);
                JObject jsonObj = (JObject)JsonConvert.DeserializeObject(jsonText);
                if ("1".Equals(jsonObj["status"].ToString()))
                {
                    string clientPayNos = jsonObj["clientPayNo"].ToString();
                    signResult.Add("wtClientPayNo", clientPayNos.Split('|')[0]);
                    signResult.Add("lklClientPayNo", clientPayNos.Split('|')[1]);
                    signResult.Add("status", "1");

                    SysConfigHelper helper = new SysConfigHelper();

                    SysConfigHelper.writerNode("LklClientNo", signResult["lklClientPayNo"]); //设置拉卡拉终端号
                    SysConfigHelper.writerNode("ClientNo", signResult["wtClientPayNo"]);     //设置万通卡终端号
                                                                                             //SetAppConfig("LklClientNo", signResult["lklClientPayNo"]);
                                                                                             //SetAppConfig("ClientNo", signResult["wtClientPayNo"]);
                                                                                             //设置加载
                    SysFormLoad.loadBar("设备签到成功");
                }
                else
                {
                    signResult.Add("status", "0");
                }
            }
            catch (Exception e)
            {
                log.Write("设备签到异常:" + e.Message);
            }
            return(signResult);
        }
Пример #30
0
        /// <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);
            }
        }