cambio real
This commit is contained in:
@@ -278,7 +278,7 @@ class ShowPromociones extends Component
|
||||
$this->fecha_final_1 = $today = Carbon::now()->addDays($tarifa->dias - 20);
|
||||
$this->fecha_final_2 = $today = Carbon::now()->addDays($tarifa->dias + 20);
|
||||
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
/* $cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||
@@ -286,16 +286,52 @@ class ShowPromociones extends Component
|
||||
->withCount('historiales')
|
||||
->where('estado', 'pendiente')
|
||||
->having('historiales_count', '==', 0)
|
||||
->first();
|
||||
} else {
|
||||
->first(); */
|
||||
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->Orderby('inicio', 'ASC')
|
||||
->with('historiales')
|
||||
->withCount('historiales')
|
||||
->where('estado', 'activo')
|
||||
->having('historiales_count', '<=', (int) $faltante)
|
||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||
->where('estado', 'pendiente')
|
||||
->orderBy('inicio', 'ASC')
|
||||
->with('historiales') // Relación de historiales
|
||||
->withCount('historiales') // Contar historiales
|
||||
->first();
|
||||
|
||||
if ($cuenta) {
|
||||
// Filtrar la cuenta si tiene 0 historiales
|
||||
if ($cuenta->historiales_count != 0) {
|
||||
$cuenta = null; // Si
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
/* $cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->Orderby('inicio', 'ASC')
|
||||
->with('historiales')
|
||||
->withCount('historiales')
|
||||
->where('estado', 'activo')
|
||||
->having('historiales_count', '<=', (int) $faltante)
|
||||
->first(); */
|
||||
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->where('estado', 'activo')
|
||||
->orderBy('inicio', 'ASC')
|
||||
->with('historiales') // Relación de historiales
|
||||
->withCount('historiales') // Contar historiales
|
||||
->first();
|
||||
|
||||
if ($cuenta && $cuenta->historiales_count <= (int) $faltante) {
|
||||
// La cuenta cumple con el filtro, puedes usarla.
|
||||
} else {
|
||||
// La cuenta no cumple con el filtro, la descartas o manejas según sea necesario.
|
||||
$cuenta = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!is_null($cuenta)) {
|
||||
@@ -363,7 +399,7 @@ class ShowPromociones extends Component
|
||||
|
||||
$logsGeneral = new Log_general();
|
||||
$logsGeneral->user_id = Auth::user()->id;
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha comprado la promocion ' . $this->consulta->nombre . ' - ' . $this->consulta->descripcion . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor .', Saldo anterior: $'.$saldo_anterior.', Nuevo saldo disponible: $'.$nuevo_saldo;
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha comprado la promocion ' . $this->consulta->nombre . ' - ' . $this->consulta->descripcion . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor . ', Saldo anterior: $' . $saldo_anterior . ', Nuevo saldo disponible: $' . $nuevo_saldo;
|
||||
$logsGeneral->tipo = 'compra';
|
||||
$logsGeneral->historial_id = $historial->id;
|
||||
$logsGeneral->save();
|
||||
@@ -405,7 +441,7 @@ class ShowPromociones extends Component
|
||||
|
||||
$logsGeneral = new Log_general();
|
||||
$logsGeneral->user_id = Auth::user()->id;
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha comprado la promocion ' . $this->consulta->nombre . ' - ' . $this->consulta->descripcion . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor ?? '' . ' y algunos han quedado pendientes'.', Saldo anterior: $'.$saldo_anterior.', Nuevo saldo disponible: $'.$nuevo_saldo;
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha comprado la promocion ' . $this->consulta->nombre . ' - ' . $this->consulta->descripcion . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor ?? '' . ' y algunos han quedado pendientes' . ', Saldo anterior: $' . $saldo_anterior . ', Nuevo saldo disponible: $' . $nuevo_saldo;
|
||||
$logsGeneral->tipo = 'compra';
|
||||
$logsGeneral->historial_id = $this->historial->id;
|
||||
$logsGeneral->save();
|
||||
@@ -415,9 +451,9 @@ class ShowPromociones extends Component
|
||||
Historial_cuenta::whereIn('id', $this->n)->delete();
|
||||
$logsGeneral = new Log_general();
|
||||
$logsGeneral->user_id = Auth::user()->id;
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Tuvo error en el cobro, Comprando la promoción ' . $this->consulta->nombre . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor .' No se desconto el saldo, ni se asignaron cuentas.';
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Tuvo error en el cobro, Comprando la promoción ' . $this->consulta->nombre . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor . ' No se desconto el saldo, ni se asignaron cuentas.';
|
||||
$logsGeneral->tipo = 'compra_error';
|
||||
$logsGeneral->historial_id = $this->historial->id;
|
||||
$logsGeneral->historial_id = $this->historial->id;
|
||||
$logsGeneral->save();
|
||||
$this->alert('warning', 'Error en el cobro, comuniquese con soporte!', [
|
||||
'position' => 'top'
|
||||
@@ -439,7 +475,7 @@ class ShowPromociones extends Component
|
||||
Historial_cuenta::whereIn('id', $this->n)->delete();
|
||||
$logsGeneral = new Log_general();
|
||||
$logsGeneral->user_id = Auth::user()->id;
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Cancelo la compra del plan ' . $this->consulta->nombre . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor.' No se desconto el saldo, ni se asignaron cuentas.';
|
||||
$logsGeneral->detalle = 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' Cancelo la compra del plan ' . $this->consulta->nombre . ' cantidad de ' . $this->historial->cantidad . ' por un valor de $' . $this->historial->valor . ' No se desconto el saldo, ni se asignaron cuentas.';
|
||||
$logsGeneral->tipo = 'compra_cancelada';
|
||||
$logsGeneral->historial_id = $this->historial->id;
|
||||
$logsGeneral->save();
|
||||
|
||||
Reference in New Issue
Block a user