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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询还款计划审批信息
    /// 通过借据号查询还款计划审批表
    /// </summary>
    public class QueryRepaymentPlanApproval : TFOutput
    {
        #region Output
        /// <summary>
        /// 还款期次
        /// 还款期次|起始日期|终止日期|还本金额|
        /// </summary>
        public string HKQC { get; internal set; }

        /// <summary>
        /// 还款期次
        /// 还款期次|起始日期|终止日期|还本金额|
        /// </summary>
        public List<E_HKQC> HKQCData { get; internal set; }

        /// <summary>
        /// 还款期次
        /// 还款期次|起始日期|终止日期|还本金额|
        /// </summary>
        public class E_HKQC
        {
            /// <summary>
            /// 还款期次
            /// </summary>
            public string HKQC { get; set; }

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

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

            /// <summary>
            /// 还本金额
            /// </summary>
            public string HBJE { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 借据号 102A
            ///  
            /// </summary>
            public string JJH { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryRepaymentPlanApproval();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd102_A = JJH;
                MessageData.Fd128 = "0033";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.HKQCData = AnilyzeFileData<E_HKQC>(MessageData.FileData,
                                            "还款期次|起始日期|终止日期|还本金额|",
                                            x =>
                                            {
                                                return new E_HKQC
                                                {
                                                    HKQC = x["还款期次"],
                                                    QSRQ = x["起始日期"],
                                                    ZZRQ = x["终止日期"],
                                                    HBJE = x["还本金额"]
                                                };
                                            });
                output.HKQC = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
