diff --git a/app/Admin/Services/EmployeeSignService.php b/app/Admin/Services/EmployeeSignService.php index 91b7bb9..1ad8bf0 100644 --- a/app/Admin/Services/EmployeeSignService.php +++ b/app/Admin/Services/EmployeeSignService.php @@ -31,9 +31,9 @@ class EmployeeSignService extends BaseService /** * 整理昨天的打卡流水, 生成对应的打卡记录 */ - public function signResult() + public function signResult(Carbon $date = null) { - $date = now()->subDay(); + $date = $date ?: now()->subDay(); $start = $date->copy()->startOfDay(); $end = $date->copy()->endOfDay(); // 打卡日志 diff --git a/app/Console/Commands/EmployeeSign.php b/app/Console/Commands/EmployeeSign.php index 55ed41a..10c07b2 100644 --- a/app/Console/Commands/EmployeeSign.php +++ b/app/Console/Commands/EmployeeSign.php @@ -5,6 +5,7 @@ namespace App\Console\Commands; use App\Admin\Services\EmployeeSignService; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; +use Carbon\Carbon; class EmployeeSign extends Command { @@ -13,7 +14,7 @@ class EmployeeSign extends Command * * @var string */ - protected $signature = 'app:employee-sign'; + protected $signature = 'app:employee-sign {--date=}'; /** * The console command description. @@ -29,7 +30,11 @@ class EmployeeSign extends Command { try { DB::beginTransaction(); - EmployeeSignService::make()->signResult(); + $date = $this->option('date'); + if ($date) { + $date = Carbon::createFromFormat('Y-m-d', $date); + } + EmployeeSignService::make()->signResult($date); DB::commit(); } catch (\Exception $e) { DB::rollBack();