| 12345678910111213141516171819202122 |
- <?php
- namespace App\Console\Commands;
- use App\Services\Sharing\ShareDefaults;
- use App\Services\Sharing\ShareSettlementService;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- class SettleSharing extends Command
- {
- protected $signature='share:settle {date? : 原下注日期Y-m-d,默认北京时间昨日} {--preview : 只读预览,不登记应付佣金} {--reconcile : 处理迟到结算和改判}';
- protected $description='每日结算新分享应付佣金,不直接入会员钱包';
- public function handle(ShareSettlementService $service): int
- {
- try {
- if ($this->option('reconcile') && $this->option('preview')) throw new \InvalidArgumentException('reconcile不支持preview,请使用日期预览');
- $result=$this->option('reconcile') ? $service->reconcile() : $service->settle($this->argument('date') ?: Carbon::now(ShareDefaults::TIMEZONE)->subDay()->toDateString(),!(bool)$this->option('preview'));
- $this->line(json_encode($result,JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR)); return self::SUCCESS;
- } catch (\Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; }
- }
- }
|