Exemple #1
0
        public static bool Deserlize(byte[] datas, ref OutPutData outPutData)
        {
            try
            {
                //POS汉字编码库为GBK
                Encoding gbk     = Encoding.GetEncoding("GB18030");
                string   outStr  = new string(gbk.GetChars(datas));
                string[] outStrs = outStr.Split('|');

                if (outStrs.Length == 31)
                {
                    //去除返回字段的前补0
                    for (int i = 0; i < outStrs.Length; i++)
                    {
                        outStrs[i] = outStrs[i].Trim(new char[] { ' ' });
                    }
                    outPutData                 = new OutPutData();
                    outPutData.resp_code       = outStrs[0];
                    outPutData.bank_code       = outStrs[1];
                    outPutData.card_no         = outStrs[2];
                    outPutData.expr            = outStrs[3];
                    outPutData.amount          = outStrs[4];
                    outPutData.trace           = outStrs[5];
                    outPutData.refer           = outStrs[6];
                    outPutData.auth            = outStrs[7];
                    outPutData.batch           = outStrs[8];
                    outPutData.date            = outStrs[9];
                    outPutData.userno          = outStrs[10];
                    outPutData.terno           = outStrs[11];
                    outPutData.old_terno       = outStrs[12];
                    outPutData.szOrderTrace    = outStrs[13];
                    outPutData.resp_chin       = outStrs[14];
                    outPutData.CredentialsType = outStrs[15];
                    outPutData.CredentialsNum  = outStrs[16];
                    outPutData.Name            = outStrs[17];
                    outPutData.Sex             = outStrs[18];
                    outPutData.birthDay        = outStrs[19];
                    outPutData.age             = outStrs[20];
                    outPutData.Address         = outStrs[21];
                    outPutData.PhoneNum        = outStrs[22];
                    outPutData.Nation          = outStrs[23];
                    outPutData.szExtend1       = outStrs[24];
                    outPutData.szExtend2       = outStrs[25];
                    outPutData.szExtend3       = outStrs[26];
                    outPutData.szExtend4       = outStrs[27];
                    outPutData.szExtend5       = outStrs[28];
                    outPutData.OrderNo         = outStrs[29];
                }
                else
                {
                    throw new Exception(string.Format("POS机返回值长度异常!现长度为{0},应为31", outStrs.Length));
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw new POSDerlizeException(ex);
            }
        }
Exemple #2
0
 internal POSReturn(OutPutData outputData)
 {
     bankCode     = outputData.bank_code;
     cardNo       = outputData.card_no;
     amount       = string.IsNullOrEmpty(outputData.amount) ? 0m : decimal.Parse(outputData.amount);
     trace        = outputData.trace;
     refer        = outputData.refer;
     szOrderTrace = outputData.szOrderTrace;
     terno        = outputData.terno;
     oldTerno     = outputData.old_terno;
     settleStatus = Constant.POSSettleStatus.NotSettle;
     date         = DateTime.ParseExact(outputData.date, Constant.POSFullTimeFormt, null);
 }