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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 9598查询-880202-批量结果查询
    /// 880202-批量结果查询
    /// </summary>
    public class QueryBatchResult : TFOutput
    {
        #region Output
        /// <summary>
        /// 查询结果
        /// 文件格式:交易日期|流水号|总笔数|总金额|成功笔数|成功金额|
        /// </summary>
        public string CXJG { get; internal set; }

        /// <summary>
        /// 查询结果
        /// 文件格式:交易日期|流水号|总笔数|总金额|成功笔数|成功金额|
        /// </summary>
        public List<E_CXJG> CXJGData { get; internal set; }

        /// <summary>
        /// 查询结果
        /// 文件格式:交易日期|流水号|总笔数|总金额|成功笔数|成功金额|
        /// </summary>
        public class E_CXJG
        {
            /// <summary>
            /// 交易日期
            /// </summary>
            public string JYRQ { get; set; }

            /// <summary>
            /// 流水号
            /// </summary>
            public string LSH { get; set; }

            /// <summary>
            /// 总笔数
            /// </summary>
            public string ZBS { get; set; }

            /// <summary>
            /// 总金额
            /// </summary>
            public string ZJE { get; set; }

            /// <summary>
            /// 成功笔数
            /// </summary>
            public string CGBS { get; set; }

            /// <summary>
            /// 成功金额
            /// </summary>
            public string CGJE { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 查询条件 
            /// 日期
            /// </summary>
            public string RQ { get; set; }

            /// <summary>
            /// 查询条件 
            /// 账号
            /// </summary>
            public string ZH { get; set; }

            /// <summary>
            /// 查询条件 
            /// 交易代码
            /// </summary>
            public string JYDM { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryBatchResult();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "9598";
                MessageData.Fd123 = string.Format("1,880202,{0},{1},{2},",RQ,ZH,JYDM);

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.CXJGData = AnilyzeFileData<E_CXJG>(MessageData.FileData,
                                            "交易日期|流水号|总笔数|总金额|成功笔数|成功金额|",
                                            x =>
                                            {
                                                return new E_CXJG
                                                {
                                                    JYRQ = x["交易日期"],
                                                    LSH = x["流水号"],
                                                    ZBS = x["总笔数"],
                                                    ZJE = x["总金额"],
                                                    CGBS = x["成功笔数"],
                                                    CGJE = x["成功金额"]
                                                };
                                            });
                output.CXJG = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
