| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Console\Commands;
- use App\Services\LogService;
- use App\Services\NewOrderCountingRecordService;
- use Illuminate\Console\Command;
- class OrderCountingRecordTask extends Command
- {
- /**
- * @var NewOrderCountingRecordService $service
- */
- public $service;
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'orderCountingRecordTask';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Command description';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @throws \Exception
- */
- public function handle()
- {
- LogService::log(OrderCountingRecordTask::class, "订单量统计", '');
- ini_set('memory_limit', '2226M');
- $this->service = app('NewOrderCountingRecordService');
- if (now()->toDateString() == now()->startOfMonth()->toDateString()) {//是否为月初
- //统计上月的数据
- $this->service->recordOrder(now()->subMonth()->startOfMonth()->toDateString(), now()->subMonth()->endOfMonth()->toDateString(), '月');
- }
- if (now()->toDateString() == now()->startOfYear()->toDateString()) {//是否为年初
- //统计上年的数据
- $this->service->recordOrder(now()->subYear()->startofYear()->toDateString(), now()->subYear()->endOfYear()->toDateString(), '年');
- }
- //统计前一天的数据
- $this->service->recordOrder(now()->subDay()->toDateString(), now()->subDay()->toDateString(), '日');
- }
- }
|