36 lines
1019 B
PHP
36 lines
1019 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Modules\EcommerceFinance\Services\FinanceLedgerCalculator;
|
|
use Throwable;
|
|
|
|
class RecalculateFinanceLedger extends Command
|
|
{
|
|
protected $signature = 'finance-ledger:recalculate';
|
|
|
|
protected $description = '重算财务台账的每日资金流水、账户余额和店铺余额';
|
|
|
|
public function handle(FinanceLedgerCalculator $calculator): int
|
|
{
|
|
try {
|
|
$result = $calculator->recalculate();
|
|
} catch (Throwable $exception) {
|
|
$this->error($exception->getMessage());
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->table(['项目', '值'], [
|
|
['账户数', $result['accounts']],
|
|
['流水行数', $result['flows']],
|
|
['期末余额合计', number_format($result['balance_sum'], 2)],
|
|
['期初日期', $result['opening_date']],
|
|
]);
|
|
$this->info('财务台账流水重算完成。');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|