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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 短信业务信息查询
    /// 短信业务信息查询
    /// </summary>
    public class QuerySMSInfo : 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 KHZH { get; set; }

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

            /// <summary>
            /// 服务类型
            /// </summary>
            public string FWLX { get; set; }

            /// <summary>
            /// 贷方发生额
            /// </summary>
            public string DFFSE { get; set; }

            /// <summary>
            /// 借方发生额
            /// </summary>
            public string JFFSE { get; set; }

            /// <summary>
            /// 开通日期
            /// </summary>
            public string KTRQ { get; set; }

            /// <summary>
            /// 开通柜员
            /// </summary>
            public string KTGY { get; set; }

        }

        #endregion

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

            /// <summary>
            /// 手机号码 0620
            ///  
            /// </summary>
            public string SJHM { get; set; }

            /// <summary>
            /// 服务类型 0640
            ///  
            /// </summary>
            public string FWLX { get; set; }

            /// <summary>
            /// 账户类型 0720
            /// 1-对公 2-个人 
            /// </summary>
            public string ZHLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QuerySMSInfo();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd37 = KHZH;
                MessageData.Fd62 = SJHM;
                MessageData.Fd64 = FWLX;
                MessageData.Fd128 = "0065";
                MessageData.Fd72 = ZHLX;

                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
                                                {
                                                    KHZH = x["客户帐号"],
                                                    SJHM = x["手机号码"],
                                                    FWLX = x["服务类型"],
                                                    DFFSE = x["贷方发生额"],
                                                    JFFSE = x["借方发生额"],
                                                    KTRQ = x["开通日期"],
                                                    KTGY = x["开通柜员"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
