up
This commit is contained in:
@@ -106,11 +106,17 @@ func GetBoldWebhookLogs(limit int) ([]BoldWebhookLog, error) {
|
||||
}
|
||||
|
||||
// GetBoldWebhookLogsPaginated devuelve los logs con paginación y filtro por tipo.
|
||||
// El valor especial "APROBADOS" incluye tanto SALE_APPROVED como API_CHECK.
|
||||
func GetBoldWebhookLogsPaginated(page, limit int, tipo string) ([]BoldWebhookLog, int64, error) {
|
||||
var logs []BoldWebhookLog
|
||||
var total int64
|
||||
db := app.Http.Database.DB.Model(&BoldWebhookLog{})
|
||||
if tipo != "" && tipo != "TODOS" {
|
||||
switch tipo {
|
||||
case "", "TODOS":
|
||||
// sin filtro
|
||||
case "APROBADOS":
|
||||
db = db.Where("tipo IN ?", []string{"SALE_APPROVED", "API_CHECK"})
|
||||
default:
|
||||
db = db.Where("tipo = ?", tipo)
|
||||
}
|
||||
db.Count(&total)
|
||||
@@ -121,6 +127,26 @@ func GetBoldWebhookLogsPaginated(page, limit int, tipo string) ([]BoldWebhookLog
|
||||
return logs, total, nil
|
||||
}
|
||||
|
||||
// UpdateBoldWebhookLogDatos actualiza email y monto de un log existente (para rellenar datos faltantes en API_CHECK).
|
||||
func UpdateBoldWebhookLogDatos(id uint, payerEmail string, monto int64) error {
|
||||
updates := map[string]interface{}{}
|
||||
if payerEmail != "" {
|
||||
updates["payer_email"] = payerEmail
|
||||
}
|
||||
if monto > 0 {
|
||||
updates["monto"] = monto
|
||||
}
|
||||
if len(updates) == 0 {
|
||||
return nil
|
||||
}
|
||||
return app.Http.Database.DB.Model(&BoldWebhookLog{}).Where("id = ?", id).Updates(updates).Error
|
||||
}
|
||||
|
||||
// GetBoldWebhookLogByID carga un registro por su PK.
|
||||
func GetBoldWebhookLogByID(id uint, out *BoldWebhookLog) error {
|
||||
return app.Http.Database.DB.First(out, id).Error
|
||||
}
|
||||
|
||||
// ─── Callback log (intentos de pago) ─────────────────────────────────────────
|
||||
|
||||
// BoldCallbackLog registra cada visita a la URL de retorno de Bold.
|
||||
|
||||
Reference in New Issue
Block a user