feat: add ExternalType to customer identity model and update related services and enums
This commit is contained in:
@@ -188,6 +188,7 @@ type Customer struct {
|
|||||||
type CustomerIdentity struct {
|
type CustomerIdentity struct {
|
||||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||||
CustomerID int64 `gorm:"type:bigint;not null;uniqueIndex:uk_customer_external"` // 为所属客户ID。
|
CustomerID int64 `gorm:"type:bigint;not null;uniqueIndex:uk_customer_external"` // 为所属客户ID。
|
||||||
|
ExternalType enums.ExternalType `gorm:"type:varchar(30);not null;default:'guest';index"` // ExternalType 为外部身份类型:guest访客,user主动设置的用户信息。
|
||||||
ExternalSource enums.ExternalSource `gorm:"type:varchar(30);uniqueIndex:uk_customer_external"` // 为外部身份来源
|
ExternalSource enums.ExternalSource `gorm:"type:varchar(30);uniqueIndex:uk_customer_external"` // 为外部身份来源
|
||||||
ExternalID string `gorm:"type:varchar(128);index:idx_external_id;uniqueIndex:uk_customer_external"` // 为平台侧用户唯一ID,与访客 ExternalID 对齐。
|
ExternalID string `gorm:"type:varchar(128);index:idx_external_id;uniqueIndex:uk_customer_external"` // 为平台侧用户唯一ID,与访客 ExternalID 对齐。
|
||||||
RawProfile string `gorm:"type:text"` // 为第三方原始资料JSON。
|
RawProfile string `gorm:"type:text"` // 为第三方原始资料JSON。
|
||||||
|
|||||||
@@ -6,6 +6,26 @@ func GetCustomerSourceTypeLabel(sourceType ExternalSource) string {
|
|||||||
return GetExternalSourceLabel(ExternalSource(sourceType))
|
return GetExternalSourceLabel(ExternalSource(sourceType))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExternalType 客户外部身份类型。
|
||||||
|
type ExternalType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ExternalTypeGuest ExternalType = "guest"
|
||||||
|
ExternalTypeUser ExternalType = "user"
|
||||||
|
)
|
||||||
|
|
||||||
|
var externalTypeLabelMap = map[ExternalType]string{
|
||||||
|
ExternalTypeGuest: "访客",
|
||||||
|
ExternalTypeUser: "用户",
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetExternalTypeLabel(externalType ExternalType) string {
|
||||||
|
if s, ok := externalTypeLabelMap[externalType]; ok {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return string(externalType)
|
||||||
|
}
|
||||||
|
|
||||||
// 联系方式类型
|
// 联系方式类型
|
||||||
type ContactType string
|
type ContactType string
|
||||||
|
|
||||||
|
|||||||
@@ -744,6 +744,7 @@ func (s *conversationService) LinkConversationCustomer(conversationID, customerI
|
|||||||
} else {
|
} else {
|
||||||
idRow := &models.CustomerIdentity{
|
idRow := &models.CustomerIdentity{
|
||||||
CustomerID: customerID,
|
CustomerID: customerID,
|
||||||
|
ExternalType: enums.ExternalTypeGuest,
|
||||||
ExternalSource: enums.ExternalSource(extSrc),
|
ExternalSource: enums.ExternalSource(extSrc),
|
||||||
ExternalID: extID,
|
ExternalID: extID,
|
||||||
Status: enums.StatusOk,
|
Status: enums.StatusOk,
|
||||||
|
|||||||
@@ -82,6 +82,15 @@ export const ExternalSourceLabels: Record<ExternalSource, string> = {
|
|||||||
[ExternalSource.WxWorkKF]: "企业微信客服",
|
[ExternalSource.WxWorkKF]: "企业微信客服",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ExternalType {
|
||||||
|
Guest = "guest",
|
||||||
|
User = "user",
|
||||||
|
}
|
||||||
|
export const ExternalTypeLabels: Record<ExternalType, string> = {
|
||||||
|
[ExternalType.Guest]: "访客",
|
||||||
|
[ExternalType.User]: "用户",
|
||||||
|
}
|
||||||
|
|
||||||
export enum Gender {
|
export enum Gender {
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
Male = 1,
|
Male = 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user