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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 借据号查询承兑汇票信息(文件)
    /// 借据号查询承兑汇票信息
    /// </summary>
    public class QueryCDHPXX : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件
        /// TITLE=~协议号|票据类型|票据号|票据金额|票据到期日期|票据签发日期|出票人全称|出票人账号|付款行全称|在途天数|票标志|异地同城标志|票据利息 
        /// </summary>
        public string WJ { get; internal set; }

        /// <summary>
        /// 文件
        /// TITLE=~协议号|票据类型|票据号|票据金额|票据到期日期|票据签发日期|出票人全称|出票人账号|付款行全称|在途天数|票标志|异地同城标志|票据利息 
        /// </summary>
        public List<E_WJ> WJData { get; internal set; }

        /// <summary>
        /// 文件
        /// TITLE=~协议号|票据类型|票据号|票据金额|票据到期日期|票据签发日期|出票人全称|出票人账号|付款行全称|在途天数|票标志|异地同城标志|票据利息 
        /// </summary>
        public class E_WJ
        {
            /// <summary>
            /// 协议号
            /// </summary>
            public string XYH { get; set; }

            /// <summary>
            /// 票据类型
            /// </summary>
            public string PJLX { get; set; }

            /// <summary>
            /// 票据号
            /// </summary>
            public string PJH { get; set; }

            /// <summary>
            /// 票据金额
            /// </summary>
            public string PJJE { get; set; }

            /// <summary>
            /// 票据到期日期
            /// </summary>
            public string PJDQRQ { get; set; }

            /// <summary>
            /// 票据签发日期
            /// </summary>
            public string PJQFRQ { get; set; }

            /// <summary>
            /// 出票人全称
            /// </summary>
            public string CPRQC { get; set; }

            /// <summary>
            /// 出票人账号
            /// </summary>
            public string CPRZH { get; set; }

            /// <summary>
            /// 付款行全称
            /// </summary>
            public string FKXQC { get; set; }

            /// <summary>
            /// 在途天数
            /// </summary>
            public string ZTTS { get; set; }

            /// <summary>
            /// 票标志
            /// </summary>
            public string PBZ { get; set; }

            /// <summary>
            /// 异地同城标志
            /// </summary>
            public string YDTCBZ { get; set; }

            /// <summary>
            /// 票据利息
            /// </summary>
            public string PJLX_1 { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 操作标志 0670
            /// 操作标志：标志位 传1-返回录入和信贷审批的，传2-返回已审核的，传3-返回正常的，传4-返回正常再转出和销户的 
            /// </summary>
            public string CZBZ { get; set; }

            /// <summary>
            /// 借据号 0860
            ///  
            /// </summary>
            public string JJH { get; set; }

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


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

                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
                                                {
                                                    XYH = x["协议号"],
                                                    PJLX = x["票据类型"],
                                                    PJH = x["票据号"],
                                                    PJJE = x["票据金额"],
                                                    PJDQRQ = x["票据到期日期"],
                                                    PJQFRQ = x["票据签发日期"],
                                                    CPRQC = x["出票人全称"],
                                                    CPRZH = x["出票人账号"],
                                                    FKXQC = x["付款行全称"],
                                                    ZTTS = x["在途天数"],
                                                    PBZ = x["票标志"],
                                                    YDTCBZ = x["异地同城标志"],
                                                    PJLX_1 = x["票据利息"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
