store-manage/app/Console/Commands/EmployeeSign.php

46 lines
1.0 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Admin\Services\EmployeeSignService;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class EmployeeSign extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:employee-sign {--date=}';
/**
* The console command description.
*
* @var string
*/
protected $description = '员工签到情况统计';
/**
* Execute the console command.
*/
public function handle()
{
try {
DB::beginTransaction();
$date = $this->option('date');
if ($date) {
$date = Carbon::createFromFormat('Y-m-d', $date);
}
EmployeeSignService::make()->signResult($date);
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
logger('app:employee-sign error');
logger()->error($e);
}
}
}