main
Jing Li 2024-05-01 11:30:01 +08:00
parent cce8b118c1
commit 498a2df89d
1 changed files with 4 additions and 8 deletions

View File

@ -27,7 +27,7 @@ class EmployeeService extends BaseService
$validate = $this->validate($data);
if ($validate !== true) {
$this->setError($validate);
return false;
}
// 添加管理员信息
@ -87,13 +87,8 @@ class EmployeeService extends BaseService
/**
* 员工离职/还原
*
* @param Employee $user
* @param array $options {leave_at: 离职时间}
*
* @return boolean
*/
public function leave(Employee $user, $options = [])
public function leave(Employee $user, $options = []): bool
{
if ($user->employee_status == EmployeeStatus::Online) {
// 店长不能离职
@ -101,11 +96,12 @@ class EmployeeService extends BaseService
return $this->setError('请先设置新店长');
}
$user->update([
'leave_at' => data_get($options, 'leave_at', now()),
'leave_at' => $options['leave_at'] ?? now(),
'employee_status' => EmployeeStatus::Offline,
]);
} else {
$user->update([
'join_at' => now(),
'leave_at' => null,
'employee_status' => EmployeeStatus::Online,
]);