提交5个文件, 修改了mongo方法, 如果token获取错误, 然后获取完租户id后, 把错误清除
This commit is contained in:
@@ -487,9 +487,10 @@ const (
|
||||
|
||||
// UserState 用户会话状态(阶段+对话计数+咨询方向,统一5分钟过期)
|
||||
type UserState struct {
|
||||
Stage int `json:"stage"` // 用户阶段:5=未选择方向 0=AI模型 1=打招呼 2=业务 3=发卡片
|
||||
Count int64 `json:"count"` // 对话计数
|
||||
Direction string `json:"direction"` // 用户选择的咨询方向(如:产品咨询、售后服务)
|
||||
Stage int `json:"stage"` // 当前阶段
|
||||
Direction string `json:"direction"` // 咨询方向
|
||||
Count int64 `json:"count"` // 对话计数(v5.2卡片触发)
|
||||
CustomerServiceId string `json:"customerServiceId"` // 用户选择的方向对应的客服账号ID
|
||||
}
|
||||
|
||||
// GetUserState 获取用户状态(阶段+计数)
|
||||
@@ -528,6 +529,17 @@ func SetUserStage(ctx context.Context, userId, platform string, stage int) error
|
||||
return err
|
||||
}
|
||||
|
||||
// SetUserCustomerServiceId 设置用户对应的客服账号ID,并刷新过期时间
|
||||
func SetUserCustomerServiceId(ctx context.Context, userId, platform, customerServiceId string) error {
|
||||
key := UserStateKeyPrefix + userId + "_" + platform
|
||||
_, err := redisClient.Do(ctx, "HSET", key, "customerServiceId", customerServiceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = redisClient.Do(ctx, "EXPIRE", key, UserStateExpireSeconds)
|
||||
return err
|
||||
}
|
||||
|
||||
// SetUserDirection 设置用户选择的咨询方向,并刷新过期时间
|
||||
func SetUserDirection(ctx context.Context, userId, platform, direction string) error {
|
||||
key := UserStateKeyPrefix + userId + "_" + platform
|
||||
|
||||
Reference in New Issue
Block a user