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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询抵质押关联信息(文件)
    /// 通过合同号查询抵质押关联信息
    /// </summary>
    public class QueryCollateralInformationLinkOfFile : 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 DZYPBH { get; set; }

            /// <summary>
            /// 抵质押品序号
            /// </summary>
            public string DZYPXH { get; set; }

            /// <summary>
            /// 抵质押金额
            /// </summary>
            public string DZYJE { get; set; }

            /// <summary>
            /// 关联金额
            /// </summary>
            public string GLJE { get; set; }

            /// <summary>
            /// 备注
            /// </summary>
            public string BZ { get; set; }

            /// <summary>
            /// 所有者姓名
            /// </summary>
            public string SYZXM { get; set; }

            /// <summary>
            /// 质押单号
            /// </summary>
            public string ZYDH { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 合同号 0370
            ///  
            /// </summary>
            public string HTH { get; set; }


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

                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
                                                {
                                                    DZYPBH = x["抵质押品编号"],
                                                    DZYPXH = x["抵质押品序号"],
                                                    DZYJE = x["抵质押金额"],
                                                    GLJE = x["关联金额"],
                                                    BZ = x["备注"],
                                                    SYZXM = x["所有者姓名"],
                                                    ZYDH = x["质押单号"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
