using MadRunFabric.Common;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace MadRunFabric.Model.WorkOrderApi
{
    /// <summary>
    /// 工单表 - 售后管理系统
    /// </summary>
    [BsonIgnoreExtraElements]
    public class Bus_WorkOrder_Base : IBaseModel<string>
    {
        /// <summary>
        /// id
        /// </summary>
        [Key]
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string id { get; set; }
        /// <summary>
        /// 工单编号
        /// </summary>
        public string ordercode { get; set; }
        /// <summary>
        /// 通话唯一ID
        /// </summary>
        public string unique_id { get; set; }
        /// <summary>
        /// 通话记录id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string callrecordid { get; set; }
        /// <summary>
        /// 类型id （字典）（两类：咨询、售后、业务办理、预约登记、订单）
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string typeid { get; set; }
        /// <summary>
        /// 工单状态:0创建，1待处理，2待指派，3待接单，9完成
        /// </summary>
        public int state { get; set; } = 0;
        //---------------------------------------------------------
        /// <summary>
        /// 客户id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string customerid { get; set; }
        /// <summary>
        /// 客户姓名
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 单位名称
        /// </summary>
        public string company { get; set; }
        /// <summary>
        /// 来电电话
        /// </summary>
        public string callintel { get; set; }
        /// <summary>
        /// 联系电话
        /// </summary>
        public string phone { get; set; }
        /// <summary>
        /// 省code（自动获取）
        /// </summary>
        public string province { get; set; }
        /// <summary>
        /// 市code（自动获取）
        /// </summary>
        public string city { get; set; }
        //---------------------------------------------------------
        /// <summary>
        /// 客户项目id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string proid { get; set; }
        /// <summary>
        /// 项目名称
        /// </summary>
        public string projectname { get; set; }
        /// <summary>
        /// 项目地点
        /// </summary>
        public string address { get; set; }
        /// <summary>
        /// 故障设备
        /// </summary>
        public string faulty_equipment { get; set; }
        /// <summary>
        /// 故障内容/咨询内容
        /// </summary>
        public string content { get; set; }
        /// <summary>
        /// 故障类型
        /// 两级: 一级：话务故障、系统性能（4小时）、软件bug（2小时定位到人，8小时给予预计处理完成时间）、甲方环境（4小时）、商务授权（24小时）、超出维保（24小时）、未知原因（48小时）
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string faulty_typeid { get; set; }
        /// <summary>
        /// 故障类型
        /// 两级: 一级：话务故障
        ///      二级：话务故障：用户自有线路（2小时）、中间件（4小时定位到处理人）、语音交换问题（4小时）]
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string faulty_type2id { get; set; }
        /// <summary>
        /// 售后来源（字典）（三大类：甲方对施工人员、客服对施工人员、商务部门转接）
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string sourceid { get; set; }
        /// <summary>
        /// 处理时效(字典)(2小时、4小时、8小时、24小时、48小时)
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string productive { get; set; }
        //---------------------------------------------------------
        /// <summary>
        /// 咨询部门id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string deptid { get; set; }
        /// <summary>
        /// 最后处理部门id
        /// </summary>
        [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
        public string dealdeptid { get; set; }
        /// <summary>
        /// 最后处理时间
        /// </summary>
        public DateTime? dealtime { get; set; }
        /// <summary>
        /// 最后处理人工号
        /// </summary>
        public string dealuser { get; set; }
        /// <summary>
        /// 最后处理人姓名
        /// </summary>
        public string dealusername { get; set; }
        /// <summary>
        /// 处理结果
        /// </summary>
        public string result { get; set; }
        //---------------------------------------------------------
        /// <summary>
        /// 创建时间 - 手动填写
        /// </summary>
        public DateTime createtime { get; set; } = DateTime.Now;
        /// <summary>
        /// 创建人工号
        /// </summary>
        public string createuser { get; set; }
        /// <summary>
        /// 创建人姓名
        /// </summary>
        public string createusername { get; set; }
        /// <summary>
        /// 是否删除（0正常1删除）
        /// </summary>
        public int isdelete { get; set; } = 0;
        /// <summary>
        /// 删除用户
        /// </summary>
        public string deleteuser { get; set; }
        /// <summary>
        /// 删除时间
        /// </summary>
        public DateTime? deletetime { get; set; }

        /// <summary>
        /// 指派时间
        /// </summary>
        public DateTime? zptime { get; set; } = DateTime.Now;

        /// <summary>
        /// 指派人code
        /// </summary>
        public string zpusercode { get; set; }

        /// <summary>
        /// 接收人
        /// </summary>
        public string touser { get; set; }

        /// <summary>
        /// 业务类型
        /// </summary>
        public string businesstype { get; set; }

        /// <summary>
        /// 工单有效性,1有效0无效
        /// </summary>
        public int iseffective { get; set; }

        /// <summary>
        /// 是否立即处理，1是0否
        /// </summary>
        public int dealinstantly { get; set; }

        /// <summary>
        /// 接单人
        /// </summary>
        public string sureuser { get; set; }

        /// <summary>
        /// 是否退回过(退回次数)
        /// </summary>
        public int isreback { get; set; } = 0;
    }
    /// <summary>
    /// 工单状态:0未处理，1已处理
    /// </summary>
    public enum EnumOrderType
    {
        /// <summary>
        /// 0创建工单
        /// </summary>
        create = 0,
        /// <summary>
        /// 1未处理
        /// </summary>
        deal = 1,
        /// <summary>
        /// 2已指派
        /// </summary>
        appoint = 2,
        /// <summary>
        /// 3已接单
        /// </summary>
        accept = 3,
        /// <summary>
        /// 9已处理
        /// </summary>
        complete = 9,
    }
}
