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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 根据帐户或印鉴卡/支付密码器查询关联信息
    /// 根据帐户或印鉴卡/支付密码器查询关联信息
    /// </summary>
    public class QueryAccountPaymentPwdConnection : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件列表
        /// ~账号|印鉴/支付密码器|凭证编号|本行标识|关联状态|关联日期|解除日期|交易机构|
        /// </summary>
        public string WJLB { get; internal set; }

        /// <summary>
        /// 文件列表
        /// ~账号|印鉴/支付密码器|凭证编号|本行标识|关联状态|关联日期|解除日期|交易机构|
        /// </summary>
        public List<E_WJLB> WJLBData { get; internal set; }

        /// <summary>
        /// 文件列表
        /// ~账号|印鉴/支付密码器|凭证编号|本行标识|关联状态|关联日期|解除日期|交易机构|
        /// </summary>
        public class E_WJLB
        {
            /// <summary>
            /// 账号
            /// </summary>
            public string ZH { get; set; }

            /// <summary>
            /// 印鉴/支付密码器
            /// </summary>
            public string YJZFMMQ { get; set; }

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

            /// <summary>
            /// 本行标识
            /// </summary>
            public string BXBS { get; set; }

            /// <summary>
            /// 关联状态
            /// </summary>
            public string GLZT { get; set; }

            /// <summary>
            /// 关联日期
            /// </summary>
            public string GLRQ { get; set; }

            /// <summary>
            /// 解除日期
            /// </summary>
            public string JCRQ { get; set; }

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

        }

        #endregion

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

            /// <summary>
            /// 印鉴卡/支付密码编号 0580
            ///  
            /// </summary>
            public string BH { get; set; }

            /// <summary>
            /// 本行标识 0670
            /// Y.本行N.他行 
            /// </summary>
            public string BHBS { get; set; }

            /// <summary>
            /// 凭证种类 0890
            /// 117:支付密码器 188:印鉴卡  
            /// </summary>
            public string PZZL { get; set; }

            /// <summary>
            /// 机构号 0910
            /// 账号的开户机构 
            /// </summary>
            public string JGH { get; set; }

            /// <summary>
            /// 关联公用标志/出售 0690
            /// Y.关联N.公用 
            /// </summary>
            public string BZ { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryAccountPaymentPwdConnection();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = ZH;
                MessageData.Fd58 = BH;
                MessageData.Fd128 = "0057";
                MessageData.Fd67 = BHBS;
                MessageData.Fd89 = PZZL;
                MessageData.Fd91 = JGH;
                MessageData.Fd69 = BZ;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.WJLBData = AnilyzeFileData<E_WJLB>(MessageData.FileData,
                                            "账号|印鉴/支付密码器|凭证编号|本行标识|关联状态|关联日期|解除日期|交易机构|",
                                            x =>
                                            {
                                                return new E_WJLB
                                                {
                                                    ZH = x["账号"],
                                                    YJZFMMQ = x["印鉴/支付密码器"],
                                                    PZBH = x["凭证编号"],
                                                    BXBS = x["本行标识"],
                                                    GLZT = x["关联状态"],
                                                    GLRQ = x["关联日期"],
                                                    JCRQ = x["解除日期"],
                                                    JYJG = x["交易机构"]
                                                };
                                            });
                output.WJLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
