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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询划款协议主账号签约信息
    /// 查询划款协议主账号签约信息
    /// </summary>
    public class QueryHKXYMainAccountLinkInfo : TFOutput
    {
        #region Output
        /// <summary>
        /// 账号关系列表
        /// ~主账号|主账号序号|从账号|协议类型|留存金额|透支额度|状态|
        /// </summary>
        public string ZHGXLB { get; internal set; }

        /// <summary>
        /// 账号关系列表
        /// ~主账号|主账号序号|从账号|协议类型|留存金额|透支额度|状态|
        /// </summary>
        public List<E_ZHGXLB> ZHGXLBData { get; internal set; }

        /// <summary>
        /// 账号关系列表
        /// ~主账号|主账号序号|从账号|协议类型|留存金额|透支额度|状态|
        /// </summary>
        public class E_ZHGXLB
        {
            /// <summary>
            /// 主账号
            /// </summary>
            public string ZZH { get; set; }

            /// <summary>
            /// 主账号序号
            /// </summary>
            public string ZZHXH { get; set; }

            /// <summary>
            /// 从账号
            /// </summary>
            public string CZH { get; set; }

            /// <summary>
            /// 协议类型
            /// </summary>
            public string XYLX { get; set; }

            /// <summary>
            /// 留存金额
            /// </summary>
            public string LCJE { get; set; }

            /// <summary>
            /// 透支额度
            /// </summary>
            public string TZED { get; set; }

            /// <summary>
            /// 状态
            /// </summary>
            public string ZT { get; set; }

        }

        #endregion

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

            /// <summary>
            /// 协议类型 1031
            ///  
            /// </summary>
            public string XYLX { get; set; }

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

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

            /// <summary>
            /// 开户机构 0910
            ///  
            /// </summary>
            public string KHJG { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryHKXYMainAccountLinkInfo();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd102_1 = ZH;
                MessageData.Fd103_1 = XYLX;
                MessageData.Fd128 = "0054";
                MessageData.Fd44 = QSRQ;
                MessageData.Fd45 = ZZRQ;
                MessageData.Fd91 = KHJG;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.ZHGXLBData = AnilyzeFileData<E_ZHGXLB>(MessageData.FileData,
                                            "主账号|主账号序号|从账号|协议类型|留存金额|透支额度|状态|",
                                            x =>
                                            {
                                                return new E_ZHGXLB
                                                {
                                                    ZZH = x["主账号"],
                                                    ZZHXH = x["主账号序号"],
                                                    CZH = x["从账号"],
                                                    XYLX = x["协议类型"],
                                                    LCJE = x["留存金额"],
                                                    TZED = x["透支额度"],
                                                    ZT = x["状态"]
                                                };
                                            });
                output.ZHGXLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
