havinraw
This commit is contained in:
@@ -275,29 +275,31 @@ class ShowPromociones extends Component
|
||||
//dd($tarifa);
|
||||
if ($pantalla_servicio_completa == $pantallas_tarifa) {
|
||||
|
||||
$this->fecha_final_1 = $today = Carbon::now()->addDays($tarifa->dias - 20);
|
||||
$this->fecha_final_2 = $today = Carbon::now()->addDays($tarifa->dias + 20);
|
||||
$this->fecha_final_1 = Carbon::now()->addDays($tarifa->dias - 20);
|
||||
$this->fecha_final_2 = Carbon::now()->addDays($tarifa->dias + 20);
|
||||
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->whereDate('vencimiento', '>=', $this->fecha_final_1)
|
||||
->whereDate('vencimiento', '<=', $this->fecha_final_2)
|
||||
->Orderby('inicio', 'ASC')->with('historiales')
|
||||
->orderBy('inicio', 'ASC')
|
||||
->with('historiales')
|
||||
->withCount('historiales')
|
||||
->havingRaw('COUNT(historiales.id) = 0') // ✅ Corrección
|
||||
->where('estado', 'pendiente')
|
||||
->having('historiales_count', '==', 0)
|
||||
->first();
|
||||
} else {
|
||||
$cuenta = Cuentas::where('servicio_id', $servicio_id)
|
||||
->whereDate('inicio', '>=', $this->fecha)
|
||||
->Orderby('inicio', 'ASC')
|
||||
->orderBy('inicio', 'ASC')
|
||||
->with('historiales')
|
||||
->withCount('historiales')
|
||||
->havingRaw('COUNT(historiales.id) <= ?', [(int) $faltante]) // ✅ Corrección
|
||||
->where('estado', 'activo')
|
||||
->having('historiales_count', '<=', (int) $faltante)
|
||||
->first();
|
||||
}
|
||||
|
||||
|
||||
if (!is_null($cuenta)) {
|
||||
$perfil = $cuenta->historiales_count;
|
||||
for ($y = 0; $y < (int) $pantallas_tarifa; $y++) {
|
||||
@@ -363,7 +365,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 +407,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 +417,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 +441,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