up
This commit is contained in:
@@ -21,6 +21,7 @@ type NotificacionLog struct {
|
|||||||
Asunto string `json:"asunto" gorm:"column:asunto"`
|
Asunto string `json:"asunto" gorm:"column:asunto"`
|
||||||
PreviewHTML string `json:"preview_html" gorm:"column:preview_html;type:text"`
|
PreviewHTML string `json:"preview_html" gorm:"column:preview_html;type:text"`
|
||||||
Pasarela string `json:"pasarela" gorm:"column:pasarela;type:varchar(20)"` // bold | dlocal | (vacío para correos de aviso)
|
Pasarela string `json:"pasarela" gorm:"column:pasarela;type:varchar(20)"` // bold | dlocal | (vacío para correos de aviso)
|
||||||
|
EnlacePago string `json:"enlace_pago" gorm:"column:enlace_pago;type:text"` // URL del link de pago generado en este envío
|
||||||
}
|
}
|
||||||
|
|
||||||
func (NotificacionLog) TableName() string { return "notificaciones_log" }
|
func (NotificacionLog) TableName() string { return "notificaciones_log" }
|
||||||
@@ -74,9 +75,10 @@ func CreateNotificacionLog(n NotificacionLog) (*NotificacionLog, error) {
|
|||||||
|
|
||||||
func UpdateNotificacionLog(n NotificacionLog) error {
|
func UpdateNotificacionLog(n NotificacionLog) error {
|
||||||
return app.Http.Database.DB.Model(&n).Updates(map[string]interface{}{
|
return app.Http.Database.DB.Model(&n).Updates(map[string]interface{}{
|
||||||
"estado": n.Estado,
|
"estado": n.Estado,
|
||||||
"error_msg": n.ErrorMsg,
|
"error_msg": n.ErrorMsg,
|
||||||
"pasarela": n.Pasarela,
|
"pasarela": n.Pasarela,
|
||||||
|
"enlace_pago": n.EnlacePago,
|
||||||
}).Error
|
}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ func EnviarNotificacionGrupo(regla *models.NotificacionRegla, cliente *models.Cl
|
|||||||
Asunto: p.Asunto,
|
Asunto: p.Asunto,
|
||||||
PreviewHTML: html,
|
PreviewHTML: html,
|
||||||
Pasarela: pasarela,
|
Pasarela: pasarela,
|
||||||
|
EnlacePago: enlacePago,
|
||||||
}
|
}
|
||||||
savedLog, err := models.CreateNotificacionLog(logEntry)
|
savedLog, err := models.CreateNotificacionLog(logEntry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -229,7 +229,14 @@
|
|||||||
<div class="ml-1">
|
<div class="ml-1">
|
||||||
<p class="text-sm font-medium text-gray-800" x-text="ev.titulo"></p>
|
<p class="text-sm font-medium text-gray-800" x-text="ev.titulo"></p>
|
||||||
<p class="text-xs text-gray-500 mt-0.5" x-text="ev.detalle"></p>
|
<p class="text-xs text-gray-500 mt-0.5" x-text="ev.detalle"></p>
|
||||||
<time class="text-xs text-gray-400" x-text="fmtDatetime(ev.fecha)"></time>
|
<template x-if="ev.enlace">
|
||||||
|
<a :href="ev.enlace" target="_blank" rel="noopener"
|
||||||
|
class="inline-flex items-center gap-1 text-xs text-indigo-600 hover:underline mt-0.5 break-all">
|
||||||
|
<svg class="w-3 h-3 shrink-0" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"/></svg>
|
||||||
|
<span x-text="ev.enlace.length > 50 ? ev.enlace.slice(0,50)+'…' : ev.enlace"></span>
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
|
<time class="block text-xs text-gray-400 mt-0.5" x-text="fmtDatetime(ev.fecha)"></time>
|
||||||
<span x-show="ev.estado==='error'" class="ml-2 text-xs text-red-500 font-medium">Fallido</span>
|
<span x-show="ev.estado==='error'" class="ml-2 text-xs text-red-500 font-medium">Fallido</span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ func GetHistorialContrato(c *fiber.Ctx) error {
|
|||||||
Icono string `json:"icono"`
|
Icono string `json:"icono"`
|
||||||
Titulo string `json:"titulo"`
|
Titulo string `json:"titulo"`
|
||||||
Detalle string `json:"detalle"`
|
Detalle string `json:"detalle"`
|
||||||
|
Enlace string `json:"enlace"` // URL de pago generada en este envío (opcional)
|
||||||
Estado string `json:"estado"` // ok | error | info
|
Estado string `json:"estado"` // ok | error | info
|
||||||
FechaISO string `json:"fecha"`
|
FechaISO string `json:"fecha"`
|
||||||
}
|
}
|
||||||
@@ -264,6 +265,18 @@ func GetHistorialContrato(c *fiber.Ctx) error {
|
|||||||
FechaISO: contrato.CreatedAt.Format(time.RFC3339),
|
FechaISO: contrato.CreatedAt.Format(time.RFC3339),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Evento: pago confirmado (directo del contrato, siempre visible si se pagó)
|
||||||
|
if contrato.PagoConfirmado && contrato.FechaPago != nil {
|
||||||
|
timeline = append(timeline, Evento{
|
||||||
|
Tipo: "pago",
|
||||||
|
Icono: "currency",
|
||||||
|
Titulo: "Pago confirmado",
|
||||||
|
Detalle: "Nuevo vencimiento: " + contrato.FechaVencimiento.Format("02/01/2006"),
|
||||||
|
Estado: "ok",
|
||||||
|
FechaISO: contrato.FechaPago.Format(time.RFC3339),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Evento: renovaciones (updated_at con estado renovado — heurístico por estado)
|
// Evento: renovaciones (updated_at con estado renovado — heurístico por estado)
|
||||||
if contrato.Estado == "renovado" {
|
if contrato.Estado == "renovado" {
|
||||||
timeline = append(timeline, Evento{
|
timeline = append(timeline, Evento{
|
||||||
@@ -297,6 +310,7 @@ func GetHistorialContrato(c *fiber.Ctx) error {
|
|||||||
Icono: "mail",
|
Icono: "mail",
|
||||||
Titulo: "Notificación enviada" + reglaLabel,
|
Titulo: "Notificación enviada" + reglaLabel,
|
||||||
Detalle: detalle,
|
Detalle: detalle,
|
||||||
|
Enlace: n.EnlacePago,
|
||||||
Estado: estado,
|
Estado: estado,
|
||||||
FechaISO: n.CreatedAt.Format(time.RFC3339),
|
FechaISO: n.CreatedAt.Format(time.RFC3339),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user