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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 借据号查询受托支付审批信息(文件)
    /// 借据号查询受托支付审批信息
    /// </summary>
    public class QuerySTZFSPXX : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件
        /// 支取协议号|审批金额|收款账号|收款人户名|收款人行号|收款人行名
        /// </summary>
        public string WJ { get; internal set; }

        /// <summary>
        /// 文件
        /// 支取协议号|审批金额|收款账号|收款人户名|收款人行号|收款人行名
        /// </summary>
        public List<E_WJ> WJData { get; internal set; }

        /// <summary>
        /// 文件
        /// 支取协议号|审批金额|收款账号|收款人户名|收款人行号|收款人行名
        /// </summary>
        public class E_WJ
        {
            /// <summary>
            /// 支取协议号
            /// </summary>
            public string ZQXYH { get; set; }

            /// <summary>
            /// 审批金额
            /// </summary>
            public string SPJE { get; set; }

            /// <summary>
            /// 收款账号
            /// </summary>
            public string SKZH { get; set; }

            /// <summary>
            /// 收款人户名
            /// </summary>
            public string SKRHM { get; set; }

            /// <summary>
            /// 收款人行号
            /// </summary>
            public string SKRXH { get; set; }

            /// <summary>
            /// 收款人行名
            /// </summary>
            public string SKRXM { get; set; }

        }

        #endregion

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


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

                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
                                                {
                                                    ZQXYH = x["支取协议号"],
                                                    SPJE = x["审批金额"],
                                                    SKZH = x["收款账号"],
                                                    SKRHM = x["收款人户名"],
                                                    SKRXH = x["收款人行号"],
                                                    SKRXM = x["收款人行名"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
