使用 Pint 格式化代码
This commit is contained in:
parent
1081455c23
commit
835b4fc7ab
@ -29,7 +29,6 @@ class All extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
|
||||||
$admins = Admin::all();
|
$admins = Admin::all();
|
||||||
|
|
||||||
$this->table(['ID', '邮箱'], $admins->map(function ($admin) {
|
$this->table(['ID', '邮箱'], $admins->map(function ($admin) {
|
||||||
|
@ -29,11 +29,9 @@ class Create extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
|
||||||
// 邮箱
|
// 邮箱
|
||||||
$email = $this->ask('请输入邮箱');
|
$email = $this->ask('请输入邮箱');
|
||||||
|
|
||||||
|
|
||||||
// 密码
|
// 密码
|
||||||
$password = $this->secret('请输入密码');
|
$password = $this->secret('请输入密码');
|
||||||
// 确认密码
|
// 确认密码
|
||||||
@ -42,13 +40,14 @@ public function handle(): int
|
|||||||
// 验证密码
|
// 验证密码
|
||||||
if ($password !== $password_confirmation) {
|
if ($password !== $password_confirmation) {
|
||||||
$this->error('两次输入的密码不一致。');
|
$this->error('两次输入的密码不一致。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建管理员
|
// 创建管理员
|
||||||
$admin = (new Admin)->create([
|
$admin = (new Admin)->create([
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'password' => bcrypt($password)
|
'password' => bcrypt($password),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 输出信息
|
// 输出信息
|
||||||
|
@ -37,6 +37,7 @@ public function handle(): int
|
|||||||
|
|
||||||
// 输出信息
|
// 输出信息
|
||||||
$this->info('管理员删除成功。');
|
$this->info('管理员删除成功。');
|
||||||
|
|
||||||
return CommandAlias::SUCCESS;
|
return CommandAlias::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ class Reset extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
|
||||||
// 获取管理员ID
|
// 获取管理员ID
|
||||||
$id = $this->ask('请输入管理员ID');
|
$id = $this->ask('请输入管理员ID');
|
||||||
|
|
||||||
@ -39,6 +38,7 @@ public function handle(): int
|
|||||||
// 验证管理员
|
// 验证管理员
|
||||||
if (is_null($admin)) {
|
if (is_null($admin)) {
|
||||||
$this->error('管理员不存在。');
|
$this->error('管理员不存在。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ public function handle(): int
|
|||||||
$this->warn('开始计算集成模块收益。');
|
$this->warn('开始计算集成模块收益。');
|
||||||
$this->warn('当前时间: '.now());
|
$this->warn('当前时间: '.now());
|
||||||
|
|
||||||
|
|
||||||
(new Module)->chunk(100, function ($modules) {
|
(new Module)->chunk(100, function ($modules) {
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$this->warn('模块: '.$module->name);
|
$this->warn('模块: '.$module->name);
|
||||||
|
@ -34,6 +34,7 @@ public function handle(): int
|
|||||||
|
|
||||||
if (! in_array($service, ['web', 'all'])) {
|
if (! in_array($service, ['web', 'all'])) {
|
||||||
$this->error('service 参数错误,只能是 web 或 all。');
|
$this->error('service 参数错误,只能是 web 或 all。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,33 +37,32 @@ public function handle(): int
|
|||||||
$node_type = config('settings.node.type');
|
$node_type = config('settings.node.type');
|
||||||
|
|
||||||
if ($node_type === 'master') {
|
if ($node_type === 'master') {
|
||||||
|
|
||||||
// if force is true, delete the old file
|
// if force is true, delete the old file
|
||||||
if ($this->option('force') === 'true') {
|
if ($this->option('force') === 'true') {
|
||||||
$confirm = 'yes';
|
$confirm = 'yes';
|
||||||
} else {
|
} else {
|
||||||
$confirm = $this->ask('主节点同步将会恢复上一次数据,确定吗?', true);
|
$confirm = $this->ask('主节点同步将会恢复上一次数据,确定吗?', true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! $confirm) {
|
if (! $confirm) {
|
||||||
$this->warn('已取消。');
|
$this->warn('已取消。');
|
||||||
|
|
||||||
return CommandAlias::SUCCESS;
|
return CommandAlias::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache_key = "master_config_zip";
|
$cache_key = 'master_config_zip';
|
||||||
$config = ClusterSupport::get($cache_key);
|
$config = ClusterSupport::get($cache_key);
|
||||||
|
|
||||||
if ($config) {
|
if ($config) {
|
||||||
$this->info('检查下载目录的 MD5 值。');
|
$this->info('检查下载目录的 MD5 值。');
|
||||||
$config_md5_key = "master_config_zip_md5";
|
$config_md5_key = 'master_config_zip_md5';
|
||||||
$config_md5 = ClusterSupport::get($config_md5_key, '');
|
$config_md5 = ClusterSupport::get($config_md5_key, '');
|
||||||
|
|
||||||
$md5 = md5($config);
|
$md5 = md5($config);
|
||||||
if ($md5 !== $config_md5) {
|
if ($md5 !== $config_md5) {
|
||||||
$this->error('下载目录 MD5 值被篡改。请尝试从其他节点重新同步。');
|
$this->error('下载目录 MD5 值被篡改。请尝试从其他节点重新同步。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +83,6 @@ public function handle(): int
|
|||||||
$cmd = "rm -rf $cache_path";
|
$cmd = "rm -rf $cache_path";
|
||||||
exec($cmd);
|
exec($cmd);
|
||||||
|
|
||||||
|
|
||||||
$this->info('正在解压缩。');
|
$this->info('正在解压缩。');
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
$zip->open($path);
|
$zip->open($path);
|
||||||
@ -103,6 +101,7 @@ public function handle(): int
|
|||||||
$this->info('检查 .env 文件的 MD5 值。');
|
$this->info('检查 .env 文件的 MD5 值。');
|
||||||
if (md5($env) !== $env_md5) {
|
if (md5($env) !== $env_md5) {
|
||||||
$this->error('.env 文件 MD5 值被篡改。请尝试从其他节点重新同步。');
|
$this->error('.env 文件 MD5 值被篡改。请尝试从其他节点重新同步。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
} else {
|
} else {
|
||||||
$this->info('正在写入 .env 文件。');
|
$this->info('正在写入 .env 文件。');
|
||||||
@ -121,9 +120,7 @@ public function handle(): int
|
|||||||
$env = preg_replace('/^NODE_IP=.*$/m', "NODE_IP=$node_ip", $env);
|
$env = preg_replace('/^NODE_IP=.*$/m', "NODE_IP=$node_ip", $env);
|
||||||
|
|
||||||
file_put_contents(base_path('.env'), $env);
|
file_put_contents(base_path('.env'), $env);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info('正在清理。');
|
$this->info('正在清理。');
|
||||||
@ -139,10 +136,10 @@ public function handle(): int
|
|||||||
ClusterSupport::publish('synced');
|
ClusterSupport::publish('synced');
|
||||||
} else {
|
} else {
|
||||||
$this->error('没有找到缓存。请尝试从其他节点重新同步。');
|
$this->error('没有找到缓存。请尝试从其他节点重新同步。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return CommandAlias::SUCCESS;
|
return CommandAlias::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,30 +110,27 @@ public function upload($node_type)
|
|||||||
unlink($cacheZip);
|
unlink($cacheZip);
|
||||||
|
|
||||||
// 上传 config/secrets/ssl_fullchain.pem 和 config/secrets/ssl_privkey.pem
|
// 上传 config/secrets/ssl_fullchain.pem 和 config/secrets/ssl_privkey.pem
|
||||||
$ssl_fullchain_key = "config/secrets/ssl_fullchain.pem";
|
$ssl_fullchain_key = 'config/secrets/ssl_fullchain.pem';
|
||||||
$ssl_privkey_key = "config/secrets/ssl_privkey.pem";
|
$ssl_privkey_key = 'config/secrets/ssl_privkey.pem';
|
||||||
|
|
||||||
if (file_exists(base_path($ssl_fullchain_key)) && file_exists(base_path($ssl_privkey_key))) {
|
if (file_exists(base_path($ssl_fullchain_key)) && file_exists(base_path($ssl_privkey_key))) {
|
||||||
|
|
||||||
$this->info('正在上传 SSL 证书。');
|
$this->info('正在上传 SSL 证书。');
|
||||||
|
|
||||||
ClusterSupport::forever("ssl_fullchain", file_get_contents(base_path($ssl_fullchain_key)));
|
ClusterSupport::forever('ssl_fullchain', file_get_contents(base_path($ssl_fullchain_key)));
|
||||||
ClusterSupport::forever("ssl_privkey", file_get_contents(base_path($ssl_privkey_key)));
|
ClusterSupport::forever('ssl_privkey', file_get_contents(base_path($ssl_privkey_key)));
|
||||||
|
|
||||||
// 计算 md5
|
// 计算 md5
|
||||||
$ssl_fullchain_md5 = md5_file(base_path($ssl_fullchain_key));
|
$ssl_fullchain_md5 = md5_file(base_path($ssl_fullchain_key));
|
||||||
$ssl_privkey_md5 = md5_file(base_path($ssl_privkey_key));
|
$ssl_privkey_md5 = md5_file(base_path($ssl_privkey_key));
|
||||||
|
|
||||||
$this->info('正在报告 SSL 证书的 MD5 值。');
|
$this->info('正在报告 SSL 证书的 MD5 值。');
|
||||||
ClusterSupport::forever("ssl_fullchain_md5", $ssl_fullchain_md5);
|
ClusterSupport::forever('ssl_fullchain_md5', $ssl_fullchain_md5);
|
||||||
ClusterSupport::forever("ssl_privkey_md5", $ssl_privkey_md5);
|
ClusterSupport::forever('ssl_privkey_md5', $ssl_privkey_md5);
|
||||||
|
|
||||||
ClusterSupport::publish('config.ssl.updated');
|
ClusterSupport::publish('config.ssl.updated');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->warn('SSL 证书不存在,跳过。');
|
$this->warn('SSL 证书不存在,跳过。');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传 .env 文件
|
// 上传 .env 文件
|
||||||
|
@ -31,7 +31,6 @@ class Work extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
|
||||||
// 检测目录下是否有 rr
|
// 检测目录下是否有 rr
|
||||||
if (! file_exists(base_path('rr'))) {
|
if (! file_exists(base_path('rr'))) {
|
||||||
$this->warn('未找到 rr 文件,将自动下载。');
|
$this->warn('未找到 rr 文件,将自动下载。');
|
||||||
@ -65,7 +64,7 @@ public function handle(): int
|
|||||||
exec("rm -rf roadrunner-$version-$os-$arch");
|
exec("rm -rf roadrunner-$version-$os-$arch");
|
||||||
|
|
||||||
// 设置 rr 可执行权限
|
// 设置 rr 可执行权限
|
||||||
exec("chmod +x rr");
|
exec('chmod +x rr');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭 Octane
|
// 关闭 Octane
|
||||||
@ -73,6 +72,7 @@ public function handle(): int
|
|||||||
|
|
||||||
if (! config('settings.node.ip')) {
|
if (! config('settings.node.ip')) {
|
||||||
$this->error('请先配置节点 IP。');
|
$this->error('请先配置节点 IP。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,12 +92,14 @@ public function handle(): int
|
|||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
if ($pid === -1) {
|
if ($pid === -1) {
|
||||||
$this->error('无法创建子进程。');
|
$this->error('无法创建子进程。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
} elseif ($pid === 0) {
|
} elseif ($pid === 0) {
|
||||||
// 再打开一个,负责 octane
|
// 再打开一个,负责 octane
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
if ($pid === -1) {
|
if ($pid === -1) {
|
||||||
$this->error('无法创建子进程。');
|
$this->error('无法创建子进程。');
|
||||||
|
|
||||||
return CommandAlias::FAILURE;
|
return CommandAlias::FAILURE;
|
||||||
} elseif ($pid === 0) {
|
} elseif ($pid === 0) {
|
||||||
// 子进程
|
// 子进程
|
||||||
@ -105,17 +107,14 @@ public function handle(): int
|
|||||||
|
|
||||||
$command = 'php artisan octane:start --host=0.0.0.0 --rpc-port=6001 --port=8000';
|
$command = 'php artisan octane:start --host=0.0.0.0 --rpc-port=6001 --port=8000';
|
||||||
$this->pipeCommand($command);
|
$this->pipeCommand($command);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->report();
|
$this->report();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 父进程
|
// 父进程
|
||||||
$this->work();
|
$this->work();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return CommandAlias::SUCCESS;
|
return CommandAlias::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +145,6 @@ private function pipeCommand($command): void
|
|||||||
// 关闭进程
|
// 关闭进程
|
||||||
|
|
||||||
proc_close($process);
|
proc_close($process);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function report(): void
|
private function report(): void
|
||||||
@ -170,6 +168,7 @@ private function getCpuUsage(): float
|
|||||||
{
|
{
|
||||||
// 获取 CPU 使用率
|
// 获取 CPU 使用率
|
||||||
$cpu = sys_getloadavg();
|
$cpu = sys_getloadavg();
|
||||||
|
|
||||||
return $cpu[0];
|
return $cpu[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,14 +193,12 @@ private function dispatchEvent($event, $message = []): void
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('配置文件更新完成。');
|
$this->info('配置文件更新完成。');
|
||||||
|
|
||||||
},
|
},
|
||||||
'cluster.restart.web' => function () {
|
'cluster.restart.web' => function () {
|
||||||
$this->info('正在重启 Web。');
|
$this->info('正在重启 Web。');
|
||||||
|
|
||||||
exec('php artisan octane:reload');
|
exec('php artisan octane:reload');
|
||||||
|
|
||||||
|
|
||||||
ClusterSupport::publish('cluster.restarted.web');
|
ClusterSupport::publish('cluster.restarted.web');
|
||||||
|
|
||||||
$this->info('Web 重启完成。');
|
$this->info('Web 重启完成。');
|
||||||
|
@ -86,7 +86,6 @@ public function handle(): int
|
|||||||
|
|
||||||
$this->info('完成。');
|
$this->info('完成。');
|
||||||
|
|
||||||
|
|
||||||
$this->warn('用户数量: '.$users);
|
$this->warn('用户数量: '.$users);
|
||||||
$this->warn('主机数量: '.$hosts);
|
$this->warn('主机数量: '.$hosts);
|
||||||
$this->warn('正在部署的主机数量: '.$pending_hosts);
|
$this->warn('正在部署的主机数量: '.$pending_hosts);
|
||||||
|
@ -45,7 +45,6 @@ public function handle(): int
|
|||||||
|
|
||||||
$user = (new User)->where('email', $email_or_id)->orWhere('id', $email_or_id)->orWhere('name', $email_or_id)->first();
|
$user = (new User)->where('email', $email_or_id)->orWhere('id', $email_or_id)->orWhere('name', $email_or_id)->first();
|
||||||
|
|
||||||
|
|
||||||
// $transaction = new Transaction();
|
// $transaction = new Transaction();
|
||||||
|
|
||||||
$this->warn('用户基本信息');
|
$this->warn('用户基本信息');
|
||||||
|
@ -43,13 +43,11 @@ public function handle(): int
|
|||||||
} else {
|
} else {
|
||||||
$host_model = (new Host)->where('id', $host)->firstOrFail();
|
$host_model = (new Host)->where('id', $host)->firstOrFail();
|
||||||
|
|
||||||
|
|
||||||
if ($this->confirm('是否扣除主机 '.$host_model->name.' 的费用?', true)) {
|
if ($this->confirm('是否扣除主机 '.$host_model->name.' 的费用?', true)) {
|
||||||
$host_model->cost();
|
$host_model->cost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return CommandAlias::SUCCESS;
|
return CommandAlias::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ public function handle(): void
|
|||||||
|
|
||||||
$amount = $this->argument('amount');
|
$amount = $this->argument('amount');
|
||||||
|
|
||||||
|
|
||||||
$user = (new User)->find($user_id);
|
$user = (new User)->find($user_id);
|
||||||
|
|
||||||
$this->warn('扣除金额: '.$amount.' 元');
|
$this->warn('扣除金额: '.$amount.' 元');
|
||||||
|
@ -39,20 +39,16 @@ public function __construct()
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->warn('===== 运行环境 =====');
|
$this->warn('===== 运行环境 =====');
|
||||||
|
|
||||||
|
|
||||||
// php version
|
// php version
|
||||||
$this->info('PHP 版本: '.PHP_VERSION);
|
$this->info('PHP 版本: '.PHP_VERSION);
|
||||||
|
|
||||||
// get mysql version
|
// get mysql version
|
||||||
$mysql_version = DB::select('select version() as version')[0]->version;
|
$mysql_version = DB::select('select version() as version')[0]->version;
|
||||||
|
|
||||||
|
|
||||||
$this->warn('MySQL 版本: '.$mysql_version);
|
$this->warn('MySQL 版本: '.$mysql_version);
|
||||||
|
|
||||||
|
|
||||||
$redis_info = Redis::info();
|
$redis_info = Redis::info();
|
||||||
|
|
||||||
// get redis version
|
// get redis version
|
||||||
@ -76,7 +72,6 @@ public function handle(): int
|
|||||||
$redis_pid = $redis_info['process_id'];
|
$redis_pid = $redis_info['process_id'];
|
||||||
$this->warn('Redis 进程 ID: '.$redis_pid);
|
$this->warn('Redis 进程 ID: '.$redis_pid);
|
||||||
|
|
||||||
|
|
||||||
// redis used memory
|
// redis used memory
|
||||||
$redis_used_memory = $redis_info['used_memory_human'];
|
$redis_used_memory = $redis_info['used_memory_human'];
|
||||||
|
|
||||||
@ -108,11 +103,9 @@ public function handle(): int
|
|||||||
$redis_total_commands_processed = $redis_info['total_commands_processed'];
|
$redis_total_commands_processed = $redis_info['total_commands_processed'];
|
||||||
$this->info('Redis 总命令数: '.$redis_total_commands_processed);
|
$this->info('Redis 总命令数: '.$redis_total_commands_processed);
|
||||||
|
|
||||||
|
|
||||||
$this->warn('===== 莱云 统计 =====');
|
$this->warn('===== 莱云 统计 =====');
|
||||||
$this->warn('要获取 莱云 统计信息,请运行 count 命令。');
|
$this->warn('要获取 莱云 统计信息,请运行 count 命令。');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public function handle(): void
|
|||||||
|
|
||||||
(new Host)->where('user_id', $user_id)->update([
|
(new Host)->where('user_id', $user_id)->update([
|
||||||
'status' => 'suspended',
|
'status' => 'suspended',
|
||||||
'suspended_at' => now()
|
'suspended_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('暂停用户的所有主机成功。');
|
$this->info('暂停用户的所有主机成功。');
|
||||||
|
@ -44,7 +44,6 @@ public function handle(): int
|
|||||||
$user_id = $this->argument('user_id');
|
$user_id = $this->argument('user_id');
|
||||||
$amount = $this->argument('amount');
|
$amount = $this->argument('amount');
|
||||||
|
|
||||||
|
|
||||||
// find user
|
// find user
|
||||||
$user = (new User)->findOrFail($user_id);
|
$user = (new User)->findOrFail($user_id);
|
||||||
|
|
||||||
@ -53,6 +52,7 @@ public function handle(): int
|
|||||||
$this->info('充值后余额: '.($user->balance + $amount).' 元');
|
$this->info('充值后余额: '.($user->balance + $amount).' 元');
|
||||||
if (! $this->confirm('确认充值 '.$amount.' 元?')) {
|
if (! $this->confirm('确认充值 '.$amount.' 元?')) {
|
||||||
$this->info('已取消。');
|
$this->info('已取消。');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +68,5 @@ public function handle(): int
|
|||||||
$this->info($user->name.', 当前余额: '.$user->balance);
|
$this->info($user->name.', 当前余额: '.$user->balance);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ class Kernel extends ConsoleKernel
|
|||||||
* Define the application's command schedule.
|
* Define the application's command schedule.
|
||||||
*
|
*
|
||||||
* @param Schedule $schedule
|
* @param Schedule $schedule
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule): void
|
protected function schedule(Schedule $schedule): void
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
class Servers extends Event implements ShouldBroadcast
|
class Servers extends Event implements ShouldBroadcast
|
||||||
{
|
{
|
||||||
|
|
||||||
public array $data;
|
public array $data;
|
||||||
|
|
||||||
public string $type = 'servers.updated';
|
public string $type = 'servers.updated';
|
||||||
|
@ -17,13 +17,15 @@ class Users extends Event implements ShouldBroadcastNow
|
|||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
public User $user;
|
public User $user;
|
||||||
|
|
||||||
public array|Model $data;
|
public array|Model $data;
|
||||||
|
|
||||||
public null|Module $module = null;
|
public null|Module $module = null;
|
||||||
|
|
||||||
public string $event = 'notification';
|
public string $event = 'notification';
|
||||||
|
|
||||||
public Carbon $sent_at;
|
public Carbon $sent_at;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
@ -57,7 +59,6 @@ public function __construct(User|int $user, string $event, array|Model $data)
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// log
|
// log
|
||||||
if (config('app.env') != 'production') {
|
if (config('app.env') != 'production') {
|
||||||
Log::debug('Users Event', [
|
Log::debug('Users Event', [
|
||||||
@ -69,14 +70,12 @@ public function __construct(User|int $user, string $event, array|Model $data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public
|
public function broadcastOn(): PrivateChannel
|
||||||
function broadcastOn(): PrivateChannel
|
|
||||||
{
|
{
|
||||||
return new PrivateChannel('users.'.$this->user->id);
|
return new PrivateChannel('users.'.$this->user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public
|
public function broadcastAs(): string
|
||||||
function broadcastAs(): string
|
|
||||||
{
|
{
|
||||||
return 'messages';
|
return 'messages';
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ class Handler extends ExceptionHandler
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the exception handling callbacks for the application.
|
* Register the exception handling callbacks for the application.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
@ -70,7 +69,6 @@ public function register(): void
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param AuthenticationException $exception
|
* @param AuthenticationException $exception
|
||||||
*
|
|
||||||
* @return JsonResponse|RedirectResponse
|
* @return JsonResponse|RedirectResponse
|
||||||
*/
|
*/
|
||||||
protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse
|
protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse
|
||||||
|
@ -4,5 +4,4 @@
|
|||||||
|
|
||||||
trait HttpEvent
|
trait HttpEvent
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,10 @@ public function await($name, Closure $callback)
|
|||||||
if (config('app.env') == 'local') {
|
if (config('app.env') == 'local') {
|
||||||
return $callback();
|
return $callback();
|
||||||
}
|
}
|
||||||
$lock = Cache::lock("lock_" . $name, 5);
|
$lock = Cache::lock('lock_'.$name, 5);
|
||||||
try {
|
try {
|
||||||
$lock->block(5);
|
$lock->block(5);
|
||||||
|
|
||||||
return $callback();
|
return $callback();
|
||||||
} finally {
|
} finally {
|
||||||
optional($lock)->release();
|
optional($lock)->release();
|
||||||
|
@ -27,7 +27,6 @@ public function index(): View
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
@ -62,7 +61,6 @@ public function create(): View
|
|||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param Admin $admin
|
* @param Admin $admin
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Admin $admin): View
|
public function edit(Admin $admin): View
|
||||||
@ -75,7 +73,6 @@ public function edit(Admin $admin): View
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Admin $admin
|
* @param Admin $admin
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Admin $admin): RedirectResponse
|
public function update(Request $request, Admin $admin): RedirectResponse
|
||||||
@ -110,7 +107,6 @@ public function update(Request $request, Admin $admin): RedirectResponse
|
|||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param Admin $admin
|
* @param Admin $admin
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(Admin $admin): RedirectResponse
|
public function destroy(Admin $admin): RedirectResponse
|
||||||
|
@ -26,7 +26,6 @@ public function index(): View
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): View
|
public function store(Request $request): View
|
||||||
@ -60,7 +59,6 @@ public function create(): View
|
|||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function show(Application $application): RedirectResponse
|
public function show(Application $application): RedirectResponse
|
||||||
@ -74,7 +72,6 @@ public function show(Application $application): RedirectResponse
|
|||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Application $application): View
|
public function edit(Application $application): View
|
||||||
@ -89,7 +86,6 @@ public function edit(Application $application): View
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Application $application): RedirectResponse
|
public function update(Request $request, Application $application): RedirectResponse
|
||||||
@ -111,7 +107,6 @@ public function update(Request $request, Application $application): RedirectResp
|
|||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param Application $application
|
* @param Application $application
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(Application $application): RedirectResponse
|
public function destroy(Application $application): RedirectResponse
|
||||||
|
@ -23,7 +23,6 @@ public function index(): View|RedirectResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function login(Request $request): RedirectResponse
|
public function login(Request $request): RedirectResponse
|
||||||
@ -41,6 +40,7 @@ public function login(Request $request): RedirectResponse
|
|||||||
public function logout(): RedirectResponse
|
public function logout(): RedirectResponse
|
||||||
{
|
{
|
||||||
auth('admin')->logout();
|
auth('admin')->logout();
|
||||||
|
|
||||||
return redirect()->route('admin.login');
|
return redirect()->route('admin.login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ class HostController extends Controller
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): View
|
public function index(Request $request): View
|
||||||
@ -40,7 +39,6 @@ public function index(Request $request): View
|
|||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param Host $host
|
* @param Host $host
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Host $host): View
|
public function edit(Host $host): View
|
||||||
@ -53,7 +51,6 @@ public function edit(Host $host): View
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Host $host
|
* @param Host $host
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Host $host): RedirectResponse
|
public function update(Request $request, Host $host): RedirectResponse
|
||||||
@ -74,7 +71,6 @@ public function update(Request $request, Host $host): RedirectResponse
|
|||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param Host $host
|
* @param Host $host
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(Host $host): RedirectResponse
|
public function destroy(Host $host): RedirectResponse
|
||||||
|
@ -17,7 +17,6 @@ class ModuleController extends Controller
|
|||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(Module $module): View
|
public function index(Module $module): View
|
||||||
@ -41,7 +40,6 @@ public function create(): View
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
@ -62,7 +60,6 @@ public function store(Request $request): RedirectResponse
|
|||||||
$module->save();
|
$module->save();
|
||||||
|
|
||||||
return redirect()->route('admin.modules.edit', $module)->with('success', '模块创建成功。');
|
return redirect()->route('admin.modules.edit', $module)->with('success', '模块创建成功。');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rules(): array
|
private function rules(): array
|
||||||
@ -81,7 +78,6 @@ private function rules(): array
|
|||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(Module $module): View
|
public function show(Module $module): View
|
||||||
@ -97,7 +93,6 @@ public function show(Module $module): View
|
|||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Module $module): View
|
public function edit(Module $module): View
|
||||||
@ -112,7 +107,6 @@ public function edit(Module $module): View
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Module $module): RedirectResponse
|
public function update(Request $request, Module $module): RedirectResponse
|
||||||
@ -152,7 +146,6 @@ public function update(Request $request, Module $module): RedirectResponse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->input('reset_api_token')) {
|
if ($request->input('reset_api_token')) {
|
||||||
$text .= ', API Token 为 '.$module->api_token.'。';
|
$text .= ', API Token 为 '.$module->api_token.'。';
|
||||||
} else {
|
} else {
|
||||||
@ -166,7 +159,6 @@ public function update(Request $request, Module $module): RedirectResponse
|
|||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param Module $module
|
* @param Module $module
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(Module $module): RedirectResponse
|
public function destroy(Module $module): RedirectResponse
|
||||||
@ -198,7 +190,6 @@ public function allows_store(Request $request, Module $module): RedirectResponse
|
|||||||
return back()->with('success', '已信任该模块。');
|
return back()->with('success', '已信任该模块。');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// fast login
|
// fast login
|
||||||
|
|
||||||
public function allows_destroy(Module $module, ModuleAllow $allow): RedirectResponse
|
public function allows_destroy(Module $module, ModuleAllow $allow): RedirectResponse
|
||||||
@ -214,6 +205,7 @@ public function fast_login(Module $module): View|RedirectResponse
|
|||||||
|
|
||||||
if ($resp['success']) {
|
if ($resp['success']) {
|
||||||
$resp = $resp['json'];
|
$resp = $resp['json'];
|
||||||
|
|
||||||
return view('admin.modules.login', compact('module', 'resp'));
|
return view('admin.modules.login', compact('module', 'resp'));
|
||||||
} else {
|
} else {
|
||||||
return redirect()->route('admin.modules.show', $module)->with('error', '快速登录失败,可能是模块不支持。');
|
return redirect()->route('admin.modules.show', $module)->with('error', '快速登录失败,可能是模块不支持。');
|
||||||
|
@ -14,12 +14,10 @@
|
|||||||
|
|
||||||
class NotificationController extends Controller
|
class NotificationController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function create(Request $request): View
|
public function create(Request $request): View
|
||||||
@ -70,7 +68,6 @@ public function query(Request|array $request): User|CachedBuilder|Builder
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
|
@ -16,7 +16,6 @@ class ReplyController extends Controller
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param WorkOrder $work_order
|
* @param WorkOrder $work_order
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request, WorkOrder $work_order): RedirectResponse
|
public function store(Request $request, WorkOrder $work_order): RedirectResponse
|
||||||
@ -32,7 +31,7 @@ public function store(Request $request, WorkOrder $work_order): RedirectResponse
|
|||||||
(new Reply)->create([
|
(new Reply)->create([
|
||||||
'content' => $request->input('content'),
|
'content' => $request->input('content'),
|
||||||
'work_order_id' => $work_order->id,
|
'work_order_id' => $work_order->id,
|
||||||
'name' => auth('admin')->user()->name
|
'name' => auth('admin')->user()->name,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return back()->with('success', '回复成功,请等待同步。');
|
return back()->with('success', '回复成功,请等待同步。');
|
||||||
@ -43,7 +42,6 @@ public function store(Request $request, WorkOrder $work_order): RedirectResponse
|
|||||||
*
|
*
|
||||||
* @param WorkOrder $work_order
|
* @param WorkOrder $work_order
|
||||||
* @param Reply $reply
|
* @param Reply $reply
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(WorkOrder $work_order, Reply $reply): View
|
public function edit(WorkOrder $work_order, Reply $reply): View
|
||||||
@ -57,7 +55,6 @@ public function edit(WorkOrder $work_order, Reply $reply): View
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param WorkOrder $work_order
|
* @param WorkOrder $work_order
|
||||||
* @param Reply $reply
|
* @param Reply $reply
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, WorkOrder $work_order, Reply $reply): RedirectResponse
|
public function update(Request $request, WorkOrder $work_order, Reply $reply): RedirectResponse
|
||||||
@ -67,7 +64,7 @@ public function update(Request $request, WorkOrder $work_order, Reply $reply): R
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$reply->update([
|
$reply->update([
|
||||||
'content' => $request->input('content')
|
'content' => $request->input('content'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect()->route('admin.work-orders.show', $work_order)->with('success', '修改成功。');
|
return redirect()->route('admin.work-orders.show', $work_order)->with('success', '修改成功。');
|
||||||
@ -78,7 +75,6 @@ public function update(Request $request, WorkOrder $work_order, Reply $reply): R
|
|||||||
*
|
*
|
||||||
* @param WorkOrder $work_order
|
* @param WorkOrder $work_order
|
||||||
* @param Reply $reply
|
* @param Reply $reply
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(WorkOrder $work_order, Reply $reply): RedirectResponse
|
public function destroy(WorkOrder $work_order, Reply $reply): RedirectResponse
|
||||||
|
@ -18,7 +18,6 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): View
|
public function index(Request $request): View
|
||||||
{
|
{
|
||||||
@ -59,7 +58,6 @@ public function index(Request $request): View
|
|||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function show(User $user): RedirectResponse
|
public function show(User $user): RedirectResponse
|
||||||
@ -73,7 +71,6 @@ public function show(User $user): RedirectResponse
|
|||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(User $user): View
|
public function edit(User $user): View
|
||||||
@ -91,7 +88,6 @@ public function edit(User $user): View
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, User $user): RedirectResponse
|
public function update(Request $request, User $user): RedirectResponse
|
||||||
@ -124,15 +120,14 @@ public function update(Request $request, User $user): RedirectResponse
|
|||||||
} elseif ($one_time_action == 'stop_all_hosts') {
|
} elseif ($one_time_action == 'stop_all_hosts') {
|
||||||
$user->hosts()->update(['status' => 'stopped', 'suspended_at' => null]);
|
$user->hosts()->update(['status' => 'stopped', 'suspended_at' => null]);
|
||||||
} elseif ($one_time_action == 'add_balance') {
|
} elseif ($one_time_action == 'add_balance') {
|
||||||
$description = '管理员 ' . $request->user('admin')->name . " 增加。";
|
$description = '管理员 '.$request->user('admin')->name.' 增加。';
|
||||||
|
|
||||||
$user->charge($request->input('balance'), 'console', $description);
|
$user->charge($request->input('balance'), 'console', $description);
|
||||||
} elseif ($one_time_action == 'reduce_balance') {
|
} elseif ($one_time_action == 'reduce_balance') {
|
||||||
$description = '管理员 ' . $request->user('admin')->name . " 扣除。";
|
$description = '管理员 '.$request->user('admin')->name.' 扣除。';
|
||||||
|
|
||||||
$user->reduce($request->input('balance'), $description);
|
$user->reduce($request->input('balance'), $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('user_group_id')) {
|
if ($request->has('user_group_id')) {
|
||||||
|
@ -27,7 +27,6 @@ public function index(): View
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): RedirectResponse
|
public function store(Request $request): RedirectResponse
|
||||||
@ -65,7 +64,6 @@ public function create(): View
|
|||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param UserGroup $user_group
|
* @param UserGroup $user_group
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(UserGroup $user_group): View
|
public function show(UserGroup $user_group): View
|
||||||
@ -79,7 +77,6 @@ public function show(UserGroup $user_group): View
|
|||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param UserGroup $user_group
|
* @param UserGroup $user_group
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(UserGroup $user_group): View
|
public function edit(UserGroup $user_group): View
|
||||||
@ -94,7 +91,6 @@ public function edit(UserGroup $user_group): View
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param UserGroup $user_group
|
* @param UserGroup $user_group
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, UserGroup $user_group): RedirectResponse
|
public function update(Request $request, UserGroup $user_group): RedirectResponse
|
||||||
@ -111,7 +107,6 @@ public function update(Request $request, UserGroup $user_group): RedirectRespons
|
|||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param UserGroup $user_group
|
* @param UserGroup $user_group
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(UserGroup $user_group): RedirectResponse
|
public function destroy(UserGroup $user_group): RedirectResponse
|
||||||
|
@ -16,7 +16,6 @@ class WorkOrderController extends Controller
|
|||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function index(WorkOrder $workOrder): View
|
public function index(WorkOrder $workOrder): View
|
||||||
@ -30,7 +29,6 @@ public function index(WorkOrder $workOrder): View
|
|||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function show(WorkOrder $workOrder): View
|
public function show(WorkOrder $workOrder): View
|
||||||
@ -46,7 +44,6 @@ public function show(WorkOrder $workOrder): View
|
|||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(WorkOrder $workOrder): View
|
public function edit(WorkOrder $workOrder): View
|
||||||
@ -59,7 +56,6 @@ public function edit(WorkOrder $workOrder): View
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, WorkOrder $workOrder): RedirectResponse
|
public function update(Request $request, WorkOrder $workOrder): RedirectResponse
|
||||||
@ -81,7 +77,6 @@ public function update(Request $request, WorkOrder $workOrder): RedirectResponse
|
|||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy(WorkOrder $workOrder): RedirectResponse
|
public function destroy(WorkOrder $workOrder): RedirectResponse
|
||||||
|
@ -25,7 +25,6 @@ public function index(): JsonResponse
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): JsonResponse
|
public function store(Request $request): JsonResponse
|
||||||
@ -51,13 +50,11 @@ public function store(Request $request): JsonResponse
|
|||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param Balance $balance
|
* @param Balance $balance
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function show(Balance $balance): JsonResponse
|
public function show(Balance $balance): JsonResponse
|
||||||
{
|
{
|
||||||
if ($balance->canPay()) {
|
if ($balance->canPay()) {
|
||||||
|
|
||||||
$url = route('balances.show', compact('balance'));
|
$url = route('balances.show', compact('balance'));
|
||||||
$balance->url = $url;
|
$balance->url = $url;
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use function config;
|
||||||
use Illuminate\Http\Client\PendingRequest;
|
use Illuminate\Http\Client\PendingRequest;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use function config;
|
|
||||||
|
|
||||||
class ForumController extends Controller
|
class ForumController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
private mixed $baseUrl;
|
private mixed $baseUrl;
|
||||||
|
|
||||||
private PendingRequest $http;
|
private PendingRequest $http;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
use App\Http\Requests\User\HostRequest;
|
use App\Http\Requests\User\HostRequest;
|
||||||
use App\Jobs\Host\HostJob;
|
use App\Jobs\Host\HostJob;
|
||||||
use App\Models\Host;
|
use App\Models\Host;
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use function auth;
|
use function auth;
|
||||||
use function dispatch;
|
use function dispatch;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use function now;
|
use function now;
|
||||||
|
|
||||||
class HostController extends Controller
|
class HostController extends Controller
|
||||||
@ -78,7 +78,7 @@ public function usages(): JsonResponse
|
|||||||
$hosts_balances = Cache::get($month_cache_key, []);
|
$hosts_balances = Cache::get($month_cache_key, []);
|
||||||
|
|
||||||
return $this->success([
|
return $this->success([
|
||||||
'balances' => $hosts_balances
|
'balances' => $hosts_balances,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\WorkOrder\Reply;
|
use App\Models\WorkOrder\Reply;
|
||||||
use App\Models\WorkOrder\WorkOrder;
|
use App\Models\WorkOrder\WorkOrder;
|
||||||
|
use function auth;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use function auth;
|
|
||||||
|
|
||||||
class ReplyController extends Controller
|
class ReplyController extends Controller
|
||||||
{
|
{
|
||||||
@ -15,7 +15,6 @@ class ReplyController extends Controller
|
|||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function index(WorkOrder $workOrder): JsonResponse
|
public function index(WorkOrder $workOrder): JsonResponse
|
||||||
@ -30,7 +29,6 @@ public function index(WorkOrder $workOrder): JsonResponse
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function store(Request $request, WorkOrder $workOrder): JsonResponse
|
public function store(Request $request, WorkOrder $workOrder): JsonResponse
|
||||||
|
@ -15,7 +15,6 @@ public function index()
|
|||||||
return $this->success($modules);
|
return $this->success($modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function show(Module $module): JsonResponse
|
public function show(Module $module): JsonResponse
|
||||||
{
|
{
|
||||||
return $this->success($module);
|
return $this->success($module);
|
||||||
|
@ -62,7 +62,6 @@ public function authentication(Request $request): Response
|
|||||||
} else {
|
} else {
|
||||||
return $this->deny();
|
return $this->deny();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +123,6 @@ public function authorization(Request $request): Response
|
|||||||
return $this->ignore();
|
return $this->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 设备只能在自己的模块下发布消息
|
// 设备只能在自己的模块下发布消息
|
||||||
if ($action == 'publish') {
|
if ($action == 'publish') {
|
||||||
if ($topics[0] !== $module_id) {
|
if ($topics[0] !== $module_id) {
|
||||||
@ -137,7 +135,6 @@ public function authorization(Request $request): Response
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (count($usernames) === 1) {
|
if (count($usernames) === 1) {
|
||||||
// 是模块自己的连接
|
// 是模块自己的连接
|
||||||
return $this->allow();
|
return $this->allow();
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
use App\Models\PersonalAccessToken;
|
use App\Models\PersonalAccessToken;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Arr;
|
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
@ -22,12 +21,10 @@ public function show(User $user): JsonResponse
|
|||||||
return $this->success($user);
|
return $this->success($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function auth($token): JsonResponse
|
public function auth($token): JsonResponse
|
||||||
{
|
{
|
||||||
$token = PersonalAccessToken::findToken($token);
|
$token = PersonalAccessToken::findToken($token);
|
||||||
|
|
||||||
return $token ? $this->success($token->tokenable) : $this->notFound();
|
return $token ? $this->success($token->tokenable) : $this->notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public function broadcast_to_user(Request $request, User $user): JsonResponse
|
|||||||
|
|
||||||
$user->notify(new WebNotification($request->all(), $request->input('event')));
|
$user->notify(new WebNotification($request->all(), $request->input('event')));
|
||||||
|
|
||||||
return $this->created("message sent.");
|
return $this->created('message sent.');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rules(): array
|
private function rules(): array
|
||||||
|
@ -22,6 +22,7 @@ public function index(Request $request): JsonResponse
|
|||||||
]);
|
]);
|
||||||
} catch (EmqxSupportException $e) {
|
} catch (EmqxSupportException $e) {
|
||||||
Log::error('emqx connect failed.', [$e]);
|
Log::error('emqx connect failed.', [$e]);
|
||||||
|
|
||||||
return $this->error('unable connectto emqx');
|
return $this->error('unable connectto emqx');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Host;
|
use App\Models\Host;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use function auth;
|
||||||
use Illuminate\Contracts\Pagination\Paginator;
|
use Illuminate\Contracts\Pagination\Paginator;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use function auth;
|
|
||||||
|
|
||||||
// use App\Models\User;
|
// use App\Models\User;
|
||||||
|
|
||||||
@ -19,8 +19,6 @@ class HostController extends Controller
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): Paginator
|
public function index(Request $request): Paginator
|
||||||
{
|
{
|
||||||
@ -31,8 +29,8 @@ public function index(Request $request): Paginator
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return Response|JsonResponse
|
* @return Response|JsonResponse
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): Response|JsonResponse
|
public function store(Request $request): Response|JsonResponse
|
||||||
@ -61,7 +59,7 @@ public function store(Request $request): Response|JsonResponse
|
|||||||
'price' => $request->input('price'),
|
'price' => $request->input('price'),
|
||||||
'managed_price' => $request->input('managed_price'),
|
'managed_price' => $request->input('managed_price'),
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'module_id' => auth('module')->id()
|
'module_id' => auth('module')->id(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$host = (new Host)->create($data);
|
$host = (new Host)->create($data);
|
||||||
@ -75,12 +73,10 @@ public function store(Request $request): Response|JsonResponse
|
|||||||
* Display the specified resource.
|
* Display the specified resource.
|
||||||
*
|
*
|
||||||
* @param Host $host
|
* @param Host $host
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function show(Host $host): JsonResponse
|
public function show(Host $host): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->success($host);
|
return $this->success($host);
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -92,8 +88,8 @@ public function show(Host $host): JsonResponse
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Host $host
|
* @param Host $host
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Host $host): JsonResponse
|
public function update(Request $request, Host $host): JsonResponse
|
||||||
@ -125,7 +121,6 @@ public function update(Request $request, Host $host): JsonResponse
|
|||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param $host
|
* @param $host
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function destroy($host): JsonResponse
|
public function destroy($host): JsonResponse
|
||||||
|
@ -14,7 +14,6 @@ class ReplyController extends Controller
|
|||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
@ -26,8 +25,6 @@ public function index(Request $request): JsonResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request, WorkOrder $work_order): JsonResponse
|
public function store(Request $request, WorkOrder $work_order): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -10,13 +10,14 @@
|
|||||||
|
|
||||||
class TaskController extends Controller
|
class TaskController extends Controller
|
||||||
{
|
{
|
||||||
public int $user_id, $host_id;
|
public int $user_id;
|
||||||
|
|
||||||
|
public int $host_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
@ -30,8 +31,8 @@ public function index(Request $request): JsonResponse
|
|||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function store(Request $request): JsonResponse
|
public function store(Request $request): JsonResponse
|
||||||
@ -53,8 +54,8 @@ public function store(Request $request): JsonResponse
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Task $task
|
* @param Task $task
|
||||||
*
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, Task $task): JsonResponse
|
public function update(Request $request, Task $task): JsonResponse
|
||||||
@ -65,10 +66,8 @@ public function update(Request $request, Task $task): JsonResponse
|
|||||||
'status' => 'sometimes|in:pending,processing,need_operation,done,success,failed,error,canceled',
|
'status' => 'sometimes|in:pending,processing,need_operation,done,success,failed,error,canceled',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$task->update($request->all());
|
$task->update($request->all());
|
||||||
|
|
||||||
|
|
||||||
return $this->updated($task);
|
return $this->updated($task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public function update(Request $request, User $user): JsonResponse
|
|||||||
|
|
||||||
$module->reduce($balance, $request->description, true, [
|
$module->reduce($balance, $request->description, true, [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'payment' => 'module_balance'
|
'payment' => 'module_balance',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user->charge($balance, 'module_balance', $request->description);
|
$user->charge($balance, 'module_balance', $request->description);
|
||||||
@ -102,12 +102,10 @@ public function auth($token): JsonResponse
|
|||||||
return $token ? $this->success(Arr::only(
|
return $token ? $this->success(Arr::only(
|
||||||
$token->tokenable
|
$token->tokenable
|
||||||
->makeVisible('real_name')
|
->makeVisible('real_name')
|
||||||
->toArray()
|
->toArray(),
|
||||||
,
|
|
||||||
[
|
[
|
||||||
'id', 'name', 'email', 'real_name'
|
'id', 'name', 'email', 'real_name',
|
||||||
]
|
]
|
||||||
)) : $this->notFound();
|
)) : $this->notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ public function verify(Request $request): JsonResponse
|
|||||||
|
|
||||||
if (! $result) {
|
if (! $result) {
|
||||||
Log::warning('实名认证失败', $request->all());
|
Log::warning('实名认证失败', $request->all());
|
||||||
|
|
||||||
return $this->error('实名认证失败。');
|
return $this->error('实名认证失败。');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ public function verify(Request $request): JsonResponse
|
|||||||
$user->id_card = $result['id_card'];
|
$user->id_card = $result['id_card'];
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$user->reduce("0.7", '实名认证费用。');
|
$user->reduce('0.7', '实名认证费用。');
|
||||||
|
|
||||||
return $this->success('实名认证成功。');
|
return $this->success('实名认证成功。');
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\User\UserNotification;
|
use App\Notifications\User\UserNotification;
|
||||||
|
use function back;
|
||||||
|
use function config;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
@ -15,8 +17,6 @@
|
|||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use function back;
|
|
||||||
use function config;
|
|
||||||
use function redirect;
|
use function redirect;
|
||||||
use function session;
|
use function session;
|
||||||
use function view;
|
use function view;
|
||||||
@ -27,19 +27,15 @@ public function index(Request $request): View|RedirectResponse
|
|||||||
{
|
{
|
||||||
// if logged in
|
// if logged in
|
||||||
if ($request->filled('callback')) {
|
if ($request->filled('callback')) {
|
||||||
|
|
||||||
$callback = $request->input('callback');
|
$callback = $request->input('callback');
|
||||||
|
|
||||||
session(['callback' => $callback]);
|
session(['callback' => $callback]);
|
||||||
|
|
||||||
if (Auth::guard('web')->check()) {
|
if (Auth::guard('web')->check()) {
|
||||||
|
|
||||||
|
|
||||||
$callbackHost = parse_url($callback, PHP_URL_HOST);
|
$callbackHost = parse_url($callback, PHP_URL_HOST);
|
||||||
$dashboardHost = parse_url(config('settings.dashboard.base_url'), PHP_URL_HOST);
|
$dashboardHost = parse_url(config('settings.dashboard.base_url'), PHP_URL_HOST);
|
||||||
|
|
||||||
if ($callbackHost === $dashboardHost) {
|
if ($callbackHost === $dashboardHost) {
|
||||||
|
|
||||||
if (! Auth::guard('web')->user()->isRealNamed()) {
|
if (! Auth::guard('web')->user()->isRealNamed()) {
|
||||||
return redirect()->route('real_name.create')->with('status', '重定向已被打断,需要先实人认证。');
|
return redirect()->route('real_name.create')->with('status', '重定向已被打断,需要先实人认证。');
|
||||||
}
|
}
|
||||||
@ -119,7 +115,6 @@ public function callback(Request $request): RedirectResponse
|
|||||||
}
|
}
|
||||||
$oauth_user = json_decode($oauth_user);
|
$oauth_user = json_decode($oauth_user);
|
||||||
|
|
||||||
|
|
||||||
$user_sql = (new User)->where('email', $oauth_user->email);
|
$user_sql = (new User)->where('email', $oauth_user->email);
|
||||||
$user = $user_sql->first();
|
$user = $user_sql->first();
|
||||||
|
|
||||||
@ -139,7 +134,7 @@ public function callback(Request $request): RedirectResponse
|
|||||||
} else {
|
} else {
|
||||||
if ($user->name != $oauth_user->name) {
|
if ($user->name != $oauth_user->name) {
|
||||||
(new User)->where('email', $oauth_user->email)->update([
|
(new User)->where('email', $oauth_user->email)->update([
|
||||||
'name' => $oauth_user->name
|
'name' => $oauth_user->name,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,7 @@ public function show(Request $request, Balance $balance): RedirectResponse|JsonR
|
|||||||
return view('balances.pay', compact('balance', 'qr_code'));
|
return view('balances.pay', compact('balance', 'qr_code'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private
|
private function xunhu_wechat(
|
||||||
function xunhu_wechat(
|
|
||||||
Balance $balance, $subject = '支付'
|
Balance $balance, $subject = '支付'
|
||||||
) {
|
) {
|
||||||
$data = [
|
$data = [
|
||||||
@ -143,8 +142,7 @@ function xunhu_wechat(
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private
|
private function xunhu_hash(
|
||||||
function xunhu_hash(
|
|
||||||
array $arr
|
array $arr
|
||||||
): string {
|
): string {
|
||||||
ksort($arr);
|
ksort($arr);
|
||||||
@ -167,7 +165,7 @@ function xunhu_hash(
|
|||||||
foreach ($pre as $key => $val) {
|
foreach ($pre as $key => $val) {
|
||||||
$arg .= "$key=$val";
|
$arg .= "$key=$val";
|
||||||
if ($index++ < ($qty - 1)) {
|
if ($index++ < ($qty - 1)) {
|
||||||
$arg .= "&";
|
$arg .= '&';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +175,7 @@ function xunhu_hash(
|
|||||||
/**
|
/**
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
*/
|
*/
|
||||||
public
|
public function notify(
|
||||||
function notify(
|
|
||||||
Request $request, $payment
|
Request $request, $payment
|
||||||
): View|JsonResponse {
|
): View|JsonResponse {
|
||||||
$is_paid = false;
|
$is_paid = false;
|
||||||
@ -229,31 +226,26 @@ function notify(
|
|||||||
if ($is_paid) {
|
if ($is_paid) {
|
||||||
// $balance->user->charge($balance->amount, $balance->payment, $balance->order_id);
|
// $balance->user->charge($balance->amount, $balance->payment, $balance->order_id);
|
||||||
$balance->update([
|
$balance->update([
|
||||||
'paid_at' => now()
|
'paid_at' => now(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->ajax()) {
|
if ($request->ajax()) {
|
||||||
return $this->success($balance);
|
return $this->success($balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('balances.process', compact('balance'));
|
return view('balances.process', compact('balance'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取交易记录
|
* 获取交易记录
|
||||||
*
|
*
|
||||||
* @param mixed $request
|
* @param mixed $request
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public
|
public function transactions(
|
||||||
function transactions(
|
|
||||||
Request $request
|
Request $request
|
||||||
): View {
|
): View {
|
||||||
|
|
||||||
$modules = Module::all();
|
$modules = Module::all();
|
||||||
|
|
||||||
$transactions = (new Transaction)->where('user_id', auth('web')->id())->where('payment', '!=', 'module_balance');
|
$transactions = (new Transaction)->where('user_id', auth('web')->id())->where('payment', '!=', 'module_balance');
|
||||||
|
@ -21,7 +21,6 @@ public function store(Request $request): RedirectResponse
|
|||||||
|
|
||||||
$realNameSupport = new RealNameSupport();
|
$realNameSupport = new RealNameSupport();
|
||||||
|
|
||||||
|
|
||||||
$birthday = $realNameSupport->getBirthday($request->input('id_card'));
|
$birthday = $realNameSupport->getBirthday($request->input('id_card'));
|
||||||
// 检查年龄是否在区间内 settings.supports.real_name.min_age ~ settings.supports.real_name.max_age
|
// 检查年龄是否在区间内 settings.supports.real_name.min_age ~ settings.supports.real_name.max_age
|
||||||
if (Carbon::now()->diffInYears($birthday) < config('settings.supports.real_name.min_age') || Carbon::now()->diffInYears($birthday) > config('settings.supports.real_name.max_age')) {
|
if (Carbon::now()->diffInYears($birthday) < config('settings.supports.real_name.min_age') || Carbon::now()->diffInYears($birthday) > config('settings.supports.real_name.max_age')) {
|
||||||
@ -30,7 +29,6 @@ public function store(Request $request): RedirectResponse
|
|||||||
return back()->with('error', $message);
|
return back()->with('error', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
if ($user->real_name_verified_at !== null) {
|
if ($user->real_name_verified_at !== null) {
|
||||||
|
@ -15,7 +15,6 @@ class ValidateReferer
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Closure(Request): (Response|RedirectResponse) $next
|
* @param Closure(Request): (Response|RedirectResponse) $next
|
||||||
*
|
|
||||||
* @return Response|RedirectResponse
|
* @return Response|RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response|RedirectResponse
|
public function handle(Request $request, Closure $next): Response|RedirectResponse
|
||||||
|
@ -11,7 +11,6 @@ class Authenticate extends Middleware
|
|||||||
* Get the path the user should be redirected to when they are not authenticated.
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
protected function redirectTo($request): ?string
|
protected function redirectTo($request): ?string
|
||||||
|
@ -14,7 +14,6 @@ class JsonResponse
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Closure(Request): (Response|RedirectResponse) $next
|
* @param Closure(Request): (Response|RedirectResponse) $next
|
||||||
*
|
|
||||||
* @return Response|RedirectResponse|\Illuminate\Http\JsonResponse
|
* @return Response|RedirectResponse|\Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response|\Illuminate\Http\JsonResponse|RedirectResponse
|
public function handle(Request $request, Closure $next): Response|\Illuminate\Http\JsonResponse|RedirectResponse
|
||||||
|
@ -14,6 +14,6 @@ class PreventRequestsDuringMaintenance extends Middleware
|
|||||||
protected $except = [
|
protected $except = [
|
||||||
// except modules
|
// except modules
|
||||||
'admin/*',
|
'admin/*',
|
||||||
'remote/*'
|
'remote/*',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ class RealNamed
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Closure $next
|
* @param Closure $next
|
||||||
* @param string $guard
|
* @param string $guard
|
||||||
*
|
|
||||||
* @return Response|RedirectResponse|JsonResponse
|
* @return Response|RedirectResponse|JsonResponse
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next, string $guard = 'web'): Response|RedirectResponse|JsonResponse
|
public function handle(Request $request, Closure $next, string $guard = 'web'): Response|RedirectResponse|JsonResponse
|
||||||
|
@ -17,7 +17,6 @@ class RedirectIfAuthenticated
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Closure(Request): (Response|RedirectResponse) $next
|
* @param Closure(Request): (Response|RedirectResponse) $next
|
||||||
* @param string|null ...$guards
|
* @param string|null ...$guards
|
||||||
*
|
|
||||||
* @return Response|RedirectResponse
|
* @return Response|RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next, ...$guards): Response|RedirectResponse
|
public function handle(Request $request, Closure $next, ...$guards): Response|RedirectResponse
|
||||||
|
@ -15,15 +15,16 @@ class ValidateUserIfBanned
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Closure $next
|
* @param Closure $next
|
||||||
*
|
|
||||||
* @return Response|RedirectResponse|JsonResponse
|
* @return Response|RedirectResponse|JsonResponse
|
||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next): Response|RedirectResponse|JsonResponse
|
public function handle(Request $request, Closure $next): Response|RedirectResponse|JsonResponse
|
||||||
{
|
{
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
if ($user) if ($user->banned_at !== null) {
|
if ($user) {
|
||||||
|
if ($user->banned_at !== null) {
|
||||||
return redirect()->route('banned');
|
return redirect()->route('banned');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Http\Request as HttpRequest;
|
use Illuminate\Http\Request as HttpRequest;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
@ -25,7 +25,6 @@ public function authorize(): bool
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,6 @@ class WorkOrderRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
$work_order = $this->route('workOrder');
|
$work_order = $this->route('workOrder');
|
||||||
|
|
||||||
return $work_order->user_id == auth()->id();
|
return $work_order->user_id == auth()->id();
|
||||||
|
@ -15,6 +15,7 @@ class HostJob implements ShouldQueue
|
|||||||
use InteractsWithQueue, Queueable, SerializesModels;
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
public HostModel $host;
|
public HostModel $host;
|
||||||
|
|
||||||
public string $type;
|
public string $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +34,7 @@ public function __construct(HostModel $host, $type = 'post')
|
|||||||
* Execute the job.
|
* Execute the job.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
*
|
||||||
* @noinspection PhpUndefinedVariableInspection
|
* @noinspection PhpUndefinedVariableInspection
|
||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
@ -44,7 +46,6 @@ public function handle(): void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$host->load(['module']);
|
$host->load(['module']);
|
||||||
|
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
|
@ -53,7 +53,6 @@ public function handle(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
$host->save();
|
$host->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ class RealHostCostJob implements ShouldQueue
|
|||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
public Host $host;
|
public Host $host;
|
||||||
|
|
||||||
public string $price;
|
public string $price;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,6 @@ public function handle(): void
|
|||||||
$host->save();
|
$host->save();
|
||||||
}
|
}
|
||||||
// dispatch(new HostJob($host, 'delete'));
|
// dispatch(new HostJob($host, 'delete'));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
namespace App\Jobs\Module;
|
namespace App\Jobs\Module;
|
||||||
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use Exception;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class DispatchFetchModuleJob implements ShouldQueue
|
class DispatchFetchModuleJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Jobs\Module;
|
namespace App\Jobs\Module;
|
||||||
|
|
||||||
use App\Jobs\Host\UpdateOrDeleteHostJob;
|
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
@ -17,7 +16,6 @@ class FetchModuleJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
protected Module $module;
|
protected Module $module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,6 +43,7 @@ public function handle(): void
|
|||||||
$response = $module->http()->get('remote');
|
$response = $module->http()->get('remote');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,13 +67,12 @@ public function handle(): void
|
|||||||
'module' => [
|
'module' => [
|
||||||
'id' => $module->id,
|
'id' => $module->id,
|
||||||
'name' => $module->name,
|
'name' => $module->name,
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}, $json['servers']));
|
}, $json['servers']));
|
||||||
|
|
||||||
// broadcast(new Servers($servers));
|
// broadcast(new Servers($servers));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if module return maintenance, then set module status to maintenance
|
// if module return maintenance, then set module status to maintenance
|
||||||
$status = $response->status();
|
$status = $response->status();
|
||||||
@ -93,6 +91,5 @@ public function handle(): void
|
|||||||
} else {
|
} else {
|
||||||
Cache::put('module:'.$module->id.':servers', $servers, now()->addMinutes(10));
|
Cache::put('module:'.$module->id.':servers', $servers, now()->addMinutes(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ public function handle(): void
|
|||||||
$this->send($module);
|
$this->send($module);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function send(Module $module): void
|
private function send(Module $module): void
|
||||||
@ -45,7 +44,6 @@ private function send(Module $module): void
|
|||||||
// make wecom_key visible
|
// make wecom_key visible
|
||||||
$wecom_key = $module->wecom_key ?? config('settings.wecom.robot_hook.billing');
|
$wecom_key = $module->wecom_key ?? config('settings.wecom.robot_hook.billing');
|
||||||
|
|
||||||
|
|
||||||
$text = "# $module->name 收益";
|
$text = "# $module->name 收益";
|
||||||
foreach ($data as $year => $months) {
|
foreach ($data as $year => $months) {
|
||||||
// 排序 months 从小到大
|
// 排序 months 从小到大
|
||||||
@ -68,7 +66,6 @@ private function send(Module $module): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$resp = Http::post('https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key='.$wecom_key, [
|
$resp = Http::post('https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key='.$wecom_key, [
|
||||||
'msgtype' => 'markdown',
|
'msgtype' => 'markdown',
|
||||||
'markdown' => [
|
'markdown' => [
|
||||||
@ -76,7 +73,6 @@ private function send(Module $module): void
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
if ($resp->failed()) {
|
if ($resp->failed()) {
|
||||||
Log::error('发送模块盈利到企业微信时失败', [
|
Log::error('发送模块盈利到企业微信时失败', [
|
||||||
'module' => $module->id,
|
'module' => $module->id,
|
||||||
|
@ -15,7 +15,10 @@ class EMQXKickClientJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected string|null $client_id, $username;
|
protected string|null $client_id;
|
||||||
|
|
||||||
|
protected string|null $username;
|
||||||
|
|
||||||
protected bool $like_username;
|
protected bool $like_username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,10 +56,10 @@ public function handle(): void
|
|||||||
$clients = $emqx->clients([$query => $this->username]);
|
$clients = $emqx->clients([$query => $this->username]);
|
||||||
} catch (EmqxSupportException $e) {
|
} catch (EmqxSupportException $e) {
|
||||||
Log::error('emqx connect failed.', [$e]);
|
Log::error('emqx connect failed.', [$e]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($clients) {
|
if ($clients) {
|
||||||
if (count($clients['data']) > 0) {
|
if (count($clients['data']) > 0) {
|
||||||
foreach ($clients['data'] as $client) {
|
foreach ($clients['data'] as $client) {
|
||||||
@ -65,7 +68,6 @@ public function handle(): void
|
|||||||
|
|
||||||
dispatch(new self(null, $this->username, $this->like_username));
|
dispatch(new self(null, $this->username, $this->like_username));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ public function handle(): void
|
|||||||
|
|
||||||
public function checkAndCharge(Balance $balance, $check = false): bool
|
public function checkAndCharge(Balance $balance, $check = false): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($check) {
|
if ($check) {
|
||||||
try {
|
try {
|
||||||
$alipay = Pay::alipay()->find(['out_trade_no' => $balance->order_id]);
|
$alipay = Pay::alipay()->find(['out_trade_no' => $balance->order_id]);
|
||||||
@ -62,7 +61,7 @@ public function checkAndCharge(Balance $balance, $check = false): bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
$balance->update([
|
$balance->update([
|
||||||
'paid_at' => now()
|
'paid_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -17,8 +17,13 @@ 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;
|
||||||
|
|
||||||
|
protected string $content;
|
||||||
|
|
||||||
protected bool $send_mail;
|
protected bool $send_mail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,9 +73,7 @@ public function handle(): void
|
|||||||
$workOrder->status = 'error';
|
$workOrder->status = 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$workOrder->save();
|
$workOrder->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -84,6 +82,5 @@ public function handle(): void
|
|||||||
dispatch(new Reply($reply));
|
dispatch(new Reply($reply));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ class Reply implements ShouldQueue
|
|||||||
use InteractsWithQueue, Queueable, SerializesModels;
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected WorkOrderReply $reply;
|
protected WorkOrderReply $reply;
|
||||||
|
|
||||||
protected string $type;
|
protected string $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,20 +51,18 @@ public function handle(): void
|
|||||||
|
|
||||||
if ($response->successful()) {
|
if ($response->successful()) {
|
||||||
$this->reply->update([
|
$this->reply->update([
|
||||||
'is_pending' => false
|
'is_pending' => false,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$this->reply->update([
|
$this->reply->update([
|
||||||
'is_pending' => true
|
'is_pending' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($this->type == 'patch') {
|
} elseif ($this->type == 'patch') {
|
||||||
|
|
||||||
// 不更新 is_pending
|
// 不更新 is_pending
|
||||||
if ($this->reply->workOrder->isPlatform()) {
|
if ($this->reply->workOrder->isPlatform()) {
|
||||||
$this->reply->update([
|
$this->reply->update([
|
||||||
'is_pending' => false
|
'is_pending' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -79,4 +78,3 @@ public function handle(): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ class WorkOrder implements ShouldQueue
|
|||||||
use InteractsWithQueue, Queueable, SerializesModels;
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
protected WorkOrderModel $workOrder;
|
protected WorkOrderModel $workOrder;
|
||||||
|
|
||||||
protected string $type;
|
protected string $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +45,6 @@ public function handle(): void
|
|||||||
$this->type = 'post';
|
$this->type = 'post';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($this->type == 'post') {
|
if ($this->type == 'post') {
|
||||||
$response = $this->workOrder->module->http()->post('work-orders', $this->workOrder->toArray());
|
$response = $this->workOrder->module->http()->post('work-orders', $this->workOrder->toArray());
|
||||||
} elseif ($this->type == 'put') {
|
} elseif ($this->type == 'put') {
|
||||||
@ -65,7 +65,7 @@ public function handle(): void
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->workOrder->update([
|
$this->workOrder->update([
|
||||||
'status' => 'error'
|
'status' => 'error',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
use App\Events\Users;
|
use App\Events\Users;
|
||||||
use App\Notifications\User\UserCharged;
|
use App\Notifications\User\UserCharged;
|
||||||
|
use function auth;
|
||||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use function auth;
|
|
||||||
|
|
||||||
class Balance extends Model
|
class Balance extends Model
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ class Balance extends Model
|
|||||||
'amount',
|
'amount',
|
||||||
'user_id',
|
'user_id',
|
||||||
'paid_at',
|
'paid_at',
|
||||||
'trade_id'
|
'trade_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
@ -57,7 +57,6 @@ protected static function boot()
|
|||||||
$model->user->notify(new WebNotification($model, 'hosts.created'));
|
$model->user->notify(new WebNotification($model, 'hosts.created'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
static::updating(function (self $model) {
|
static::updating(function (self $model) {
|
||||||
if ($model->isDirty('status')) {
|
if ($model->isDirty('status')) {
|
||||||
if ($model->status == 'suspended') {
|
if ($model->status == 'suspended') {
|
||||||
@ -131,7 +130,6 @@ public function module(): BelongsToAlias
|
|||||||
// return $this->hasMany(WorkOrder::class);
|
// return $this->hasMany(WorkOrder::class);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
public function getPrice(): float
|
public function getPrice(): float
|
||||||
{
|
{
|
||||||
return $this->managed_price ?? $this->price;
|
return $this->managed_price ?? $this->price;
|
||||||
@ -162,6 +160,7 @@ public function safeDelete(): bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch(new HostJob($this, 'delete'));
|
dispatch(new HostJob($this, 'delete'));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +188,7 @@ public function cost(string $amount = null, $auto = true): bool
|
|||||||
$append_description = '';
|
$append_description = '';
|
||||||
if ($user_group) {
|
if ($user_group) {
|
||||||
if ($user_group->discount !== 100 && $user_group->discount !== null) {
|
if ($user_group->discount !== 100 && $user_group->discount !== null) {
|
||||||
$real_price = bcmul($real_price, bcdiv($user_group->discount, "100", 4), 4);
|
$real_price = bcmul($real_price, bcdiv($user_group->discount, '100', 4), 4);
|
||||||
|
|
||||||
$append_description = ' (折扣 '.$user_group->discount.'%)';
|
$append_description = ' (折扣 '.$user_group->discount.'%)';
|
||||||
}
|
}
|
||||||
@ -206,6 +205,7 @@ public function cost(string $amount = null, $auto = true): bool
|
|||||||
|
|
||||||
if ($real_price == 0) {
|
if ($real_price == 0) {
|
||||||
echo '价格为 0,不扣费';
|
echo '价格为 0,不扣费';
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,9 +262,9 @@ public function cost(string $amount = null, $auto = true): bool
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addLog(string $amount = "0"): bool
|
public function addLog(string $amount = '0'): bool
|
||||||
{
|
{
|
||||||
if ($amount === "0") {
|
if ($amount === '0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,19 +21,20 @@ class Module extends Authenticatable
|
|||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
protected $table = 'modules';
|
protected $table = 'modules';
|
||||||
|
|
||||||
protected $keyType = 'string';
|
protected $keyType = 'string';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'api_token'
|
'api_token',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
'api_token',
|
'api_token',
|
||||||
'wecom_key',
|
'wecom_key',
|
||||||
'balance',
|
'balance',
|
||||||
'url'
|
'url',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
@ -66,7 +67,6 @@ protected static function boot()
|
|||||||
// return $this->getResponse($response);
|
// return $this->getResponse($response);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// post, get, patch, delete 等请求
|
// post, get, patch, delete 等请求
|
||||||
public function remote($func, $requests): array
|
public function remote($func, $requests): array
|
||||||
{
|
{
|
||||||
@ -141,7 +141,7 @@ public function moduleRequest($method, $path, $requests): array
|
|||||||
$module_id = auth('module')->id();
|
$module_id = auth('module')->id();
|
||||||
|
|
||||||
$http = $this->http()->withHeaders([
|
$http = $this->http()->withHeaders([
|
||||||
'X-Module' => $module_id
|
'X-Module' => $module_id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$requests['module_id'] = $module_id;
|
$requests['module_id'] = $module_id;
|
||||||
@ -175,14 +175,14 @@ public function check(): bool
|
|||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ArrayShape(['transactions' => "array"])]
|
#[ArrayShape(['transactions' => 'array'])]
|
||||||
public function calculate(): array
|
public function calculate(): array
|
||||||
{
|
{
|
||||||
$cache_key = 'module_earning_'.$this->id;
|
$cache_key = 'module_earning_'.$this->id;
|
||||||
|
|
||||||
return Cache::get($cache_key, []);
|
return Cache::get($cache_key, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扣除费用
|
* 扣除费用
|
||||||
*
|
*
|
||||||
@ -190,10 +190,9 @@ public function calculate(): array
|
|||||||
* @param string|null $description
|
* @param string|null $description
|
||||||
* @param bool $fail
|
* @param bool $fail
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function reduce(string|null $amount = "0", string|null $description = "消费", bool $fail = false, array $options = []): string
|
public function reduce(string|null $amount = '0', string|null $description = '消费', bool $fail = false, array $options = []): string
|
||||||
{
|
{
|
||||||
if ($amount === null || $amount === '') {
|
if ($amount === null || $amount === '') {
|
||||||
return $this->balance;
|
return $this->balance;
|
||||||
@ -225,9 +224,7 @@ public function reduce(string|null $amount = "0", string|null $description = "
|
|||||||
}
|
}
|
||||||
|
|
||||||
(new Transaction)->create($data);
|
(new Transaction)->create($data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this->balance;
|
return $this->balance;
|
||||||
@ -240,10 +237,9 @@ public function reduce(string|null $amount = "0", string|null $description = "
|
|||||||
* @param string $payment
|
* @param string $payment
|
||||||
* @param string|null $description
|
* @param string|null $description
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function charge(string|null $amount = "0", string $payment = 'console', string|null $description = '充值', array $options = []): string
|
public function charge(string|null $amount = '0', string $payment = 'console', string|null $description = '充值', array $options = []): string
|
||||||
{
|
{
|
||||||
if ($amount === null || $amount === '') {
|
if ($amount === null || $amount === '') {
|
||||||
return $this->balance;
|
return $this->balance;
|
||||||
@ -271,8 +267,6 @@ public function charge(string|null $amount = "0", string $payment = 'console', s
|
|||||||
|
|
||||||
(new Transaction)->create($data);
|
(new Transaction)->create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $this->balance;
|
return $this->balance;
|
||||||
|
@ -17,7 +17,6 @@ class PersonalAccessToken extends SanctumPersonalAccessToken
|
|||||||
* since we aren't going to use that column for anything.
|
* since we aren't going to use that column for anything.
|
||||||
*
|
*
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function save(array $options = []): bool
|
public function save(array $options = []): bool
|
||||||
@ -27,6 +26,7 @@ public function save(array $options = []): bool
|
|||||||
if (! array_key_exists('last_used_at', $changes) || count($changes) > 2) {
|
if (! array_key_exists('last_used_at', $changes) || count($changes) > 2) {
|
||||||
parent::save();
|
parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,23 @@
|
|||||||
|
|
||||||
use App\Events\Users;
|
use App\Events\Users;
|
||||||
use App\Exceptions\CommonException;
|
use App\Exceptions\CommonException;
|
||||||
|
use function auth;
|
||||||
|
use function broadcast;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use function auth;
|
|
||||||
use function broadcast;
|
|
||||||
|
|
||||||
class Task extends Model
|
class Task extends Model
|
||||||
{
|
{
|
||||||
public $incrementing = false;
|
public $incrementing = false;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'host_id',
|
'host_id',
|
||||||
'title',
|
'title',
|
||||||
'progress',
|
'progress',
|
||||||
'status',
|
'status',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'id' => 'string',
|
'id' => 'string',
|
||||||
'progress' => 'integer',
|
'progress' => 'integer',
|
||||||
@ -75,7 +77,6 @@ protected static function boot()
|
|||||||
broadcast(new Users($model->user_id, 'tasks.updated', $model));
|
broadcast(new Users($model->user_id, 'tasks.updated', $model));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
static::deleted(function (self $model) {
|
static::deleted(function (self $model) {
|
||||||
broadcast(new Users($model->user_id, 'tasks.deleted', $model));
|
broadcast(new Users($model->user_id, 'tasks.deleted', $model));
|
||||||
});
|
});
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
class Transaction extends Model
|
class Transaction extends Model
|
||||||
{
|
{
|
||||||
const UPDATED_AT = null;
|
const UPDATED_AT = null;
|
||||||
|
|
||||||
protected $connection = 'mongodb';
|
protected $connection = 'mongodb';
|
||||||
|
|
||||||
// 停用 updated_at
|
// 停用 updated_at
|
||||||
protected $collection = 'transactions';
|
protected $collection = 'transactions';
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
'created_at',
|
'created_at',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
|
@ -23,6 +23,14 @@ class User extends Authenticatable
|
|||||||
{
|
{
|
||||||
use HasApiTokens, HasFactory, Notifiable, Cachable;
|
use HasApiTokens, HasFactory, Notifiable, Cachable;
|
||||||
|
|
||||||
|
public array $publics = [
|
||||||
|
'id',
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'real_name',
|
||||||
|
'balance',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
@ -52,7 +60,7 @@ class User extends Authenticatable
|
|||||||
'real_name_verified_at' => 'datetime',
|
'real_name_verified_at' => 'datetime',
|
||||||
'balance' => 'decimal:4',
|
'balance' => 'decimal:4',
|
||||||
'banned_at' => 'datetime',
|
'banned_at' => 'datetime',
|
||||||
'birthday_at' => 'date:Y-m-d'
|
'birthday_at' => 'date:Y-m-d',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
@ -62,14 +70,6 @@ class User extends Authenticatable
|
|||||||
'birthday_at',
|
'birthday_at',
|
||||||
];
|
];
|
||||||
|
|
||||||
public array $publics = [
|
|
||||||
'id',
|
|
||||||
'name',
|
|
||||||
'email',
|
|
||||||
'real_name',
|
|
||||||
'balance',
|
|
||||||
];
|
|
||||||
|
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
@ -96,7 +96,8 @@ protected static function boot()
|
|||||||
$user->id_card = Crypt::encryptString($user->id_card);
|
$user->id_card = Crypt::encryptString($user->id_card);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->isDirty('id_card') || $user->isDirty('real_name')) if (empty($user->id_card) || empty($user->real_name)) {
|
if ($user->isDirty('id_card') || $user->isDirty('real_name')) {
|
||||||
|
if (empty($user->id_card) || empty($user->real_name)) {
|
||||||
$user->real_name_verified_at = null;
|
$user->real_name_verified_at = null;
|
||||||
} else {
|
} else {
|
||||||
$user->real_name_verified_at = now();
|
$user->real_name_verified_at = now();
|
||||||
@ -108,7 +109,7 @@ protected static function boot()
|
|||||||
$user->birthday_at = null;
|
$user->birthday_at = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +130,7 @@ private function getBirthdayFromIdCard(): string
|
|||||||
return $year.'-'.$month.'-'.$day;
|
return $year.'-'.$month.'-'.$day;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasBalance(string $amount = "0.01"): bool
|
public function hasBalance(string $amount = '0.01'): bool
|
||||||
{
|
{
|
||||||
return bccomp($this->balance, $amount, 4) >= 0;
|
return bccomp($this->balance, $amount, 4) >= 0;
|
||||||
}
|
}
|
||||||
@ -187,10 +188,9 @@ public function startTransfer(self $to, string $amount, string|null $description
|
|||||||
* @param string $description
|
* @param string $description
|
||||||
* @param bool $fail
|
* @param bool $fail
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function reduce(string|null $amount = "0", string $description = "消费", bool $fail = false, array $options = []): string
|
public function reduce(string|null $amount = '0', string $description = '消费', bool $fail = false, array $options = []): string
|
||||||
{
|
{
|
||||||
if ($amount === null || $amount === '') {
|
if ($amount === null || $amount === '') {
|
||||||
return $this->balance;
|
return $this->balance;
|
||||||
@ -233,10 +233,9 @@ public function reduce(string|null $amount = "0", string $description = "消费"
|
|||||||
* @param string $payment
|
* @param string $payment
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function charge(string|null $amount = "0", string $payment = 'console', string $description = '充值', array $options = []): string
|
public function charge(string|null $amount = '0', string $payment = 'console', string $description = '充值', array $options = []): string
|
||||||
{
|
{
|
||||||
if ($amount === null || $amount === '') {
|
if ($amount === null || $amount === '') {
|
||||||
return $this->balance;
|
return $this->balance;
|
||||||
|
@ -29,14 +29,12 @@ public function users(): HasMany
|
|||||||
return $this->hasMany(User::class);
|
return $this->hasMany(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置临时用户组
|
* 设置临时用户组
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param UserGroup $group
|
* @param UserGroup $group
|
||||||
* @param Carbon $expired_at
|
* @param Carbon $expired_at
|
||||||
*
|
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function setTempGroup(User $user, self $group, Carbon $expired_at): User
|
public function setTempGroup(User $user, self $group, Carbon $expired_at): User
|
||||||
@ -62,5 +60,4 @@ public function setTempGroup(User $user, self $group, Carbon $expired_at): User
|
|||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class Reply extends Model
|
|||||||
'name',
|
'name',
|
||||||
'module_id',
|
'module_id',
|
||||||
'is_pending',
|
'is_pending',
|
||||||
'role'
|
'role',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@ -46,24 +46,20 @@ protected static function boot()
|
|||||||
|
|
||||||
throw_if($model->workOrder->isFailure(), CommonException::class, '工单还没有就绪。');
|
throw_if($model->workOrder->isFailure(), CommonException::class, '工单还没有就绪。');
|
||||||
|
|
||||||
|
|
||||||
// change work order status
|
// change work order status
|
||||||
if (auth('admin')->check()) {
|
if (auth('admin')->check()) {
|
||||||
$model->role = 'admin';
|
$model->role = 'admin';
|
||||||
$model->workOrder->status = 'replied';
|
$model->workOrder->status = 'replied';
|
||||||
|
|
||||||
} elseif (auth('sanctum')->check()) {
|
} elseif (auth('sanctum')->check()) {
|
||||||
$model->user_id = auth('sanctum')->id();
|
$model->user_id = auth('sanctum')->id();
|
||||||
$model->role = 'user';
|
$model->role = 'user';
|
||||||
$model->workOrder->status = 'user_replied';
|
$model->workOrder->status = 'user_replied';
|
||||||
|
|
||||||
} elseif (auth('module')->check()) {
|
} elseif (auth('module')->check()) {
|
||||||
$model->user_id = null;
|
$model->user_id = null;
|
||||||
$model->role = 'module';
|
$model->role = 'module';
|
||||||
$model->workOrder->status = 'replied';
|
$model->workOrder->status = 'replied';
|
||||||
|
|
||||||
broadcast(new Users($model->user, 'work-order.replied', $model->workOrder));
|
broadcast(new Users($model->user, 'work-order.replied', $model->workOrder));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$model->role = 'guest';
|
$model->role = 'guest';
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class WorkOrder extends Model
|
|||||||
'user_id',
|
'user_id',
|
||||||
'module_id',
|
'module_id',
|
||||||
'status',
|
'status',
|
||||||
'notify'
|
'notify',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@ -36,7 +36,7 @@ class WorkOrder extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'notify' => 'boolean'
|
'notify' => 'boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
|
@ -16,7 +16,6 @@ class WeComChannel extends Notification
|
|||||||
*
|
*
|
||||||
* @param mixed $notifiable
|
* @param mixed $notifiable
|
||||||
* @param Notification $notification
|
* @param Notification $notification
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function send(mixed $notifiable, Notification $notification): void
|
public function send(mixed $notifiable, Notification $notification): void
|
||||||
|
@ -16,7 +16,6 @@ class WebChannel extends Notification
|
|||||||
*
|
*
|
||||||
* @param mixed $notifiable
|
* @param mixed $notifiable
|
||||||
* @param Notification $notification
|
* @param Notification $notification
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function send(mixed $notifiable, Notification $notification): void
|
public function send(mixed $notifiable, Notification $notification): void
|
||||||
|
@ -43,24 +43,23 @@ public function toMail(): MailMessage
|
|||||||
{
|
{
|
||||||
$url = URL::format(config('settings.dashboard.base_url'), config('settings.dashboard.birthday_path'));
|
$url = URL::format(config('settings.dashboard.base_url'), config('settings.dashboard.birthday_path'));
|
||||||
|
|
||||||
|
|
||||||
$lyrics = [
|
$lyrics = [
|
||||||
[
|
[
|
||||||
"Happy Birthday",
|
'Happy Birthday',
|
||||||
"好想把我的心意传达给你。"
|
'好想把我的心意传达给你。',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'今天祝你生日快乐!',
|
'今天祝你生日快乐!',
|
||||||
'这是第几次呢 假装忘记了(实际上)。',
|
'这是第几次呢 假装忘记了(实际上)。',
|
||||||
'心里很清楚 只是在装傻。'
|
'心里很清楚 只是在装傻。',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'今天祝你生日快乐!',
|
'今天祝你生日快乐!',
|
||||||
'蛋糕上的蜡烛要立几根好呢。连备用的都一起买好了!'
|
'蛋糕上的蜡烛要立几根好呢。连备用的都一起买好了!',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'Happy Birthday!',
|
'Happy Birthday!',
|
||||||
'人与人的相遇真是不可思议。'
|
'人与人的相遇真是不可思议。',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'你知道吗?',
|
'你知道吗?',
|
||||||
@ -68,7 +67,7 @@ public function toMail(): MailMessage
|
|||||||
'会不会太迟了呢?我喜欢你,还会更喜欢你。',
|
'会不会太迟了呢?我喜欢你,还会更喜欢你。',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'即使以心传心但也一定有着极限的。所以要好好地说出来。'
|
'即使以心传心但也一定有着极限的。所以要好好地说出来。',
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@ -47,8 +47,7 @@ public function toWeCom(Balance $notifiable): array
|
|||||||
'data' => [
|
'data' => [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'balance' => $notifiable,
|
'balance' => $notifiable,
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,9 @@ class UserNotification extends Notification implements ShouldQueue
|
|||||||
use Queueable;
|
use Queueable;
|
||||||
|
|
||||||
public string $title;
|
public string $title;
|
||||||
|
|
||||||
public string $content;
|
public string $content;
|
||||||
|
|
||||||
public bool $send_mail;
|
public bool $send_mail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,6 @@ public function __construct(WorkOrderModel $work_order)
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param WorkOrderModel $workOrder
|
* @param WorkOrderModel $workOrder
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function via(WorkOrderModel $workOrder): array
|
public function via(WorkOrderModel $workOrder): array
|
||||||
@ -50,7 +49,6 @@ public function via(WorkOrderModel $workOrder): array
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param WorkOrderModel $workOrder
|
* @param WorkOrderModel $workOrder
|
||||||
*
|
|
||||||
* @return MailMessage
|
* @return MailMessage
|
||||||
*/
|
*/
|
||||||
public function toMail(WorkOrderModel $workOrder): MailMessage
|
public function toMail(WorkOrderModel $workOrder): MailMessage
|
||||||
@ -66,7 +64,6 @@ public function toMail(WorkOrderModel $workOrder): MailMessage
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param WorkOrderModel $workOrder
|
* @param WorkOrderModel $workOrder
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray(WorkOrderModel $workOrder): array
|
public function toArray(WorkOrderModel $workOrder): array
|
||||||
@ -88,7 +85,6 @@ public function toWeCom(WorkOrderModel $workOrder): false|array
|
|||||||
|
|
||||||
// 取消隐藏字段
|
// 取消隐藏字段
|
||||||
$module->makeVisible(['wecom_key']);
|
$module->makeVisible(['wecom_key']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($module?->wecom_key == null) {
|
if ($module?->wecom_key == null) {
|
||||||
@ -100,7 +96,7 @@ public function toWeCom(WorkOrderModel $workOrder): false|array
|
|||||||
return [
|
return [
|
||||||
'key' => $wecom_key,
|
'key' => $wecom_key,
|
||||||
'view' => 'notifications.work_order',
|
'view' => 'notifications.work_order',
|
||||||
'data' => $workOrder
|
'data' => $workOrder,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,5 +104,4 @@ public function toWeCom(WorkOrderModel $workOrder): false|array
|
|||||||
// {
|
// {
|
||||||
// return new BroadcastMessage($workOrder->toArray());
|
// return new BroadcastMessage($workOrder->toArray());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ class WorkOrderPolicy
|
|||||||
*
|
*
|
||||||
* @param User|Module $user
|
* @param User|Module $user
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return Response|bool
|
* @return Response|bool
|
||||||
*/
|
*/
|
||||||
public function view(User|Module $user, WorkOrder $workOrder): Response|bool
|
public function view(User|Module $user, WorkOrder $workOrder): Response|bool
|
||||||
@ -34,7 +33,6 @@ public function view(User|Module $user, WorkOrder $workOrder): Response|bool
|
|||||||
*
|
*
|
||||||
* @param User|Module $user
|
* @param User|Module $user
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return Response|bool
|
* @return Response|bool
|
||||||
*/
|
*/
|
||||||
public function update(User|Module $user, WorkOrder $workOrder): Response|bool
|
public function update(User|Module $user, WorkOrder $workOrder): Response|bool
|
||||||
@ -51,7 +49,6 @@ public function update(User|Module $user, WorkOrder $workOrder): Response|bool
|
|||||||
*
|
*
|
||||||
* @param User|Module $user
|
* @param User|Module $user
|
||||||
* @param WorkOrder $workOrder
|
* @param WorkOrder $workOrder
|
||||||
*
|
|
||||||
* @return Response|bool
|
* @return Response|bool
|
||||||
*/
|
*/
|
||||||
public function delete(User|Module $user, WorkOrder $workOrder): Response|bool
|
public function delete(User|Module $user, WorkOrder $workOrder): Response|bool
|
||||||
|
@ -18,7 +18,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,9 +44,7 @@ public function boot(): void
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Carbon setTestNow
|
// Carbon setTestNow
|
||||||
// Carbon::setTestNow(now()->addDays(1));
|
// Carbon::setTestNow(now()->addDays(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
class ClusterSupport
|
class ClusterSupport
|
||||||
{
|
{
|
||||||
|
|
||||||
public static string $prefix = 'cluster:';
|
public static string $prefix = 'cluster:';
|
||||||
|
|
||||||
public static function isCluster(): bool
|
public static function isCluster(): bool
|
||||||
@ -68,7 +67,6 @@ public static function hset($key, $value, $data = []): void
|
|||||||
* @param string|array $events 事件名称
|
* @param string|array $events 事件名称
|
||||||
* @param $callback callable 回调函数,接收一个参数,为事件数据。
|
* @param $callback callable 回调函数,接收一个参数,为事件数据。
|
||||||
* @param $ignore_self bool 是否忽略此节点的消息。
|
* @param $ignore_self bool 是否忽略此节点的消息。
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function listen(string|array $events, callable $callback, bool $ignore_self = true): void
|
public static function listen(string|array $events, callable $callback, bool $ignore_self = true): void
|
||||||
|
@ -39,32 +39,6 @@ public function api(): PendingRequest
|
|||||||
return Http::baseUrl(config('emqx.api_url'))->withBasicAuth(config('emqx.api_key'), config('emqx.api_secret'));
|
return Http::baseUrl(config('emqx.api_url'))->withBasicAuth(config('emqx.api_key'), config('emqx.api_secret'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws EmqxSupportException
|
|
||||||
*/
|
|
||||||
public function clients($params = [])
|
|
||||||
{
|
|
||||||
// merge params
|
|
||||||
$params = array_merge([
|
|
||||||
'limit' => $this->limit_per_page,
|
|
||||||
'isTrusted' => true,
|
|
||||||
], $params);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$response = $this->api()->get('clients', $params);
|
|
||||||
} /** @noinspection PhpRedundantCatchClauseInspection */ catch (ConnectionException $e) {
|
|
||||||
Log::error('emqx connect failed.', [$e]);
|
|
||||||
throw new EmqxSupportException('EMQX API 无法连接。' . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($response->successful()) {
|
|
||||||
return $response->json();
|
|
||||||
} else {
|
|
||||||
throw new EmqxSupportException('无法获取客户端列表。');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws EmqxSupportException
|
* @throws EmqxSupportException
|
||||||
*/
|
*/
|
||||||
@ -99,4 +73,29 @@ public function pagination($params = []): LengthAwarePaginator
|
|||||||
'path' => route('admin.devices.index'),
|
'path' => route('admin.devices.index'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws EmqxSupportException
|
||||||
|
*/
|
||||||
|
public function clients($params = [])
|
||||||
|
{
|
||||||
|
// merge params
|
||||||
|
$params = array_merge([
|
||||||
|
'limit' => $this->limit_per_page,
|
||||||
|
'isTrusted' => true,
|
||||||
|
], $params);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $this->api()->get('clients', $params);
|
||||||
|
} /** @noinspection PhpRedundantCatchClauseInspection */ catch (ConnectionException $e) {
|
||||||
|
Log::error('emqx connect failed.', [$e]);
|
||||||
|
throw new EmqxSupportException('EMQX API 无法连接。'.$e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return $response->json();
|
||||||
|
} else {
|
||||||
|
throw new EmqxSupportException('无法获取客户端列表。');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
*/
|
*/
|
||||||
class RealNameSupport
|
class RealNameSupport
|
||||||
{
|
{
|
||||||
|
|
||||||
private string $url = 'https://faceidh5.market.alicloudapi.com';
|
private string $url = 'https://faceidh5.market.alicloudapi.com';
|
||||||
|
|
||||||
private string $app_code;
|
private string $app_code;
|
||||||
|
|
||||||
private PendingRequest $http;
|
private PendingRequest $http;
|
||||||
@ -36,7 +36,6 @@ public function __construct()
|
|||||||
* @param $user_id
|
* @param $user_id
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param $id_card
|
* @param $id_card
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function create($user_id, $name, $id_card): string
|
public function create($user_id, $name, $id_card): string
|
||||||
@ -57,7 +56,6 @@ public function create($user_id, $name, $id_card): string
|
|||||||
/** 向 实名认证服务 发送请求
|
/** 向 实名认证服务 发送请求
|
||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function submit(string $id): string
|
private function submit(string $id): string
|
||||||
@ -98,7 +96,6 @@ private function submit(string $id): string
|
|||||||
* 验证实名认证请求
|
* 验证实名认证请求
|
||||||
*
|
*
|
||||||
* @param array $request
|
* @param array $request
|
||||||
*
|
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
public function verify(array $request): array|bool
|
public function verify(array $request): array|bool
|
||||||
@ -111,6 +108,7 @@ public function verify(array $request): array|bool
|
|||||||
|
|
||||||
if (! $verify) {
|
if (! $verify) {
|
||||||
Log::debug('实名认证签名验证失败', $request);
|
Log::debug('实名认证签名验证失败', $request);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +125,7 @@ public function verify(array $request): array|bool
|
|||||||
|
|
||||||
private function verifyIfSuccess(string $request, string $sign): bool
|
private function verifyIfSuccess(string $request, string $sign): bool
|
||||||
{
|
{
|
||||||
|
$public_key = <<<'EOF'
|
||||||
$public_key = <<<EOF
|
|
||||||
-----BEGIN PUBLIC KEY-----
|
-----BEGIN PUBLIC KEY-----
|
||||||
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWKKJoLwh6XEBkTeCfVbKSB3zkkycbIdd8SBabj2jpWynXx0pBZvdFpbb9AEiyrnM8bImhpz8YOXc2yUuN1ui/w==
|
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWKKJoLwh6XEBkTeCfVbKSB3zkkycbIdd8SBabj2jpWynXx0pBZvdFpbb9AEiyrnM8bImhpz8YOXc2yUuN1ui/w==
|
||||||
-----END PUBLIC KEY-----
|
-----END PUBLIC KEY-----
|
||||||
@ -155,5 +152,4 @@ public function getBirthday(string $id_card): string
|
|||||||
|
|
||||||
return $year.'-'.$month.'-'.$day;
|
return $year.'-'.$month.'-'.$day;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
class BasicCard extends Component
|
class BasicCard extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
public string $title;
|
public string $title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,7 @@ public function __construct(Module $module)
|
|||||||
public function render(): View
|
public function render(): View
|
||||||
{
|
{
|
||||||
$years = $this->module->calculate();
|
$years = $this->module->calculate();
|
||||||
|
|
||||||
return view('components.module-earning', compact('years'));
|
return view('components.module-earning', compact('years'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ public function __construct()
|
|||||||
public function render(): View
|
public function render(): View
|
||||||
{
|
{
|
||||||
$modules = Module::all();
|
$modules = Module::all();
|
||||||
|
|
||||||
return view('components.module-script', compact('modules'));
|
return view('components.module-script', compact('modules'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ public function __construct(string|null $payment)
|
|||||||
*/
|
*/
|
||||||
public function render(): View
|
public function render(): View
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->payment = match ($this->payment) {
|
$this->payment = match ($this->payment) {
|
||||||
'alipay' => '支付宝',
|
'alipay' => '支付宝',
|
||||||
'wechat', 'wepay' => '微信支付',
|
'wechat', 'wepay' => '微信支付',
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
'driver' => 'api'
|
'driver' => 'api',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -109,6 +109,6 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'prefix' => 'laev3_cache'
|
'prefix' => 'laev3_cache',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
$cors_origin = ['*'];
|
$cors_origin = ['*'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user