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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 客户信息查询-文件
    /// 根据客户号查询客户信息
    /// </summary>
    public class QueryCustomerInfoByCode : TFOutput
    {
        #region Output
        /// <summary>
        /// 客户信息
        /// 客户编码|证件类型|证件号码|开始日期|结束日期|客户名称|客户级别|客户别名|创建日期|手机号|地址|公司地址|联系电话|性别|贡献度|
        /// </summary>
        public string KHXX { get; internal set; }

        /// <summary>
        /// 客户信息
        /// 客户编码|证件类型|证件号码|开始日期|结束日期|客户名称|客户级别|客户别名|创建日期|手机号|地址|公司地址|联系电话|性别|贡献度|
        /// </summary>
        public List<E_KHXX> KHXXData { get; internal set; }

        /// <summary>
        /// 客户信息
        /// 客户编码|证件类型|证件号码|开始日期|结束日期|客户名称|客户级别|客户别名|创建日期|手机号|地址|公司地址|联系电话|性别|贡献度|
        /// </summary>
        public class E_KHXX
        {
            /// <summary>
            /// 客户编码
            /// </summary>
            public string KHBM { get; set; }

            /// <summary>
            /// 证件类型
            /// </summary>
            public string ZJLX { get; set; }

            /// <summary>
            /// 证件号码
            /// </summary>
            public string ZJHM { get; set; }

            /// <summary>
            /// 开始日期
            /// </summary>
            public string KSRQ { get; set; }

            /// <summary>
            /// 结束日期
            /// </summary>
            public string JSRQ { get; set; }

            /// <summary>
            /// 客户名称
            /// </summary>
            public string KHMC { get; set; }

            /// <summary>
            /// 客户级别
            /// </summary>
            public string KHJB { get; set; }

            /// <summary>
            /// 客户别名
            /// </summary>
            public string KHBM_1 { get; set; }

            /// <summary>
            /// 创建日期
            /// </summary>
            public string CJRQ { get; set; }

            /// <summary>
            /// 手机号
            /// </summary>
            public string SJH { get; set; }

            /// <summary>
            /// 地址
            /// </summary>
            public string DZ { get; set; }

            /// <summary>
            /// 公司地址
            /// </summary>
            public string GSDZ { get; set; }

            /// <summary>
            /// 联系电话
            /// </summary>
            public string LXDH { get; set; }

            /// <summary>
            /// 性别
            /// </summary>
            public string XB { get; set; }

            /// <summary>
            /// 贡献度
            /// </summary>
            public string GXD { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 客户号 0280
            ///  
            /// </summary>
            public string KHH { get; set; }

            /// <summary>
            /// 客户类型 0670
            /// 1.对私2.对公 
            /// </summary>
            public string KHLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCustomerInfoByCode();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd28 = KHH;
                MessageData.Fd67 = KHLX;
                MessageData.Fd128 = "0036";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.KHXXData = AnilyzeFileData<E_KHXX>(MessageData.FileData,
                                            "客户编码|证件类型|证件号码|开始日期|结束日期|客户名称|客户级别|客户别名|创建日期|手机号|地址|公司地址|联系电话|性别|贡献度|",
                                            x =>
                                            {
                                                return new E_KHXX
                                                {
                                                    KHBM = x["客户编码"],
                                                    ZJLX = x["证件类型"],
                                                    ZJHM = x["证件号码"],
                                                    KSRQ = x["开始日期"],
                                                    JSRQ = x["结束日期"],
                                                    KHMC = x["客户名称"],
                                                    KHJB = x["客户级别"],
                                                    KHBM_1 = x["客户别名"],
                                                    CJRQ = x["创建日期"],
                                                    SJH = x["手机号"],
                                                    DZ = x["地址"],
                                                    GSDZ = x["公司地址"],
                                                    LXDH = x["联系电话"],
                                                    XB = x["性别"],
                                                    GXD = x["贡献度"]
                                                };
                                            });
                output.KHXX = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
