using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 印鉴卡/支付密码器查询关联明细查询
    /// 根据帐户或印鉴卡/支付密码器查询关联明细信息
    /// </summary>
    public class QueryYJKZFMMQGLMX : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件
        /// 账号|户名|凭证类型|凭证编号|交易日期|交易机构|交易柜员|操作类型|交易流水|
        /// </summary>
        public string WJ { get; internal set; }

        /// <summary>
        /// 文件
        /// 账号|户名|凭证类型|凭证编号|交易日期|交易机构|交易柜员|操作类型|交易流水|
        /// </summary>
        public List<E_WJ> WJData { get; internal set; }

        /// <summary>
        /// 文件
        /// 账号|户名|凭证类型|凭证编号|交易日期|交易机构|交易柜员|操作类型|交易流水|
        /// </summary>
        public class E_WJ
        {
            /// <summary>
            /// 账号
            /// </summary>
            public string ZH { get; set; }

            /// <summary>
            /// 户名
            /// </summary>
            public string HM { get; set; }

            /// <summary>
            /// 凭证类型
            /// </summary>
            public string PZLX { get; set; }

            /// <summary>
            /// 凭证编号
            /// </summary>
            public string PZBH { get; set; }

            /// <summary>
            /// 交易日期
            /// </summary>
            public string JYRQ { get; set; }

            /// <summary>
            /// 交易机构
            /// </summary>
            public string JYJG { get; set; }

            /// <summary>
            /// 交易柜员
            /// </summary>
            public string JYGY { get; set; }

            /// <summary>
            /// 操作类型
            /// </summary>
            public string CZLX { get; set; }

            /// <summary>
            /// 交易流水
            /// </summary>
            public string JYLS { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 账号 0300
            ///  
            /// </summary>
            public string ZH { get; set; }

            /// <summary>
            /// 凭证编号 0580
            ///  
            /// </summary>
            public string PZBH { get; set; }

            /// <summary>
            /// 凭证类型 0890
            ///  
            /// </summary>
            public string PZLX { get; set; }

            /// <summary>
            /// 交易机构 0910
            ///  
            /// </summary>
            public string JYJG { get; set; }

            /// <summary>
            /// 起始日期 0440
            ///  
            /// </summary>
            public string QSRQ { get; set; }

            /// <summary>
            /// 终止日期 0450
            ///  
            /// </summary>
            public string ZZRQ { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryYJKZFMMQGLMX();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = ZH;
                MessageData.Fd58 = PZBH;
                MessageData.Fd89 = PZLX;
                MessageData.Fd91 = JYJG;
                MessageData.Fd128 = "0100";
                MessageData.Fd44 = QSRQ;
                MessageData.Fd45 = ZZRQ;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.WJData = AnilyzeFileData<E_WJ>(MessageData.FileData,
                                            "账号|户名|凭证类型|凭证编号|交易日期|交易机构|交易柜员|操作类型|交易流水|",
                                            x =>
                                            {
                                                return new E_WJ
                                                {
                                                    ZH = x["账号"],
                                                    HM = x["户名"],
                                                    PZLX = x["凭证类型"],
                                                    PZBH = x["凭证编号"],
                                                    JYRQ = x["交易日期"],
                                                    JYJG = x["交易机构"],
                                                    JYGY = x["交易柜员"],
                                                    CZLX = x["操作类型"],
                                                    JYLS = x["交易流水"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
