diff --git a/projects/ai-customer-service/go.mod b/projects/ai-customer-service/go.mod index 13e93bf7..6f2ed260 100644 --- a/projects/ai-customer-service/go.mod +++ b/projects/ai-customer-service/go.mod @@ -2,4 +2,7 @@ module github.com/bridge/ai-customer-service go 1.22 -require github.com/lib/pq v1.10.9 +require ( + github.com/google/uuid v1.6.0 + github.com/lib/pq v1.10.9 +) diff --git a/projects/ai-customer-service/go.sum b/projects/ai-customer-service/go.sum index aeddeae3..ae20c4cb 100644 --- a/projects/ai-customer-service/go.sum +++ b/projects/ai-customer-service/go.sum @@ -1,2 +1,4 @@ +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= diff --git a/projects/ai-customer-service/internal/service/dialog/service.go b/projects/ai-customer-service/internal/service/dialog/service.go index a67da3a4..7b24dd20 100644 --- a/projects/ai-customer-service/internal/service/dialog/service.go +++ b/projects/ai-customer-service/internal/service/dialog/service.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + "github.com/google/uuid" + "github.com/bridge/ai-customer-service/internal/domain/audit" intentdomain "github.com/bridge/ai-customer-service/internal/domain/intent" "github.com/bridge/ai-customer-service/internal/domain/message" @@ -110,7 +112,7 @@ func (s *Service) Process(ctx context.Context, msg *message.UnifiedMessage) (*Re sess.Status = session.StatusHandoff replyText = "已为您转人工客服,请稍候,我们会尽快处理。" if s.tickets != nil { - ticketID = fmt.Sprintf("%s-%d", sess.ID, now.UnixNano()) + ticketID = uuid.New().String() ticketPriority := ticket.Priority(handoffDecision.Priority) if ticketPriority == "" { ticketPriority = ticket.PriorityP2 @@ -136,7 +138,7 @@ func (s *Service) Process(ctx context.Context, msg *message.UnifiedMessage) (*Re if ticketID != "" { auditPayload["ticket_id"] = ticketID } - if err := s.audits.Add(ctx, audit.Event{ID: fmt.Sprintf("%s-%d", sess.ID, now.UnixNano()), SessionID: sess.ID, Type: "message_processed", Action: "process", Channel: msg.Channel, OpenID: msg.OpenID, ActorID: msg.OpenID, Payload: auditPayload, CreatedAt: now}); err != nil { + if err := s.audits.Add(ctx, audit.Event{ID: uuid.New().String(), SessionID: sess.ID, Type: "message_processed", Action: "process", Channel: msg.Channel, OpenID: msg.OpenID, ActorID: msg.OpenID, Payload: auditPayload, CreatedAt: now}); err != nil { return nil, err }