generated from liutk/owl-admin-base
console app:employee-sign
parent
6705f1b516
commit
3ee46efb5d
|
|
@ -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();
|
$start = $date->copy()->startOfDay();
|
||||||
$end = $date->copy()->endOfDay();
|
$end = $date->copy()->endOfDay();
|
||||||
// 打卡日志
|
// 打卡日志
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||||
use App\Admin\Services\EmployeeSignService;
|
use App\Admin\Services\EmployeeSignService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class EmployeeSign extends Command
|
class EmployeeSign extends Command
|
||||||
{
|
{
|
||||||
|
|
@ -13,7 +14,7 @@ class EmployeeSign extends Command
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'app:employee-sign';
|
protected $signature = 'app:employee-sign {--date=}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
|
|
@ -29,7 +30,11 @@ class EmployeeSign extends Command
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
EmployeeSignService::make()->signResult();
|
$date = $this->option('date');
|
||||||
|
if ($date) {
|
||||||
|
$date = Carbon::createFromFormat('Y-m-d', $date);
|
||||||
|
}
|
||||||
|
EmployeeSignService::make()->signResult($date);
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue