改进 更优雅的目录格式
This commit is contained in:
parent
43d02ca500
commit
96961d2a55
@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
use App\Jobs\AutoCloseWorkOrderJob;
|
use App\Jobs\Host\DeleteHostJob;
|
||||||
use App\Jobs\CheckAndChargeBalanceJob;
|
use App\Jobs\Host\HostCostJob;
|
||||||
use App\Jobs\ClearTasksJob;
|
|
||||||
use App\Jobs\DeleteHostJob;
|
|
||||||
use App\Jobs\Host\ScanAllHostsJob;
|
use App\Jobs\Host\ScanAllHostsJob;
|
||||||
use App\Jobs\HostCostJob;
|
|
||||||
use App\Jobs\Module\FetchModuleJob;
|
use App\Jobs\Module\FetchModuleJob;
|
||||||
use App\Jobs\Module\PushWorkOrderJob;
|
use App\Jobs\Module\SendModuleEarningsJob;
|
||||||
use App\Jobs\RollbackUserTempGroupJob;
|
use App\Jobs\User\CheckAndChargeBalanceJob;
|
||||||
use App\Jobs\SendModuleEarningsJob;
|
use App\Jobs\User\ClearTasksJob;
|
||||||
use App\Jobs\SetBirthdayGroupJob;
|
use App\Jobs\User\RollbackUserTempGroupJob;
|
||||||
|
use App\Jobs\User\SetBirthdayGroupJob;
|
||||||
|
use App\Jobs\WorkOrder\AutoCloseWorkOrderJob;
|
||||||
|
use App\Jobs\WorkOrder\PushWorkOrderJob;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\Host;
|
||||||
|
|
||||||
use App\Models\Host;
|
use App\Models\Host;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
@ -34,14 +34,14 @@ public function handle(): void
|
|||||||
// 查找暂停时间超过 3 天的 host
|
// 查找暂停时间超过 3 天的 host
|
||||||
(new Host)->where('status', 'suspended')->where('suspended_at', '<', now()->subDays(3))->chunk(100, function ($hosts) {
|
(new Host)->where('status', 'suspended')->where('suspended_at', '<', now()->subDays(3))->chunk(100, function ($hosts) {
|
||||||
foreach ($hosts as $host) {
|
foreach ($hosts as $host) {
|
||||||
dispatch(new Module\HostJob($host, 'delete'));
|
dispatch(new HostJob($host, 'delete'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查找部署时间超过3天以上的 host
|
// 查找部署时间超过3天以上的 host
|
||||||
(new Host)->where('status', 'pending')->where('created_at', '<', now()->subDays(3))->chunk(100, function ($hosts) {
|
(new Host)->where('status', 'pending')->where('created_at', '<', now()->subDays(3))->chunk(100, function ($hosts) {
|
||||||
foreach ($hosts as $host) {
|
foreach ($hosts as $host) {
|
||||||
dispatch(new Module\HostJob($host, 'delete'));
|
dispatch(new HostJob($host, 'delete'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\Host;
|
||||||
|
|
||||||
use App\Helpers\Lock;
|
use App\Helpers\Lock;
|
||||||
use App\Models\Host;
|
use App\Models\Host;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs\Module;
|
namespace App\Jobs\Host;
|
||||||
|
|
||||||
use App\Models\Host as HostModel;
|
use App\Models\Host as HostModel;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs\Module;
|
namespace App\Jobs\Host;
|
||||||
|
|
||||||
use App\Models\Host;
|
use App\Models\Host;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\Module;
|
||||||
|
|
||||||
|
use App\Jobs\Job;
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use App\Notifications\ModuleEarnings;
|
use App\Notifications\Modules\ModuleEarnings;
|
||||||
|
|
||||||
class SendModuleEarningsJob extends Job
|
class SendModuleEarningsJob extends Job
|
||||||
{
|
{
|
@ -1,15 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\User;
|
||||||
|
|
||||||
|
use App\Jobs\Job;
|
||||||
use App\Models\Balance;
|
use App\Models\Balance;
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Yansongda\LaravelPay\Facades\Pay;
|
use Yansongda\LaravelPay\Facades\Pay;
|
||||||
use Yansongda\Pay\Exception\ContainerException;
|
use Yansongda\Pay\Exception\ContainerException;
|
||||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||||
use Yansongda\Pay\Exception\ServiceNotFoundException;
|
use Yansongda\Pay\Exception\ServiceNotFoundException;
|
||||||
|
|
||||||
class CheckAndChargeBalanceJob extends Job
|
class CheckAndChargeBalanceJob extends Job implements ShouldQueue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\User;
|
||||||
|
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\User;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\User;
|
||||||
|
|
||||||
use App\Http\Controllers\Admin\NotificationController;
|
use App\Http\Controllers\Admin\NotificationController;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\Common;
|
use App\Notifications\User\UserNotification;
|
||||||
use GeneaLabs\LaravelModelCaching\CachedBuilder;
|
use GeneaLabs\LaravelModelCaching\CachedBuilder;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
@ -12,24 +12,26 @@
|
|||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class SendCommonNotificationsJob implements ShouldQueue
|
class SendUserNotificationsJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected array $requests;
|
protected array $requests;
|
||||||
protected User|CachedBuilder $users;
|
protected User|CachedBuilder $users;
|
||||||
protected string $title, $content;
|
protected string $title, $content;
|
||||||
|
protected bool $send_mail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(array $requests, $title, $content)
|
public function __construct(array $requests, $title, $content, $send_mail = false)
|
||||||
{
|
{
|
||||||
$this->requests = $requests;
|
$this->requests = $requests;
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
|
$this->send_mail = $send_mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,8 +41,6 @@ public function __construct(array $requests, $title, $content)
|
|||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
|
||||||
$notificationController = new NotificationController();
|
$notificationController = new NotificationController();
|
||||||
|
|
||||||
$users = $notificationController->query($this->requests);
|
$users = $notificationController->query($this->requests);
|
||||||
@ -48,7 +48,7 @@ public function handle(): void
|
|||||||
// chunk
|
// chunk
|
||||||
$users->chunk(100, function ($users) {
|
$users->chunk(100, function ($users) {
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$user->notify(new Common($this->title, $this->content));
|
$user->notify(new UserNotification($this->title, $this->content, $this->send_mail));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\User;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserGroup;
|
use App\Models\UserGroup;
|
||||||
use App\Notifications\TodayIsUserBirthday;
|
use App\Notifications\User\TodayIsUserBirthday;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs\WorkOrder;
|
||||||
|
|
||||||
|
use App\Jobs\Job;
|
||||||
use App\Models\WorkOrder\WorkOrder;
|
use App\Models\WorkOrder\WorkOrder;
|
||||||
|
|
||||||
class AutoCloseWorkOrderJob extends Job
|
class AutoCloseWorkOrderJob extends Job
|
@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs\Module;
|
namespace App\Jobs\WorkOrder;
|
||||||
|
|
||||||
use App\Jobs\Module\WorkOrder\Reply;
|
|
||||||
use App\Models\WorkOrder\WorkOrder;
|
use App\Models\WorkOrder\WorkOrder;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs\Module\WorkOrder;
|
namespace App\Jobs\WorkOrder;
|
||||||
|
|
||||||
use App\Models\WorkOrder\Reply as WorkOrderReply;
|
use App\Models\WorkOrder\Reply as WorkOrderReply;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Jobs\Module\WorkOrder;
|
namespace App\Jobs\WorkOrder;
|
||||||
|
|
||||||
use App\Models\WorkOrder\WorkOrder as WorkOrderModel;
|
use App\Models\WorkOrder\WorkOrder as WorkOrderModel;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications\Channels;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications\Channels;
|
||||||
|
|
||||||
|
use App\Console\Commands\Cluster\Log;
|
||||||
use App\Events\Users;
|
use App\Events\Users;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
@ -31,10 +32,6 @@ public function send(mixed $notifiable, Notification $notification): void
|
|||||||
|
|
||||||
$user = User::find($user_id);
|
$user = User::find($user_id);
|
||||||
|
|
||||||
if (!in_array($data['type'] ?? '', ['info', 'success', 'warning', 'error'])) {
|
broadcast(new Users($user, $data['event'], $data));
|
||||||
$data['type'] = 'info';
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcast(new Users($user, $data['type'], $data));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications\Modules;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications\User;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications\User;
|
||||||
|
|
||||||
use App\Models\Balance;
|
use App\Models\Balance;
|
||||||
|
use App\Notifications\Channels\WeComChannel;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Notifications;
|
namespace App\Notifications\WorkOrder;
|
||||||
|
|
||||||
use App\Models\WorkOrder\WorkOrder as WorkOrderModel;
|
use App\Models\WorkOrder\WorkOrder as WorkOrderModel;
|
||||||
|
use App\Notifications\Channels\WebChannel;
|
||||||
|
use App\Notifications\Channels\WeComChannel;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
Loading…
Reference in New Issue
Block a user