package company

import "time"

// Company 客户表
type Company struct {
	CompanyID       uint64    `gorm:"primaryKey;column:company_id;type:bigint(20) unsigned;not null" json:"-"`                           // 客户id
	CompanyName     string    `gorm:"index:company_name;column:company_name;type:varchar(100)" json:"companyName"`                       // 客户名称
	CreditCode      string    `gorm:"column:credit_code;type:varchar(30)" json:"creditCode"`                                             // 社会统一信用码
	CompanyCode     string    `gorm:"index:company_code;column:company_code;type:varchar(32)" json:"companyCode"`                        // 客户编码
	Sort            int       `gorm:"column:sort;type:int(10);default:1" json:"sort"`                                                    // 优先级
	IsFeeCustomer   int8      `gorm:"column:is_fee_customer;type:tinyint(1)" json:"isFeeCustomer"`                                       // 是否付费用户
	Country         string    `gorm:"column:country;type:varchar(20)" json:"country"`                                                    // 国家编码
	ProvinceID      int64     `gorm:"index:province_id;column:province_id;type:bigint(20)" json:"provinceId"`                            // 省id
	CityID          int64     `gorm:"index:city_id;column:city_id;type:bigint(20)" json:"cityId"`                                        // 市id
	Address         string    `gorm:"column:address;type:varchar(512)" json:"address"`                                                   // 详细地址
	Type            int       `gorm:"column:type;type:int(10);default:1" json:"type"`                                                    // 客户标签,1：付费客户，2：试用客户，3：流失客户，4：潜在客户,5:永续
	Enabled         int8      `gorm:"index:enabled;column:enabled;type:tinyint(1);default:1" json:"enabled"`                             // 用户状态
	CreatedTime     time.Time `gorm:"index:created_time;column:created_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createdTime"` // 创建时间
	LastUpdatedTime time.Time `gorm:"index:last_updated_time;column:last_updated_time;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"lastUpdatedTime"`
	Seller          string    `gorm:"column:seller;type:varchar(200)" json:"seller"`                            // 销售员
	SellsID         int64     `gorm:"index:idx_sells_id;column:sells_id;type:bigint(20)" json:"sellsId"`        // 销售员id
	CompanyBelong   string    `gorm:"column:company_belong;type:varchar(30);default:ficc" json:"companyBelong"` // 客户所属，ficc：ficc客户，public_offering：公募客户，partner：合作伙伴
	StartDate       time.Time `gorm:"column:start_date;type:date" json:"startDate"`                             // 合同开始日期
	EndDate         time.Time `gorm:"column:end_date;type:date" json:"endDate"`                                 // 合同结束日期
	LoseReason      string    `gorm:"column:lose_reason;type:varchar(1024);default:''" json:"loseReason"`       // 流失原因
	LastType        int       `gorm:"column:last_type;type:int(10)" json:"lastType"`                            // 原客户标签
	LossTime        time.Time `gorm:"column:loss_time;type:datetime;not null" json:"lossTime"`                  // 流失时间
	FirstStartDate  time.Time `gorm:"column:first_start_date;type:date" json:"firstStartDate"`                  // 首次设置为试用客户开始时间
	FirstEndDate    time.Time `gorm:"column:first_end_date;type:date" json:"firstEndDate"`                      // 首次设置为试用客户结束时间
	DateType        int       `gorm:"column:date_type;type:int(11);default:0" json:"dateType"`
	Remark          string    `gorm:"column:remark;type:varchar(255)" json:"remark"`                               // 备注
	Province        string    `gorm:"column:province;type:varchar(100);default:''" json:"province"`                // 省
	City            string    `gorm:"column:city;type:varchar(100);default:''" json:"city"`                        // 市
	IsVip           int8      `gorm:"column:is_vip;type:tinyint(4)" json:"isVip"`                                  // 0:普通用户,1:大客户
	RegionType      string    `gorm:"column:region_type;type:varchar(30);default:''" json:"regionType"`            // 国内，海外
	OpenCompanyCode string    `gorm:"column:open_company_code;type:varchar(64);default:''" json:"openCompanyCode"` // 开放给第三方的客户编码，不让第三方定位我们的客户信息
}

// TableName get sql table name.获取数据库表名
func (m *Company) TableName() string {
	return "company"
}

// CompanyColumns get sql column name.获取数据库列名
var CompanyColumns = struct {
	CompanyID       string
	CompanyName     string
	CreditCode      string
	CompanyCode     string
	Sort            string
	IsFeeCustomer   string
	Country         string
	ProvinceID      string
	CityID          string
	Address         string
	Type            string
	Enabled         string
	CreatedTime     string
	LastUpdatedTime string
	Seller          string
	SellsID         string
	CompanyBelong   string
	StartDate       string
	EndDate         string
	LoseReason      string
	LastType        string
	LossTime        string
	FirstStartDate  string
	FirstEndDate    string
	DateType        string
	Remark          string
	Province        string
	City            string
	IsVip           string
	RegionType      string
	OpenCompanyCode string
}{
	CompanyID:       "company_id",
	CompanyName:     "company_name",
	CreditCode:      "credit_code",
	CompanyCode:     "company_code",
	Sort:            "sort",
	IsFeeCustomer:   "is_fee_customer",
	Country:         "country",
	ProvinceID:      "province_id",
	CityID:          "city_id",
	Address:         "address",
	Type:            "type",
	Enabled:         "enabled",
	CreatedTime:     "created_time",
	LastUpdatedTime: "last_updated_time",
	Seller:          "seller",
	SellsID:         "sells_id",
	CompanyBelong:   "company_belong",
	StartDate:       "start_date",
	EndDate:         "end_date",
	LoseReason:      "lose_reason",
	LastType:        "last_type",
	LossTime:        "loss_time",
	FirstStartDate:  "first_start_date",
	FirstEndDate:    "first_end_date",
	DateType:        "date_type",
	Remark:          "remark",
	Province:        "province",
	City:            "city",
	IsVip:           "is_vip",
	RegionType:      "region_type",
	OpenCompanyCode: "open_company_code",
}
