chore: update
This commit is contained in:
@@ -182,6 +182,20 @@ func tryAssignCommandWithPriority(
|
||||
|
||||
database.AddCommandLog(commandID, "assigned", logMessage, "system-cron")
|
||||
|
||||
// 8. Notifier le livreur de la nouvelle commande
|
||||
notifMsg := fmt.Sprintf("Nouvelle commande #%d assignée - Livraison dans ~%d min (%.2f km)", commandID, travelTime, distance)
|
||||
if notifErr := database.NotifyLivreur(nearest.Username, commandID, "new_assignment", notifMsg); notifErr != nil {
|
||||
log.Printf("⚠️ [CRON] Erreur notification livreur %s: %v", nearest.Username, notifErr)
|
||||
}
|
||||
|
||||
// 9. Notifier le client
|
||||
if cmd, err := database.GetCommandByID(commandID); err == nil {
|
||||
if clientUsername, ok := cmd["username"].(string); ok && clientUsername != "" {
|
||||
clientMsg := fmt.Sprintf("Votre commande #%d est confirmée ! Livraison prévue dans ~%d min", commandID, travelTime)
|
||||
database.NotifyClient(clientUsername, commandID, "assigned", clientMsg)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("✅ [CRON] Cmd %d → %s (%.2f km) | Priorité #%d | Attente: %d min",
|
||||
commandID, nearest.Username, distance, priority, waitingMinutes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user