36 行
1.2 KiB
PHP
36 行
1.2 KiB
PHP
<?php
|
|
|
|
namespace addons\shopro\console;
|
|
|
|
use think\console\Input;
|
|
use think\console\Output;
|
|
use think\console\input\Option;
|
|
use think\console\Command;
|
|
use addons\shopro\service\partner\DailySettleService;
|
|
|
|
class PartnerSettle extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this->setName('shopro:partner:settle')
|
|
->addOption('date', 'd', Option::VALUE_OPTIONAL, '结算日期 Y-m-d,默认昨天')
|
|
->addOption('rerun', 'r', Option::VALUE_NONE, '删除当天日结后重算')
|
|
->setDescription('收益中心日结(马豆/馆县均分/兑换券释放)');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$date = $input->getOption('date');
|
|
$rerun = (bool) $input->getOption('rerun');
|
|
$output->writeln('partner settle start ' . ($date ?: 'yesterday') . ($rerun ? ' rerun' : ''));
|
|
try {
|
|
$report = (new DailySettleService())->run($date, $rerun);
|
|
$output->writeln('partner settle done: ' . json_encode($report ? $report->toArray() : [], JSON_UNESCAPED_UNICODE));
|
|
return 0;
|
|
} catch (\Exception $e) {
|
|
$output->writeln('partner settle fail: ' . $e->getMessage());
|
|
return 1;
|
|
}
|
|
}
|
|
}
|