perf: 任务时间修改提醒

This commit is contained in:
kuaifan 2023-01-30 18:08:30 +08:00
parent ffafe82e43
commit fd22cd3265
5 changed files with 33 additions and 52 deletions

View File

@ -767,9 +767,7 @@ class ProjectTask extends AbstractModel
$this->addLog("修改{任务}时间" . ($desc ? "(备注:{$desc}" : ""), [
'change' => [$oldStringAt, $newStringAt]
]);
// 修改计划时间需要重置任务邮件提醒日志
ProjectTaskMailLog::whereTaskId($this->id)->delete();
$this->taskPush(null, 3);
}
// 以下紧顶级任务可修改
if ($this->parent_id === 0) {
@ -1435,7 +1433,7 @@ class ProjectTask extends AbstractModel
/**
* 任务提醒
* @param $userids
* @param int $type 0-新任务、1-即将超时、2-已超时
* @param int $type 0-新任务、1-即将超时、2-已超时、3-修改时间
* @return void
*/
public function taskPush($userids, int $type)
@ -1457,7 +1455,7 @@ class ProjectTask extends AbstractModel
}
$text = view('push.task', [
'type' => str_replace([0, 1, 2], ['start', 'before', 'after'], $type),
'type' => str_replace([0, 1, 2, 3], ['start', 'before', 'after', 'times'], $type),
'task' => $this,
])->render();

View File

@ -1,45 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* App\Models\ProjectTaskMailLog
*
* @property int $id
* @property int|null $userid 用户id
* @property int|null $task_id 任务id
* @property string|null $email 电子邮箱
* @property int|null $type 提醒类型0 任务开始提醒1 距离到期提醒2到期超时提醒
* @property int|null $is_send 邮件发送是否成功0否1是
* @property string|null $send_error 邮件发送错误详情
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog newQuery()
* @method static \Illuminate\Database\Query\Builder|ProjectTaskMailLog onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog query()
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereIsSend($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereSendError($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereTaskId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ProjectTaskMailLog whereUserid($value)
* @method static \Illuminate\Database\Query\Builder|ProjectTaskMailLog withTrashed()
* @method static \Illuminate\Database\Query\Builder|ProjectTaskMailLog withoutTrashed()
* @mixin \Eloquent
*/
class ProjectTaskMailLog extends AbstractModel
{
use SoftDeletes;
}

View File

@ -2,8 +2,6 @@
namespace App\Tasks;
use App\Models\ProjectTask;
use App\Models\ProjectTaskMailLog;
use App\Models\Setting;
use App\Models\User;
use App\Models\WebSocketDialogMsg;

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DeleteProjectTaskMailLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('project_task_mail_logs');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// 删除表无法恢复
}
}

View File

@ -2,6 +2,8 @@
您的任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span> 即将超时,请及时处理。
@elseif ($type === 'after')
您的任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span> 已经超时,请及时处理。
@elseif ($type === 'times')
您的任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span> 时间已修改,请注意查看。
@else
您有一个新任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span>。
@endif