using System;
using System.Text;

namespace BBWY.Client.Models
{
    /// <summary>
    /// 合格证
    /// </summary>
    public class CertificateModel : NotifyObject
    {
        /// <summary>
        /// 合格证id
        /// </summary>
        public long Id { get; set; }
        /// <summary>
        /// skuid
        /// </summary>
        public string SkuId { get; set; }


        private string spuId;
        /// <summary>
        /// spu
        /// </summary>
        public string SpuId { get => spuId; set { Set(ref spuId, value); } }


        private string brand;
        /// <summary>
        /// 品牌
        /// </summary>
        public string Brand { get => brand; set { Set(ref brand, value); } }


        private string brandName;
        /// <summary>
        /// 品名
        /// </summary>
        public string BrandName { get => brandName; set { Set(ref brandName, value); } }

        private string shader;
        /// <summary>
        /// 材质
        /// </summary>
        public string Shader { get => shader; set { Set(ref shader, value); } }

        private string excuteStander;
        /// <summary>
        /// 执行标准
        /// </summary>
        public string ExcuteStander
        {
            get => excuteStander; set
            {
                Set(ref excuteStander, value);
                GetExcuteStanderFormat();
            }
        }


        private string excuteStanderFormat;
        /// <summary>
        /// 执行标准 (,=>换行)
        /// </summary>
        public string ExcuteStanderFormat { get => excuteStanderFormat; set { Set(ref excuteStanderFormat, value); } }

        private string productShop;
        /// <summary>
        /// 生产商
        /// </summary>
        public string ProductShop { get => productShop; set { Set(ref productShop, value); } }

        private string productAdress;
        /// <summary>
        /// 地址
        /// </summary>
        public string ProductAdress { get => productAdress; set { Set(ref productAdress, value); } }

        private string productNo;
        /// <summary>
        /// 型号(货号)
        /// </summary>
        public string ProductNo { get => productNo; set { Set(ref productNo, value); } }

        /// <summary>
        /// 经销商
        /// </summary>
        public string Reseller { get; set; }

        private int isLogo;
        /// <summary>
        /// 是否含3cLogo(0没有 ,1有)
        /// </summary>
        public int IsLogo { get => isLogo; set { Set(ref isLogo, value); } }

        private string factoryNumber;
        /// <summary>
        /// 工厂编号
        /// </summary>
        public string FactoryNumber { get => factoryNumber; set { Set(ref factoryNumber, value); } }
        private string applyAge;
        /// <summary>
        /// 适用年龄
        /// </summary>
        public string ApplyAge { get => applyAge; set { Set(ref applyAge, value); } }


        private CertificateLabelModel labelModel;
        public CertificateLabelModel LabelModel { get => labelModel; set { Set(ref labelModel, value); } }

        void GetExcuteStanderFormat()
        {
            StringBuilder sb = new StringBuilder();
            if (!string.IsNullOrEmpty(ExcuteStander))
                if (this.ExcuteStander.Contains(",") || this.ExcuteStander.Contains(","))//有逗号就拆分
                {
                    var excutes = this.ExcuteStander.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < excutes.Length; i++)
                    {
                        if (i % 2 == 0 && i > 0)//间隔两个换行
                        {
                            sb.Append("\r\n");
                        }
                        sb.Append(excutes[i]).Append("   ");
                    }
                    sb.Remove(sb.Length - 3, 3);
                    this.ExcuteStanderFormat = sb.ToString();
                    return;
                }
            this.ExcuteStanderFormat = ExcuteStander;
        }





        private long goodsNumber = 1;
        /// <summary>
        /// 配件序号
        /// </summary>
        public long GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }



        private int goodsNumberIndex = 1;
        /// <summary>
        /// 配件序号
        /// </summary>
        public int GoodsNumberIndex { get => goodsNumberIndex; set { Set(ref goodsNumberIndex, value); } }


        private string produceDate;
        /// <summary>
        /// 生产日期
        /// </summary>
        public string ProduceDate { get => produceDate; set { Set(ref produceDate, value); } }

        /// <summary>
        /// 配件商品Id
        /// </summary>
        public string PurchaseSkuId { get; set; }
    }
}