| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | <?phpnamespace App\Console\Commands\SendOrder;use App\Modules\SendOrder\Services\SendOrderChargeStatService;use Illuminate\Console\Command;class StatSendOrderByDate extends Command{    /**     * 执行命令   php artisan send_order:generate_day_stat     *     * The name and signature of the console command.     *     * @var string     */    protected $signature = 'send_order_recharge_stat {--start_date=} {--end_date=}';    /**     * The console command description.     *     * @var string     */    protected $description = '派单充值数据统计';    /**     * @return bool     */    public function handle(): bool    {        $date       = date('Y-m-d', strtotime('-1 days'));        $start_date = $this->option('start_date');        $end_date   = $this->option('end_date');        // 根据参数判断        if ($start_date && $end_date && $start_date <= $end_date) {            while (strtotime($start_date) <= strtotime($end_date)) {                var_dump($start_date);                // 删除旧数据                SendOrderChargeStatService::deleteSendOrderStatsByDate($start_date);                // 执行                SendOrderChargeStatService::getOrdersByDate($start_date);                // 自增1天                $start_date = date('Y-m-d', strtotime('+1 days', strtotime($start_date)));            }        } else {            // 删除旧数据            SendOrderChargeStatService::deleteSendOrderStatsByDate($date);            // 执行            SendOrderChargeStatService::getOrdersByDate($date);        }        return true;    }}
 |