改进 工单推送
This commit is contained in:
parent
fdacec1882
commit
98dd634ea6
@ -7,6 +7,7 @@
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
// use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
@ -44,10 +45,13 @@ public function handle(): void
|
||||
|
||||
|
||||
if ($workOrder->status === 'error') {
|
||||
// 如果 created_at 超过 3 天 use Carbon
|
||||
if (now()->diffInDays($workOrder->created_at) > 3) {
|
||||
// 如果超过 3 次错误,使用 Redis
|
||||
$count = Cache::get('work_order_error_count_' . $workOrder->id, 0);
|
||||
if ($count > 3) {
|
||||
$workOrder->delete();
|
||||
continue;
|
||||
} else {
|
||||
Cache::increment('work_order_error_count_' . $workOrder->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,9 @@ protected static function boot()
|
||||
static::updated(function (self $model) {
|
||||
dispatch(new WorkOrderJob($model, 'put'));
|
||||
|
||||
$model->notify(new WorkOrderNotification($model));
|
||||
if ($model->notify) {
|
||||
$model->notify(new WorkOrderNotification($model));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,6 @@ public function toWeCom(WorkOrderModel $workOrder): false|array
|
||||
|
||||
$module = $workOrder->module;
|
||||
|
||||
if ($workOrder->notify === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 取消隐藏字段
|
||||
$module->makeVisible(['wecom_key']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user