update
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||
use App\Models\Historial_cuenta;
|
||||
use App\Models\Historiale;
|
||||
use App\Models\Log_general;
|
||||
use App\Models\RegistroCompra;
|
||||
use App\Models\Saldo;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
@@ -40,7 +41,6 @@ class validacionCompra extends Command
|
||||
//$hora_antes = Carbon::now()->subHours(100)->format('Y-m-d H:i:s'); // 24 horas antes
|
||||
$hora_antes = Carbon::now()->subMinutes(10)->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
$this->validarSaldosNegativos($hora_antes, $fecha_ahora);
|
||||
|
||||
$resultados = Historiale::select('vendedor_id')
|
||||
@@ -66,7 +66,16 @@ class validacionCompra extends Command
|
||||
|
||||
$diferencia = Carbon::parse($anterior->created_at)->diffInSeconds(Carbon::parse($registro->created_at));
|
||||
|
||||
if ($diferencia < 10) {
|
||||
$segundos_antes_anterior = Carbon::parse($anterior->created_at)->subSeconds(10);
|
||||
$segundos_antes_registro = Carbon::parse($registro->created_at)->subSeconds(10);
|
||||
|
||||
|
||||
|
||||
$validaranterior = RegistroCompra::where('user_id', $anterior->vendedor_id)->whereBetween('created_at', [$segundos_antes_anterior, $anterior->created_at])->exists();
|
||||
$validarregistro = RegistroCompra::where('user_id', $registro->vendedor_id)->whereBetween('created_at', [$segundos_antes_registro, $registro->created_at])->exists();
|
||||
|
||||
if ($diferencia < 10 && !$validaranterior && !$validarregistro ) {
|
||||
|
||||
//echo "Diferencia: {$diferencia} segundos<br>Vendedor ID: {$anterior->nombre_cliente}- {$anterior->created_at} - {$registro->created_at}<br><br>";
|
||||
$validar_actual = Log_general::where('historial_id', $registro->id)
|
||||
->where('tipo', 'compra')
|
||||
@@ -105,7 +114,7 @@ class validacionCompra extends Command
|
||||
'tipo' => 'corregido',
|
||||
'detalle' => 'Se ha corregido la compra duplicada, usuario: ' . $email . ' - ' .
|
||||
Carbon::parse($registro->created_at)->format('d M Y h:i A') . ' - ' .
|
||||
Carbon::parse($anterior->created_at)->format('d M Y h:i A') . ' - Saldo retornado:' . $registro->valor .'- Saldo actual: '.$vendedor->saldo->valor,
|
||||
Carbon::parse($anterior->created_at)->format('d M Y h:i A') . ' - Saldo retornado:' . $registro->valor . '- Saldo actual: ' . $vendedor->saldo->valor,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -158,8 +167,8 @@ class validacionCompra extends Command
|
||||
// Devolver saldo
|
||||
$nuevo_saldo = $actualizar_saldo->saldo->valor + $historial_actual->valor;
|
||||
Saldo::where('usuario_id', $usuario_anterior)->update(['valor' => $nuevo_saldo]);
|
||||
|
||||
|
||||
|
||||
|
||||
// Cancelar historial actual
|
||||
$historial_actual->estado = 'cancelado';
|
||||
$historial_actual->save();
|
||||
|
||||
Reference in New Issue
Block a user