This commit is contained in:
kizzroyal
2022-03-08 17:25:21 +07:00
parent 36f6e2ee49
commit 432749674b
24 changed files with 454 additions and 146 deletions

View File

@@ -8,6 +8,8 @@ use App\Models\AttendanceSetting;
use App\Models\LichSuChoiMomo;
use App\Models\Setting;
use App\Traits\PhoneNumber;
use App\Models\DoanhThu;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Queue\Listener;
@@ -166,6 +168,7 @@ class HandleUserWinAttendanceSession extends Command
$phoneWin = $setPhoneWin;
AttendanceSetting::first()->update(['setphonewin' => null]);
}
// Log::info("end phone win");
DB::table('lich_su_choi_momos')->insert([
'sdt' => $phoneWin,
@@ -180,6 +183,20 @@ class HandleUserWinAttendanceSession extends Command
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]);
// update doanh thu ngày
$doanhThu = new DoanhThu;
$getDoanhThu = $doanhThu->whereDate('created_at', Carbon::today())->limit(1);
if ($getDoanhThu->count() > 0){
$GetLimitCron = $getDoanhThu->first();
$GetLimitCron->doanhthungay = $GetLimitCron->doanhthungay - $amount;
$GetLimitCron->save();
}else{
$doanhThu= new DoanhThu;
$doanhThu->doanhthungay = -$amount;
$doanhThu->save();
}
}
return $phoneWin;
}