console app:employee-sign

main
panliang 2024-05-11 15:17:01 +08:00
parent 6705f1b516
commit 3ee46efb5d
2 changed files with 9 additions and 4 deletions

View File

@ -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();
// 打卡日志

View File

@ -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();