You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
3.1 KiB
52 lines
3.1 KiB
package models
|
|
|
|
import (
|
|
"ims/util/db/dts"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// CustomerSource 客户来源
|
|
type CustomerSource int8
|
|
|
|
const (
|
|
FromRecommend CustomerSource = iota + 1 // 转介绍
|
|
FromPC // 网站注册
|
|
FromMiniProgram // 小程序注册
|
|
FromSalesman // 销售自拓
|
|
)
|
|
|
|
// Customer 客户
|
|
type Customer struct {
|
|
ID uint `json:"id" gorm:"primarykey"` // 客户ID
|
|
Code string `json:"code" gorm:"uniqueIndex"` // 客户编码
|
|
Name string `json:"name" gorm:"uniqueIndex"` // 客户名称
|
|
Source CustomerSource `json:"source"` // 客户来源
|
|
TypeID uint `json:"type_id"` // 客户类型
|
|
TagID dts.NullUint `json:"tag_id"` // 客户标签
|
|
PriceStrategyID dts.NullUint `json:"price_strategy_id"` // 价格策略
|
|
SettlementID dts.NullUint `json:"settlement_id"` // 结算方式
|
|
CreditLimit int `json:"credit_limit"` // 信用额度,单位分
|
|
PrincipalID dts.NullUint `json:"principal_id"` // 销售负责人编号
|
|
|
|
Type *Tag `json:"type,omitempty" gorm:"foreignKey:TypeID"` // 客户类型
|
|
Tag *Tag `json:"Tag,omitempty" gorm:"foreignKey:TagID"` // 客户标签
|
|
PriceStrategy *Tag `json:"price_strategy" gorm:"foreignKey:PriceStrategyID"` // 价格策略
|
|
Settlement *Tag `json:"settlement" gorm:"foreignKey:SettlementID"` // 结算方式
|
|
Principal *Employee `json:"principal" gorm:"foreignKey:PrincipalID"` // 销售负责人
|
|
Address *Address `json:"address,omitempty" gorm:"polymorphic:Owner;polymorphicValue:customer"` // 客户地址
|
|
Remittance *Remittance `json:"remittance,omitempty" gorm:"polymorphic:Owner;polymorphicValue:customer"` // 汇款信息
|
|
Linkmen []Linkman `json:"linkmen,omitempty" gorm:"polymorphic:Owner;polymorphicValue:customer"` // 联系人列表
|
|
|
|
CreatedBy uint `json:"created_by"` // 创建者(员工编号)
|
|
CreatedAt time.Time `json:"created_at"` // 创建时间
|
|
UpdatedBy dts.NullUint `json:"updated_by"` // 创建者(员工编号)
|
|
UpdatedAt dts.NullTime `json:"updated_at" gorm:"autoUpdateTime:false"` // 上次操作时间
|
|
DeletedBy dts.NullUint `json:"deleted_by"` // 删除者(员工编号)
|
|
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` // 删除数据时间
|
|
|
|
Creator *Employee `json:"creator,omitempty" gorm:"foreignKey:CreatedBy"` // 创建数据的员工
|
|
Updater *Employee `json:"updater,omitempty" gorm:"foreignKey:UpdatedBy"` // 上次更新数据的员工
|
|
Deleter *Employee `json:"deleter,omitempty" gorm:"foreignKey:DeletedBy"` // 删除数据的员工
|
|
}
|
|
|