feat: ticket enhancemnet
This commit is contained in:
@@ -132,16 +132,39 @@ func PostCDREventFrom(w http.ResponseWriter, r *http.Request) {
|
||||
CreatedAt: time.Now().UnixMicro(),
|
||||
UpdatedAt: updatedAt,
|
||||
}
|
||||
if err := mfService.InsertCallbackTicket(ticket); err != nil {
|
||||
if err := mfService.InsertCallbackTicket(&ticket); err != nil {
|
||||
log.Error("Failed to insert MF callback ticket", err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
}
|
||||
// 新工单分配后发送邮件通知
|
||||
if selectedAgent.Email != "" {
|
||||
subject := "新工单分配通知"
|
||||
body := fmt.Sprintf("您被分配了一个新的回拨工单,主叫号码:%s", ticket.CallerNumber)
|
||||
go email.SendEmail(selectedAgent.Email, subject, body) // 异步发送
|
||||
// 发送邮件通知
|
||||
emailConfig := config.GetSMTPConfig()
|
||||
if emailConfig != nil && emailConfig.Enabled {
|
||||
// 创建配置副本,避免修改全局配置
|
||||
emailCopy := *emailConfig // 浅拷贝结构体
|
||||
|
||||
// 合并配置中的To地址和当前工单的座席邮箱
|
||||
var recipients []string
|
||||
|
||||
// 添加配置中的原始收件人(如管理员、监控人员等)
|
||||
if len(emailConfig.To) > 0 {
|
||||
recipients = append(recipients, emailConfig.To...)
|
||||
}
|
||||
|
||||
// 添加当前工单的座席邮箱
|
||||
recipients = append(recipients, ticket.AgentEmail)
|
||||
|
||||
// 去重处理(避免重复邮箱)
|
||||
emailCopy.To = email.RemoveDuplicateEmails(recipients)
|
||||
|
||||
// 设置邮件主题和内容
|
||||
emailCopy.Subject = "新工单分配通知"
|
||||
emailCopy.Body = fmt.Sprintf("您被分配了一个新的回拨工单(编号:%d, 主叫号码:%s), 请及时处理.",
|
||||
ticket.TicketId, ticket.CallerNumber)
|
||||
go email.SendEmailWithGomail(emailCopy) // 异步发送
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Warn("No available agents found for callback ticket")
|
||||
|
||||
Reference in New Issue
Block a user