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(), '日'); } }