15061959991 1adf627c0d feat: 财务系统二次开发 - 营销账户账单功能
- 基础环境:Docker 部署配置,源码挂载实时同步
- 修复:super_admin 权限补全、登录重定向循环
- 开发:店铺营销账户账单 - 抖音账户(15字段汇总账单)
- 开发:店铺营销账户账单 - 淘系支付宝账户(8字段流水账单)
- 开发:店铺营销账户账单 - 拼多多账户(7字段流水账单)
- 业务页面导航集成:config/business_navigation.php + Business\Pages 控制器
- 各平台独立表结构和视图,互不影响
2026-07-21 18:43:52 +08:00

87 lines
2.0 KiB
PHP

<?php
namespace App\Abstracts\Commands;
use App\Models\Module\Module as Model;
use App\Models\Module\ModuleHistory as ModelHistory;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use Symfony\Component\Console\Input\InputArgument;
abstract class Module extends Command
{
public string $alias;
public int $company_id;
public string $locale;
public object|null $model;
public int|null $old_company_id;
protected function prepare()
{
$this->alias = Str::kebab($this->argument('alias'));
$this->company_id = (int) $this->argument('company');
$this->locale = $this->argument('locale');
}
protected function changeRuntime()
{
$this->old_company_id = company_id();
company($this->company_id)->makeCurrent();
app()->setLocale($this->locale);
// Disable model cache
config(['laravel-model-caching.enabled' => false]);
}
protected function revertRuntime()
{
if (empty($this->old_company_id)) {
return;
}
company($this->old_company_id)->makeCurrent();
}
protected function getModel()
{
$this->model = Model::companyId($this->company_id)->alias($this->alias)->first();
return $this->model;
}
protected function createHistory($action)
{
if (empty($this->model)) {
return;
}
ModelHistory::create([
'company_id' => $this->company_id,
'module_id' => $this->model->id,
'version' => module($this->alias)->get('version'),
'description' => trans('modules.' . $action, ['module' => $this->alias]),
'created_from' => source_name(),
'created_by' => user_id(),
]);
}
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['alias', InputArgument::REQUIRED, 'Module alias.'],
['company', InputArgument::REQUIRED, 'Company ID.'],
];
}
}