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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询贴现信息
    /// 根据协议编号和查询标志或票据号和票据类型或贴现账号查询贴现登记簿信息
    /// </summary>
    public class QueryDiscounting : TFOutput
    {
        #region Output
        /// <summary>
        /// 电票标志 0200
        /// P纸票 E电票
        /// </summary>
        public string DPBZ { get; internal set; }

        /// <summary>
        /// 产品编号 0230
        /// 
        /// </summary>
        public string CPBH { get; internal set; }

        /// <summary>
        /// 对方行名或转贴现申请人全称 0250
        /// 
        /// </summary>
        public string DFXMHZTXSQRQC { get; internal set; }

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

        /// <summary>
        /// 收款人全称 0270
        /// 
        /// </summary>
        public string SKRQC { get; internal set; }

        /// <summary>
        /// 票据出票日期 0280
        /// 
        /// </summary>
        public string PJCPRQ { get; internal set; }

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

        /// <summary>
        /// 收款人账号 0320
        /// 
        /// </summary>
        public string SKRZH { get; internal set; }

        /// <summary>
        /// 贴现账号 0330
        /// 
        /// </summary>
        public string TXZH { get; internal set; }

        /// <summary>
        /// 再贴现日期 0440
        /// 
        /// </summary>
        public string ZTXRQ { get; internal set; }

        /// <summary>
        /// 汇票到期日期 0450
        /// 
        /// </summary>
        public string HPDQRQ { get; internal set; }

        /// <summary>
        /// 回购日期 0460
        /// 
        /// </summary>
        public string HGRQ { get; internal set; }

        /// <summary>
        /// 贴现日 0470
        /// 
        /// </summary>
        public string TXR { get; internal set; }

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

        /// <summary>
        /// 贴现协议编号 0620
        /// 
        /// </summary>
        public string TXXYBH { get; internal set; }

        /// <summary>
        /// 转贴现协议编号 0630
        /// 
        /// </summary>
        public string ZTXXYBH { get; internal set; }

        /// <summary>
        /// 收款账户类型 0670
        /// 
        /// </summary>
        public string SKZHLX { get; internal set; }

        /// <summary>
        /// 异地同城标志 0680
        /// 0本地 1异地
        /// </summary>
        public string YDTCBZ { get; internal set; }

        /// <summary>
        /// 状态 0700
        /// 1录入 2已审核 3正常 4正常再转出 *销户 X信贷已审批
        /// </summary>
        public string ZT { get; internal set; }

        /// <summary>
        /// 有无追索权志 0710
        /// 0无追索权 1有追索权
        /// </summary>
        public string YWZSQZ { get; internal set; }

        /// <summary>
        /// 标志位 0730
        /// [空格表示没有查询相关数据]第0位：1输入贴现账号不存在； 第2位：1输入的协议号不存在； 第3位：1贴现对应的贷款账号不存在；
        /// </summary>
        public string BZW { get; internal set; }

        /// <summary>
        /// 贴现申请人户名 0740
        /// 
        /// </summary>
        public string TXSQRHM { get; internal set; }

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

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

        /// <summary>
        /// 收款人开户行全称 0820
        /// 
        /// </summary>
        public string SKRKHXQC { get; internal set; }

        /// <summary>
        /// 贴现申请人账号 0830
        /// 
        /// </summary>
        public string TXSQRZH { get; internal set; }

        /// <summary>
        /// 贴现率 0840
        /// 
        /// </summary>
        public string TXL { get; internal set; }

        /// <summary>
        /// 转贴现率 0850
        /// 
        /// </summary>
        public string ZTXL { get; internal set; }

        /// <summary>
        /// 再贴现协议编号 0880
        /// 
        /// </summary>
        public string ZTXXYBH_1 { get; internal set; }

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

        /// <summary>
        /// 贴现机构 0910
        /// 
        /// </summary>
        public string TXJG { get; internal set; }

        /// <summary>
        /// 柜员号 0920
        /// 
        /// </summary>
        public string GYH { get; internal set; }

        /// <summary>
        /// 再贴现率 0970
        /// 
        /// </summary>
        public string ZTXL_1 { get; internal set; }

        /// <summary>
        /// 贴现利息 1001
        /// 
        /// </summary>
        public string TXLX { get; internal set; }

        /// <summary>
        /// 汇票金额 1002
        /// 
        /// </summary>
        public string HPJE { get; internal set; }

        /// <summary>
        /// 转贴现利息 1003
        /// 
        /// </summary>
        public string ZTXLX { get; internal set; }

        /// <summary>
        /// 再贴现利息 1004
        /// 
        /// </summary>
        public string ZTXLX_1 { get; internal set; }

        /// <summary>
        /// 贴现类型 101C
        /// 1贴现 2买断转入 3回购转入 4买断转出 5回购转出 6买断再贴现 7回购再贴现 8委托收款 9贴现收回
        /// </summary>
        public string TXLX_1 { get; internal set; }

        /// <summary>
        /// 转贴现日期 102E
        /// 
        /// </summary>
        public string ZTXRQ_1 { get; internal set; }

        /// <summary>
        /// 审核柜员 0640
        /// 
        /// </summary>
        public string SHGY { get; internal set; }


        #endregion

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

            /// <summary>
            /// 协议编号 0620
            /// 根据67域查询标志区分该协议编号为何种贴现 
            /// </summary>
            public string XYBH { get; set; }

            /// <summary>
            /// 查询标志 0670
            /// 使用协议号 1贴现 2转贴现转出 3再贴现 4转帖先转入 5查询贴现和转入，使用票据类型和票据号时传入状态X录入2审核3记账4转出*销户 
            /// </summary>
            public string CXBZ { get; set; }

            /// <summary>
            /// 票据号码 0750
            ///  
            /// </summary>
            public string PJHM { get; set; }

            /// <summary>
            /// 票据类型 0900
            /// 111银行承兑汇票 112商业承兑汇票 
            /// </summary>
            public string PJLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryDiscounting();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "K006";
                MessageData.Fd30 = TXZH;
                MessageData.Fd62 = XYBH;
                MessageData.Fd67 = CXBZ;
                MessageData.Fd75 = PJHM;
                MessageData.Fd90 = PJLX;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.DPBZ = DelSpace(MessageData.Fd20);
                output.CPBH = DelSpace(MessageData.Fd23);
                output.DFXMHZTXSQRQC = DelSpace(MessageData.Fd25);
                output.CPRQC = DelSpace(MessageData.Fd26);
                output.SKRQC = DelSpace(MessageData.Fd27);
                output.PJCPRQ = DelSpace(MessageData.Fd28);
                output.CPRZH = DelSpace(MessageData.Fd31);
                output.SKRZH = DelSpace(MessageData.Fd32);
                output.TXZH = DelSpace(MessageData.Fd33);
                output.ZTXRQ = DelSpace(MessageData.Fd44);
                output.HPDQRQ = DelSpace(MessageData.Fd45);
                output.HGRQ = DelSpace(MessageData.Fd46);
                output.TXR = DelSpace(MessageData.Fd47);
                output.ZTTS = Number(MessageData.Fd48);
                output.TXXYBH = DelSpace(MessageData.Fd62);
                output.ZTXXYBH = DelSpace(MessageData.Fd63);
                output.SKZHLX = DelSpace(MessageData.Fd67);
                output.YDTCBZ = DelSpace(MessageData.Fd68);
                output.ZT = DelSpace(MessageData.Fd70);
                output.YWZSQZ = DelSpace(MessageData.Fd71);
                output.BZW = (MessageData.Fd73);
                output.TXSQRHM = DelSpace(MessageData.Fd74);
                output.PJH = DelSpace(MessageData.Fd75);
                output.FKXQC = DelSpace(MessageData.Fd81);
                output.SKRKHXQC = DelSpace(MessageData.Fd82);
                output.TXSQRZH = DelSpace(MessageData.Fd83);
                output.TXL = DelSpace(MessageData.Fd84);
                output.ZTXL = DelSpace(MessageData.Fd85);
                output.ZTXXYBH_1 = DelSpace(MessageData.Fd88);
                output.PJLX = DelSpace(MessageData.Fd90);
                output.TXJG = DelSpace(MessageData.Fd91);
                output.GYH = DelSpace(MessageData.Fd92);
                output.ZTXL_1 = DelSpace(MessageData.Fd97);
                output.TXLX = DelSpace(MessageData.Fd100_1);
                output.HPJE = DelSpace(MessageData.Fd100_2);
                output.ZTXLX = DelSpace(MessageData.Fd100_3);
                output.ZTXLX_1 = DelSpace(MessageData.Fd100_4);
                output.TXLX_1 = DelSpace(MessageData.Fd101_C);
                output.ZTXRQ_1 = DelSpace(MessageData.Fd102_E);
                output.SHGY = DelSpace(MessageData.Fd64);

                return output;
            }
        }
        #endregion
    }
}
