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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询划款协议账号关系表
    /// 根据账号查询划款协议关系表
    /// </summary>
    public class QueryPaymentAgreementAccountRelation : 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 HZJE { get; set; }

            /// <summary>
            /// 登记日期
            /// </summary>
            public string DJRQ { get; set; }

            /// <summary>
            /// 到期日期
            /// </summary>
            public string DQRQ { get; set; }

            /// <summary>
            /// 登记柜员
            /// </summary>
            public string DJGY { 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
            /// XD1.协定划款1,SA3,金管家1号,SA4.金管家2号,YY1.零整自动续存,Z03.集团户 
            /// </summary>
            public string XYBH { get; set; }

            /// <summary>
            /// 主交易码 1265
            /// 主交易码 
            /// </summary>
            public string ZJYM { get; set; }

            /// <summary>
            /// 协议状态 0670
            /// 1：正常 *：已解约 
            /// </summary>
            public string XYZT { get; set; }

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

            /// <summary>
            /// 结束日期 0450
            /// 非必输 
            /// </summary>
            public string JSRQ { get; set; }

            /// <summary>
            /// 从账号 1011
            /// 非必输 
            /// </summary>
            public string CZH { get; set; }

            /// <summary>
            /// 从账号序号 1012
            /// 非必输 
            /// </summary>
            public string CZHXH { get; set; }

            /// <summary>
            /// 账户序号 1022
            ///  
            /// </summary>
            public string ZHXH { get; set; }

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


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryPaymentAgreementAccountRelation();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd102_1 = ZH;
                MessageData.Fd103_1 = XYBH;
                MessageData.Fd126_5 = ZJYM;
                MessageData.Fd128 = "0053";
                MessageData.Fd67 = XYZT;
                MessageData.Fd44 = QSRQ;
                MessageData.Fd45 = JSRQ;
                MessageData.Fd101_1 = CZH;
                MessageData.Fd101_2 = CZHXH;
                MessageData.Fd102_2 = ZHXH;
                MessageData.Fd91 = JGH;

                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["留存金额"],
                                                    HZJE = x["划转金额"],
                                                    DJRQ = x["登记日期"],
                                                    DQRQ = x["到期日期"],
                                                    DJGY = x["登记柜员"],
                                                    ZT = x["状态"]
                                                };
                                            });
                output.ZHGXLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
