ai_scheduler/internal/data/model/ai_advice_follow.go

113 lines
5.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import "time"
// ===== 共享枚举(定时提醒 + 成交线索 分类,用于复盘抽取时的类型判定)=====
// 抽取分类 type:remind 单纯提醒(到点 AI 主动发);visit/deal/payment 成交线索。
const (
FollowTypeRemind = "remind" // 单纯提醒:到点 AI 主动发消息
FollowTypeVisit = "visit" // 约定到访(成交线索)
FollowTypeDeal = "deal" // 约定成交(成交线索)
FollowTypePayment = "payment" // 约定付款/给钱(成交线索)
)
// 状态(两表共用):pending 待处理;done 已完成;cancelled 已取消;failed 执行失败(仅提醒)。
const (
FollowStatusPending = "pending"
FollowStatusDone = "done"
FollowStatusCancelled = "cancelled"
FollowStatusFailed = "failed"
)
// 来源(两表共用):ai 复盘抽取;manual 手动补录。
const (
FollowSourceAi = "ai"
FollowSourceManual = "manual"
)
// IsValidFollowType 是否为合法的抽取分类。
func IsValidFollowType(t string) bool {
switch t {
case FollowTypeRemind, FollowTypeVisit, FollowTypeDeal, FollowTypePayment:
return true
}
return false
}
// IsLeadType 是否为成交线索类(到访/成交/付款)。
func IsLeadType(t string) bool {
return t == FollowTypeVisit || t == FollowTypeDeal || t == FollowTypePayment
}
// LeadTypeLabel 类型中文标签(供对话注入与提示使用)。
func LeadTypeLabel(t string) string {
switch t {
case FollowTypeVisit:
return "约定到访"
case FollowTypeDeal:
return "约定成交"
case FollowTypePayment:
return "约定付款"
case FollowTypeRemind:
return "提醒回访"
}
return "跟进事项"
}
// ===== 定时提醒表 =====
const TableNameAiAdviceRemindTask = "ai_advice_remind_task"
// AiAdviceRemindTask 定时提醒(到点由 AI 主动发消息提醒客户)。mapped from <ai_advice_remind_task>
type AiAdviceRemindTask struct {
Id int64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
ProjectId int32 `gorm:"column:project_id;not null;comment:项目ID" json:"project_id"`
AdvicerId int32 `gorm:"column:advicer_id;not null;comment:所属销售ID" json:"advicer_id"`
ClientId string `gorm:"column:client_id;not null;comment:客户画像ID(Mongo _id hex)" json:"client_id"`
Wxid string `gorm:"column:wxid;not null;comment:客户微信ID" json:"wxid"`
SelfWxid string `gorm:"column:self_wxid;not null;comment:销售本人微信ID" json:"self_wxid"`
AppId string `gorm:"column:app_id;not null;comment:销售登录设备appid" json:"app_id"`
Title string `gorm:"column:title;not null;comment:提醒标题" json:"title"`
Detail string `gorm:"column:detail;comment:提醒详情" json:"detail"`
DueAt time.Time `gorm:"column:due_at;not null;comment:到点时间" json:"due_at"`
Status string `gorm:"column:status;not null;default:pending;comment:状态" json:"status"`
Source string `gorm:"column:source;not null;default:ai;comment:来源 ai/manual" json:"source"`
SourceMsgIds string `gorm:"column:source_msg_ids;comment:来源消息ID(逗号分隔)" json:"source_msg_ids"`
Result string `gorm:"column:result;comment:实际发送内容" json:"result"`
ErrMsg string `gorm:"column:err_msg;not null;comment:失败原因" json:"err_msg"`
DoneAt *time.Time `gorm:"column:done_at;comment:完成/取消时间" json:"done_at"`
CreateAt time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
UpdateAt time.Time `gorm:"column:update_at;default:CURRENT_TIMESTAMP" json:"update_at"`
}
func (*AiAdviceRemindTask) TableName() string { return TableNameAiAdviceRemindTask }
// ===== 成交线索表 =====
const TableNameAiAdviceDealLead = "ai_advice_deal_lead"
// AiAdviceDealLead 成交线索(约定到访/成交/付款,供销售跟进并注入后续对话)。mapped from <ai_advice_deal_lead>
type AiAdviceDealLead struct {
Id int64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
ProjectId int32 `gorm:"column:project_id;not null;comment:项目ID" json:"project_id"`
AdvicerId int32 `gorm:"column:advicer_id;not null;comment:所属销售ID" json:"advicer_id"`
ClientId string `gorm:"column:client_id;not null;comment:客户画像ID(Mongo _id hex)" json:"client_id"`
Wxid string `gorm:"column:wxid;not null;comment:客户微信ID" json:"wxid"`
SelfWxid string `gorm:"column:self_wxid;not null;comment:销售本人微信ID" json:"self_wxid"`
AppId string `gorm:"column:app_id;not null;comment:销售登录设备appid" json:"app_id"`
LeadType string `gorm:"column:lead_type;not null;comment:线索类型 visit/deal/payment" json:"lead_type"`
Title string `gorm:"column:title;not null;comment:线索标题" json:"title"`
Detail string `gorm:"column:detail;comment:线索详情" json:"detail"`
ExpectAt time.Time `gorm:"column:expect_at;not null;comment:期望/约定时间" json:"expect_at"`
Status string `gorm:"column:status;not null;default:pending;comment:状态 pending/done/cancelled" json:"status"`
Source string `gorm:"column:source;not null;default:ai;comment:来源 ai/manual" json:"source"`
SourceMsgIds string `gorm:"column:source_msg_ids;comment:来源消息ID(逗号分隔)" json:"source_msg_ids"`
Result string `gorm:"column:result;comment:跟进结果" json:"result"`
DoneAt *time.Time `gorm:"column:done_at;comment:完成/取消时间" json:"done_at"`
CreateAt time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
UpdateAt time.Time `gorm:"column:update_at;default:CURRENT_TIMESTAMP" json:"update_at"`
}
func (*AiAdviceDealLead) TableName() string { return TableNameAiAdviceDealLead }