Exemplo n.º 1
0
        /// <summary>
        /// 银行企业直连 通讯报文
        /// </summary>
        /// <param name="parmaKeyDict">参数</param>
        /// <returns></returns>
        private string GetBankEnterpriseNetHead(ExHashTable parmaKeyDict)
        {
            var    pinganPayConfig = GlobalData.LoadPinganConfig();
            var    messageHeader   = new MessageHeader();
            string servType        = (string)parmaKeyDict.Get("ServType");
            string hTradeCode      = (string)parmaKeyDict.Get("TranFunc");
            string thirdLogNo      = (string)parmaKeyDict.Get("ThirdLogNo");
            string messageBody     = (string)parmaKeyDict.Get("MessageBody");

            byte[] byteMessageBody = Utils.ToByte(messageBody);//编码 重要
            string hLength         = byteMessageBody.Length.ToString().PadLeft(10, '0');

            string Qydm = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.Qydm;

            if (parmaKeyDict.Contains("Qydm") && servType == "02")
            {
                Qydm = (string)parmaKeyDict.Get("Qydm");
            }
            //操作员
            string CounterId = (string)parmaKeyDict.Get("CounterId");

            if (servType == "01" && parmaKeyDict.Contains("CounterId"))
            {
                CounterId = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.CounterId;
            }

            messageHeader.MessageType  = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.MessageType;
            messageHeader.ServType     = servType;
            messageHeader.Length       = byteMessageBody.Length.ToString();
            messageHeader.TradeCode    = hTradeCode;
            messageHeader.TargetSystem = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.TargetSystem;
            messageHeader.Qydm         = Qydm;
            messageHeader.CounterId    = CounterId;
            messageHeader.ThirdLogNo   = thirdLogNo;
            messageHeader.Times        = pinganPayConfig.TranMessageNetHead_1_4.NetMessageHead.Times;
            if (servType == "02" && parmaKeyDict.Contains("RspCode"))
            {
                messageHeader.RspCode = (string)parmaKeyDict.Get("RspCode");
            }
            if (servType == "02" && parmaKeyDict.Contains("RspMsg"))
            {
                messageHeader.RspMsg = (string)parmaKeyDict.Get("RspMsg");
            }
            return(messageHeader.ToString());

            #region 11

            /*
             * DateTime dt = System.DateTime.Now;
             * string MessageType = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.MessageType; // "A001";//报文类别 C(4) A001定长222报文头+报文体,客户端需要按此报文头上送。 A002 无报文头,客户端不上送以A001开头的报文,由B2BiC客户端增加A002开头的222位报文头
             * string TargetSystem = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.TargetSystem;// "01"; //目标系统 C(2) 01:银企直连 02:供应链金融 03:交易资金 04:电子商业汇票 05:政府前置 - 昆明国土局 06:供应链1号店 07:POSP信用卡系统 08:资产托管网银 10:交易资金 - P2P系统 11:实物黄金系统 12:政府前置 - 深圳交警 13:交易资金 - 见证系统 14:企业网上银行系统 15:贷贷平安网银 16:橙e物流管理系统 17:橙e App消息推送服务 18:橙e网门户 19: 岼山招标通 21:反交易欺诈侦测平台  22:直通银行子系统
             * string MessageEncoding = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.MessageEncoding;//"01";//报文编码 C(2) 01:GBK缺省 02:UTF8  03:unicode  04:iso-8859-1
             * string TeleProtocol = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.TeleProtocol;// "01";//通讯协议C(2)  01:tcpip 缺省 02:http  03:webservice
             * string hQydm = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.Qydm;// "00101079900009999000";//(string)parmaKeyDict.Get("Qydm");//企业银企直连标准代码 银行提供给企业的20位唯一的标识代码 C(20) 测试使用:00102079900001231000
             * hQydm = hQydm.PadRight(20, ' ');
             * //string hTradeCode = (string)parmaKeyDict.Get("TranFunc");// "4001";// "000000";//交易码 通信报文统一交易码:000000 C(6)
             * hTradeCode = hTradeCode.PadRight(6, ' ');
             * string hCounterId = pinganPayConfig.BankEnterpriseNetHead.NetMessageHead.CounterId;// "00000"; //"     ";;//操做员代码 可选 C(5) 建议送"00000"
             * hCounterId = hCounterId.PadRight(5, ' ');
             * //string hServType = this.PinganPayConfig.BankEnterpriseNetHead.NetMessageHead.ServType;// "01";//服务类型 可选 01-请求 02-应答 C(2)
             * string hTrandateTime = dt.ToString("yyyyMMddHHmmss");//交易日期时间 C(14)
             * string hThirdLogNo = (string)parmaKeyDict.Get("ThirdLogNo");//请求方系统流水号 C(20)
             * hThirdLogNo = hThirdLogNo.PadRight(20, ' ');
             * string hRspCode = "      ";//"000000";//返回码 默认:000000 C(6) 请求时必须填写"000000"
             * //格式为 “:交易成功”;其中冒号为英文格式半角。
             * //100个空格 返回描述 C(100)
             * string hRspMsg = "                                                                                                    ";
             * string hConFlag = "0";//后续包标志 C(1) 0-结束包,1-还有后续包 目前仅支持0
             * //请求次数 C(3) 目前仅支持000
             * string hTimes = pinganPayConfig.TranMessageNetHead_1_4.NetMessageHead.Times; //"000";
             * hTimes = hTimes.PadLeft(3, '0');
             * string hSignFlag = "0";//签名标识 填0,企业不管,由银行客户端完成 C(1) 目前仅支持填0
             * string hSignPacketType = " ";//"1";// "1";//签名数据包格式 填1,企业不管,由银行客户端完成 C(1) 0-裸签 1- PKCS7 目前仅支持送1
             * string hSignAlgorithm = "            ";//签名算法 12个空格 C(12)  RSA-SHA1
             * string hSignDataLength = "          ";// "0000000000";//签名数据长度 填0,签名报文数据长度 C(10) 目前仅支填写0
             * string hAttachCount = "0";//附件数目 默认为0 C(1) 最多9个
             * string bankEnterpriseMessageNetHead = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}{16}{17}{18}{19}",
             *  MessageType,//报文类别 C(4)
             *  TargetSystem,//目标系统 C(2)
             *  MessageEncoding,//报文编码 C(2) 01:GBK
             *  TeleProtocol,//通讯协议 01:tcpip 缺省 02:http C(2)
             *  hQydm,//交易网代码  C(20)
             *  hLength,//接收报文长度 C(10) XML报文体数据的字节长度(提示:不是字符串的长度);不包括附件内容、签名内容的长度
             *  hTradeCode,//交易码 C(6)
             *  hCounterId,//操做员代码 C(5)
             *  servType,//服务类型 C(2)
             *  hTrandateTime,//交易日期时间 C(14)
             *  hThirdLogNo,//请求方系统流水号 C(20)
             *  hRspCode,//返回码 C(6)
             *  hRspMsg,//返回描述 C(100)
             *  hConFlag,// 后续包标志 C(1)
             *  hTimes,//请求次数 C(3)
             *  hSignFlag,//签名标识 C(1)
             *  hSignPacketType,//签名数据包格式 C(1)
             *  hSignAlgorithm,//签名算法 C(12)
             *  hSignDataLength,//签名数据长度 C(10)
             *  hAttachCount//附件数目 C(1)
             *  );
             * return bankEnterpriseMessageNetHead;
             */
            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// 业务报文头
        /// </summary>
        /// <param name="parmaKeyDict">参数</param>
        /// <returns></returns>
        private string GetTranMessageHead(ExHashTable parmaKeyDict)
        {
            var    pinganPayConfig = GlobalData.LoadPinganConfig();
            var    businessHeader  = new BusinessHeader();
            string messageBody     = (string)parmaKeyDict.Get("MessageBody");
            string servType        = (string)parmaKeyDict.Get("ServType");

            string Qydm = pinganPayConfig.TranMessageNetHead_1_4.BusinessMessageHead.Qydm;

            if (parmaKeyDict.Contains("Qydm") && servType == "02")
            {
                Qydm = (string)parmaKeyDict.Get("Qydm");
            }

            string CounterId = (string)parmaKeyDict.Get("CounterId");

            if (servType == "01" && string.IsNullOrEmpty(CounterId))
            {
                CounterId = pinganPayConfig.TranMessageNetHead_1_4.BusinessMessageHead.CounterId;
            }

            //if (parmaKeyDict.Contains("CounterId") && servType == "02") CounterId = (string)parmaKeyDict.Get("CounterId");

            businessHeader.TranFunc   = (string)parmaKeyDict.Get("TranFunc");
            businessHeader.ThirdLogNo = (string)parmaKeyDict.Get("ThirdLogNo");

            byte[] byteMessageBody = Utils.ToByte(messageBody);
            string hLength         = byteMessageBody.Length.ToString().PadLeft(8, '0');

            businessHeader.Length    = hLength;
            businessHeader.ServType  = servType;
            businessHeader.CounterId = CounterId;
            businessHeader.Qydm      = Qydm.Trim();
            if (servType == "02" && parmaKeyDict.Contains("RspCode"))
            {
                businessHeader.RspCode = (string)parmaKeyDict.Get("RspCode");
            }
            if (servType == "02" && parmaKeyDict.Contains("RspMsg"))
            {
                businessHeader.RspMsg = (string)parmaKeyDict.Get("RspMsg");
            }
            return(businessHeader.ToString());

            #region ///

            /*
             * DateTime dt = System.DateTime.Now;
             * string hMacCode = "0";//"                ";//16字符
             * hMacCode = hMacCode.PadRight(16, ' ');
             * string hTrandateTime = dt.ToString("yyyyMMddHHmmss");//设置日期格式
             * string hRspCode = pinganPayConfig.TranMessageNetHead_1_4.BusinessMessageHead.RspCode;// "999999";//交易发起方初始填入”999999”
             * string hRspMsg = "";// "                                          ";
             * hRspMsg = hRspMsg.PadRight(42, ' ');
             * string hConFlag = "0";
             * string hCounterId = pinganPayConfig.TranMessageNetHead_1_4.BusinessMessageHead.CounterId;//"PA001"; ;// "00000";////操作员号
             * hCounterId = hCounterId.PadLeft(5,' ');
             * string hTranFunc = (string)parmaKeyDict.Get("TranFunc");
             * string hThirdLogNo = (string)parmaKeyDict.Get("ThirdLogNo");
             * hThirdLogNo = hThirdLogNo.PadRight(20, ' ');
             * string hQydm = pinganPayConfig.TranMessageNetHead_1_4.BusinessMessageHead.Qydm; //(string)parmaKeyDict.Get("Qydm");
             *
             * string tranMessageHead = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}",
             *     hTranFunc,    //交易类型 C(4)
             *     servType,    //服务类型 C(2)
             *     hMacCode,     //MAC码 C(16)
             *     hTrandateTime,//交易日期和时间 C(14)
             *     hRspCode,    //应答码 交易发起方初始填入”999999” C(6)
             *     hRspMsg,     //应答码描述 C(42)
             *     hConFlag,    //后续包标志 0结束包,1还有后续包 C(1)
             *     hLength,     //报文体长度 C(8)
             *     hCounterId,  //操作员号 C(5)
             *     hThirdLogNo, //请求方系统流水号 C(20)
             *     hQydm        //交易网代码 C(4)
             *     );
             * return tranMessageHead;
             */
            #endregion
        }