using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace ChuPiao.Common.Models
{
    /// <summary>
    /// 彩票机缴款报表
    /// </summary>
    public class R_MachinePayMoneyReportEntity
    {
        public R_MachinePayMoneyReportEntity()
        {

        }
        //public R_MachinePayMoneyReportEntity(XmlNode xmlNode)
        //{
        //    if(xmlNode==null)
        //    {
        //        return;
        //    }
        //    XmlNode node = xmlNode.SelectSingleNode("id");
        //    if(node!=null)
        //    {
        //        int.TryParse(node.InnerText, out _r_id);
        //    }
        //    node = xmlNode.SelectSingleNode("balance");
        //    if (node != null)
        //    {
        //        decimal.TryParse(node.InnerText, out _r_balance);
        //    }
        //    node = xmlNode.SelectSingleNode("creditline");
        //    if (node != null)
        //    {
        //        decimal.TryParse(node.InnerText, out _r_creditline);
        //    }
        //    node = xmlNode.SelectSingleNode("outstandingmoney");
        //    if (node != null)
        //    {
        //        decimal.TryParse(node.InnerText, out _r_outstandingmoney);
        //    }
        //    node = xmlNode.SelectSingleNode("cansalemoney");
        //    if (node != null)
        //    {
        //        decimal.TryParse(node.InnerText, out _r_cansalemoney);
        //    }
        //    node = xmlNode.SelectSingleNode("payablemoney");
        //    if (node != null)
        //    {
        //        decimal.TryParse(node.InnerText, out _r_payablemoney);
        //    }
        //    node = xmlNode.SelectSingleNode("zxmacnumber");
        //    if (node != null)
        //    {
        //        _r_zxmacnumber = node.InnerText;
        //    }
        //    node = xmlNode.SelectSingleNode("querytime");
        //    if (node != null)
        //    {
        //        DateTime.TryParse(node.InnerText, out _r_querytime);
        //    }
        //    node = xmlNode.SelectSingleNode("prntext");
        //    if (node != null)
        //    {
        //        _r_prntext = node.InnerText;
        //    }
        //    _r_dataList = new List<PayMoneyDataItem>();
        //    XmlNodeList nodeList = xmlNode.SelectNodes("datalist/dataitem");
        //    if (nodeList != null)
        //    {
        //        foreach (XmlNode tmpnode in nodeList)
        //        {
        //            _r_dataList.Add(new PayMoneyDataItem(tmpnode));
        //        }
        //    }
        //}
        //public string Pack()
        //{
        //    StringBuilder dataBuilder = new StringBuilder();
        //    dataBuilder.Append("<machinepaymoneyreport>");
        //    dataBuilder.AppendFormat("<id>{0}</id><balance>{1}</balance><creditline>{2}</creditline><outstandingmoney>{3}</outstandingmoney><cansalemoney>{4}</cansalemoney><payablemoney>{5}</payablemoney><zxmacnumber>{6}</zxmacnumber><querytime>{7}</querytime><prntext>{8}</prntext>",
        //        _r_id, _r_balance, _r_creditline, _r_outstandingmoney, _r_cansalemoney,_r_payablemoney,_r_zxmacnumber,_r_querytime,_r_prntext);
        //    dataBuilder.Append("<datalist>");
        //    foreach (PayMoneyDataItem item in _r_dataList)
        //    {
        //        dataBuilder.Append(item.PackDataItem());
        //    }
        //    dataBuilder.Append("</datalist>");
        //    dataBuilder.Append("</machinepaymoneyreport>");
        //    return dataBuilder.ToString();
        //}
        #region Model
        private int _r_id;
        private string _r_zxmacnumber = "";
        private decimal _r_balance = 0;
        private decimal _r_creditline = 0;
        private decimal _r_outstandingmoney = 0;
        private decimal _r_cansalemoney = 0;
        private decimal _r_payablemoney = 0;
        private List<PayMoneyDataItem> _r_dataList=new List<PayMoneyDataItem>();
        private DateTime _r_querytime = new DateTime(1900, 1, 1);
        private string _r_prntext = "";
        /// <summary>
        /// 主键ID
        /// </summary>
        public int R_Id
        {
            set { _r_id = value; }
            get { return _r_id; }
        }
        /// <summary>
        /// 销售点（中心机器号）
        /// </summary>
        public string R_ZxMacNumber
        {
            set { _r_zxmacnumber = value; }
            get { return _r_zxmacnumber; }
        }
        /// <summary>
        /// 当前账户余额
        /// </summary>
        public decimal R_Balance
        {
            get { return _r_balance; }
            set { _r_balance = value; }
        }
        /// <summary>
        /// 本销售点信用额度
        /// </summary>
        public decimal R_CreditLine
        {
            get { return _r_creditline; }
            set { _r_creditline = value; }
        }
        /// <summary>
        /// 未结算金额
        /// </summary>
        public decimal R_OutstandingMoney
        {
            get { return _r_outstandingmoney; }
            set { _r_outstandingmoney = value; }
        }
        /// <summary>
        /// 当前售票额度
        /// </summary>
        public decimal R_CanSaleMoney
        {
            set { _r_cansalemoney = value; }
            get { return _r_cansalemoney; }
        }
        /// <summary>
        /// 最新应缴款
        /// </summary>
        public decimal R_PayableMoney
        {
            get { return _r_payablemoney; }
            set { _r_payablemoney = value; }
        }
        /// <summary>
        /// 报表查询时间
        /// </summary>
        public DateTime R_QueryTime
        {
            set { _r_querytime = value; }
            get { return _r_querytime; }
        }
        /// <summary>
        /// 电子票文本
        /// </summary>
        public string R_PrnText
        {
            get { return _r_prntext; }
            set { _r_prntext = value; }
        }
        /// <summary>
        /// 交款明细列表,按缴款时间由近到远排好序了
        /// </summary>
        public List<PayMoneyDataItem> R_DataList
        {
            get { return _r_dataList; }
            set { _r_dataList = value; }
        }

        #endregion Model
    }
    /// <summary>
    /// 交款明细
    /// </summary>
    public class PayMoneyDataItem
    {
        public PayMoneyDataItem()
        {
            
        }
        public PayMoneyDataItem(int paytype, decimal paymoney, DateTime paytime)
        {
            _paytype = paytype;
            _paymoney = paymoney;
            _paytime = paytime;
            _fee = 0M;
        }
        public PayMoneyDataItem(int paytype, decimal paymoney, DateTime paytime,decimal fee)
        {
            _paytype = paytype;
            _paymoney = paymoney;
            _paytime = paytime;
            _fee = fee;
        }
        //public PayMoneyDataItem(XmlNode node)
        //{
        //    if(node==null)
        //    {
        //        return;
        //    }
        //    XmlAttributeCollection attributes = node.Attributes;
        //    if(attributes!=null)
        //    {
        //        decimal.TryParse(attributes["paymoney"].InnerText, out _paymoney);
        //        DateTime.TryParse(attributes["paytime"].InnerText, out _paytime);
        //    }
        //}
        ///// <summary>
        ///// 打包参数
        ///// </summary>
        //public string PackDataItem()
        //{
        //    return string.Format("<dataitem paymoney=\"{0}\" paytime=\"{1}\"></dataitem>", _paymoney, _paytime);
        //}
        private decimal _paymoney=0M;
        private DateTime _paytime = DateTime.MinValue;
        /// <summary>
        /// 交款金额
        /// </summary>
        public decimal PayMoney
        {
            get { return _paymoney; }
            set { _paymoney = value; }
        }
        /// <summary>
        /// 交款时间
        /// </summary>
        public DateTime PayTime
        {
            get { return _paytime; }
            set { _paytime = value; }
        }

        private int _paytype;
        /// <summary>
        /// 1：缴款；2：佣金；3：转入即开；4：支付宝充值；5：微信充值；
        /// </summary>
        public int PayType
        {
            get { return _paytype; }
            set { _paytype = value; }
        }

        private decimal _fee=0M;
        /// <summary>
        /// 移动充值手续费
        /// </summary>
        public decimal Fee
        {
            get { return _fee; }
            set { _fee = value; }
        }
    }
}
