Exemple #1
0
        public static BusCpuCardInfo GetOrder(BusReChangeParam busReChangeParam, BusCpuCardParam param, string paycode)
        {
            Boolean isSuccess = false;
            //签到
            BusRegisterInfo busRegisterInfo = BusAccess.BusRegister();

            if (busRegisterInfo.cpumsg.OUTPUT != null)
            {
                isSuccess = true;
            }
            if (isSuccess == false)
            {
                throw new WtException(WtExceptionCode.Bus.BUS_PAY);
            }
            isSuccess = false;
            //公交卡充值


            param.authcode     = SysBLL.Authcode;;                       // 认证码   not null
            param.servicename  = "DD006";                                //交易类型编号  not null
            param.trandateTime = SysBLL.getYYYYMMDDHHMMSSTime();         //交易日期:YYYYMMDDHHMMSS not null
            param.resqn        = SysBLL.getSerialNum();                  //请求流水号  not null
            param.paymentno    = busReChangeParam.paymentno;             //用户名 用户编号 not null
            param.paymentAmout = busReChangeParam.paymentAmout + "00";   //账单金额   not null
            param.billDate     = DateTime.Now.Year.ToString();           //账单日期 not null
            param.merchantNo   = "S000000200";                           //缴费单位编号 not null
            param.step         = "0";                                    //执行第几步 Not null
            param.money        = busReChangeParam.paymentAmout + "00";   //充值金额 Not null
            param.serno        = SysBLL.getSerialNum().Substring(0, 12); //业务流水号  not null
            param.appsid       = busReChangeParam.appsid;                //应用序列号
            param.btype        = "1931";                                 //业务类型  not null
            param.opno         = busRegisterInfo.cpumsg.OUTPUT.OPNO;     //操作员卡号 not null
            param.scode        = busRegisterInfo.cpumsg.OUTPUT.SCODE;    //签到码 not null
            param.terno        = SysBLL.getMac();                        //终端编号 Not null
            param.loginId      = SysBLL.getCpuNo();                      //设备ID
            param.CMTYPE       = "0";
            param.WMONEY       = busReChangeParam.wmoney;
            param.inapdu       = "no";
            param.tradeno      = busReChangeParam.trandeNo;
            //param.payCode = paycode;
            //param.orderno = busReChangeParam.orderno;
            BusInterface   access          = new BusInterface();
            BusCpuCardInfo busCpuCardInfo1 = access.BusCpuCard(param);

            //  orderno = busCpuCardInfo1.msgrsp.orderno;
            return(busCpuCardInfo1);
        }
Exemple #2
0
        public static BusCpuCardInfo ReCharge(BusCpuCardInfo busCpuCardInfo1, BusCpuCardParam param)
        {
            try{
                BusInterface access    = new BusInterface();
                Boolean      isSuccess = false;
                if (busCpuCardInfo1.cpumsg.OUTPUT.OUTAPDU != null)
                {
                    isSuccess = true;
                }
                if (isSuccess == false)
                {
                    throw new WtException(WtExceptionCode.Bus.BUS_PAY);
                }
                isSuccess      = false;
                param.orderno  = busCpuCardInfo1.msgrsp.orderno; //订单编号    null 循环最后一步传递
                param.payCode  = "Z000000004";                   //支付渠道编码  null 循环最后一步传递
                param.trandeNo = SysBLL.getSerialNum();          //支付渠道交易流水号 null 循环最后一步传递
                param.inapdu   = "yes";                          //指令    不定 第一步不需要传,当服务端有 OUTAPDU 指令后,将 OUTAPDU 指令执行并上传 INAPDU 指令

                string status = busCpuCardInfo1.cpumsg.OUTPUT.OUTAPDU.LASTAPDU;
                param.step = busCpuCardInfo1.cpumsg.OUTPUT.STEP;

                //执行指令
                BusCardBLL bus  = new BusCardBLL();
                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 apduData     = "";

                string APDUDATA            = "";
                string APDUSW              = "";
                string RETDATA             = "";
                int    APDUSUM             = 0;
                string result              = "";
                string last                = "";
                List <BusCpuCardAPDU> apdu = busCpuCardInfo1.cpumsg.OUTPUT.OUTAPDU.APDU;
                for (int i = 0; i < apdu.Count; i++)
                {
                    APDUDATA = APDUDATA + apdu[i].APDUDATA + "|";

                    result = bus.sendApdu(apdu[i].APDUDATA);

                    last   = result.Substring(result.Length - 4);
                    APDUSW = APDUSW + last + "|";
                    result = result.Remove(result.Length - 4, 4);
                    if (result.Length == 0)
                    {
                        result = last;
                    }
                    if (apduData != null)
                    {
                        RETDATA = RETDATA + result + "|";
                    }
                    Thread.Sleep(10);
                    APDUSUM++;
                }
                //CRT603.CRT603Vx_CloseConnection();
                APDUDATA = APDUDATA.Remove(APDUDATA.Length - 1, 1);
                APDUSW   = APDUSW.Remove(APDUSW.Length - 1, 1);
                RETDATA  = RETDATA.Remove(RETDATA.Length - 1, 1);

                BusCpuCardInfo busCpuCardInfo2 = null;
                while (true)
                {
                    param.APDUDATA = APDUDATA;
                    param.APDUSW   = APDUSW;
                    param.RETDATA  = RETDATA;
                    param.APDUSUM  = APDUSUM.ToString();
                    if ("-1".Equals(param.step))
                    {
                        busCpuCardInfo2.msgrsp.Tac = param.RETDATA;
                    }
                    //结果
                    if (status.Equals("01"))
                    {
                        busCpuCardInfo2 = access.BusCpuCard(param);
                        return(busCpuCardInfo2);
                    }

                    busCpuCardInfo2 = access.BusCpuCard(param);
                    if (busCpuCardInfo2.cpumsg.OUTPUT.OUTAPDU != null)
                    {
                        isSuccess = true;
                    }
                    if (isSuccess == false)
                    {
                        throw new WtException(WtExceptionCode.Bus.BUS_PAY);
                    }
                    isSuccess = false;
                    APDUDATA  = "";
                    APDUSW    = "";
                    RETDATA   = "";
                    APDUSUM   = 0;
                    List <BusCpuCardAPDU> apdu2 = busCpuCardInfo2.cpumsg.OUTPUT.OUTAPDU.APDU;

                    for (int i = 0; i < apdu2.Count; i++)
                    {
                        APDUDATA = APDUDATA + apdu2[i].APDUDATA + "|";
                        result   = bus.sendApdu(apdu2[i].APDUDATA);
                        last     = result.Substring(result.Length - 4);
                        result   = result.Remove(result.Length - 4, 4);
                        APDUSW   = last + APDUSW + "|";
                        //执行apdu
                        RETDATA = RETDATA + result + "|";
                        APDUSUM++;
                    }
                    APDUDATA   = APDUDATA.Remove(APDUDATA.Length - 1, 1);
                    APDUSW     = APDUSW.Remove(APDUSW.Length - 1, 1);
                    RETDATA    = RETDATA.Remove(RETDATA.Length - 1, 1);
                    param.step = busCpuCardInfo2.cpumsg.OUTPUT.STEP;
                    status     = busCpuCardInfo2.cpumsg.OUTPUT.OUTAPDU.LASTAPDU;
                }
            }
            catch { return(null); }
        }