generated from liutk/owl-admin-base
站内消息
parent
3d7646ef6a
commit
2ae9362179
|
|
@ -86,27 +86,22 @@ class ExaminationService extends BaseService
|
||||||
$employees = Employee::whereIn('id', $ids)->get();
|
$employees = Employee::whereIn('id', $ids)->get();
|
||||||
// 为员工生成考卷
|
// 为员工生成考卷
|
||||||
foreach ($employees as $employee) {
|
foreach ($employees as $employee) {
|
||||||
$examination->papers()->create([
|
$paper = $examination->papers()->create([
|
||||||
'employee_id' => $employee->id,
|
'employee_id' => $employee->id,
|
||||||
'content' => $questions,
|
'content' => $questions,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
(new MessageService())->create(
|
||||||
|
MessageType::Exam,
|
||||||
|
'考试通知',
|
||||||
|
'您有一张待完成试卷,请尽快完成考试。',
|
||||||
|
[$employee],
|
||||||
|
['paper' => ['id' => $paper->id]],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$examination->update(['exam_status' => ExamStatus::Published, 'published_at' => now()]);
|
$examination->update(['exam_status' => ExamStatus::Published, 'published_at' => now()]);
|
||||||
|
|
||||||
(new MessageService())->create(
|
|
||||||
MessageType::Exam,
|
|
||||||
'考试通知',
|
|
||||||
'您有一张待完成试卷,请尽快完成考试。',
|
|
||||||
$employees->all(),
|
|
||||||
[
|
|
||||||
'examination' => [
|
|
||||||
'id' => $examination->id,
|
|
||||||
'name' => $examination->name,
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@ namespace App\Listeners;
|
||||||
|
|
||||||
use App\Enums\MessageType;
|
use App\Enums\MessageType;
|
||||||
use App\Events\WorkflowCheckFailed;
|
use App\Events\WorkflowCheckFailed;
|
||||||
|
use App\Models\EmployeePromotion;
|
||||||
|
use App\Models\EmployeeSignRepair;
|
||||||
|
use App\Models\HolidayApply;
|
||||||
|
use App\Models\OfficalBusiness;
|
||||||
|
use App\Models\OvertimeApply;
|
||||||
|
use App\Models\Reimbursement;
|
||||||
use App\Services\MessageService;
|
use App\Services\MessageService;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
@ -29,7 +35,11 @@ class CreateWorkflowCheckFailedMessage implements ShouldQueue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($event->workflowCheck->employee)) {
|
if (is_null($employee = $event->workflowCheck->employee)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($subject = $event->workflowCheck->subject)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,8 +47,11 @@ class CreateWorkflowCheckFailedMessage implements ShouldQueue
|
||||||
MessageType::Approval,
|
MessageType::Approval,
|
||||||
'审批提醒',
|
'审批提醒',
|
||||||
"您有一条【{$subjectTypeText}】未通过审核。",
|
"您有一条【{$subjectTypeText}】未通过审核。",
|
||||||
[$event->workflowCheck->employee],
|
[$employee],
|
||||||
['workflow_check' => $event->workflowCheck],
|
[
|
||||||
|
'subject_type' => $subject->subject_type,
|
||||||
|
'subject' => $subject,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class CreateWorkflowCheckNextMessage implements ShouldQueue
|
||||||
'审批提醒',
|
'审批提醒',
|
||||||
"您有一条【{$subjectTypeText}】待审批。",
|
"您有一条【{$subjectTypeText}】待审批。",
|
||||||
$employees->all(),
|
$employees->all(),
|
||||||
['workflow_log' => $event->workflowLog],
|
['workflow_log' => $event->workflowLog->withoutRelations()],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,19 @@ class CreateWorkflowCheckSuccessMessage implements ShouldQueue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null($subject = $event->workflowCheck->subject)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->messageService->create(
|
$this->messageService->create(
|
||||||
MessageType::Approval,
|
MessageType::Approval,
|
||||||
'审批提醒',
|
'审批提醒',
|
||||||
"您有一条【{$subjectTypeText}】已通过审核。",
|
"您有一条【{$subjectTypeText}】已通过审核。",
|
||||||
[$event->workflowCheck->employee],
|
[$event->workflowCheck->employee],
|
||||||
['workflow_check' => $event->workflowCheck],
|
[
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject' => $subject,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
use Slowlyo\OwlAdmin\Admin;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
|
|
||||||
trait UploadTrait
|
trait UploadTrait
|
||||||
{
|
{
|
||||||
|
|
@ -61,7 +62,7 @@ trait UploadTrait
|
||||||
return $this->response()->fail(__('admin.upload_file_error'));
|
return $this->response()->fail(__('admin.upload_file_error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $file->store(Admin::config('admin.upload.tem_directory.'.$type).'/'.date('Y-m-d'), Admin::config('admin.upload.disk'));
|
$path = $file->storeAs(Admin::config('admin.upload.tem_directory.'.$type).'/'.date('Ymd'), $this->hashFilename($file), Admin::config('admin.upload.disk'));
|
||||||
if (request()->has('full-url')) {
|
if (request()->has('full-url')) {
|
||||||
$path = Storage::disk(Admin::config('admin.upload.disk'))->url($path);
|
$path = Storage::disk(Admin::config('admin.upload.disk'))->url($path);
|
||||||
}
|
}
|
||||||
|
|
@ -220,4 +221,19 @@ trait UploadTrait
|
||||||
return $this->response()->fail(__('admin.upload_file_error'));
|
return $this->response()->fail(__('admin.upload_file_error'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function hashFilename(UploadedFile $file): string
|
||||||
|
{
|
||||||
|
$hash = Str::random(40);
|
||||||
|
|
||||||
|
$extension = '';
|
||||||
|
|
||||||
|
if ($originalExtension = $file->getClientOriginalExtension()) {
|
||||||
|
$extension = '.'.$originalExtension;
|
||||||
|
} elseif ($guessExtension = $this->guessExtension()) {
|
||||||
|
$extension = '.'.$guessExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hash.$extension;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue