<?php

namespace app\admin\service\statistics;

use app\model\Appointment;
use support\Db;

class AppointmentService
{
    public static function getAppointment()
    {
        // 待确认
        $data['waiting'] = Appointment::where('appointment_status', 'WAITING')->count('appointment_id');
        // 待服务
        $data['append'] = Appointment::where('appointment_status', 'PENDING')->count('appointment_id');
        // 今日预约
        $data['todayAppointment'] = Appointment::where('appointment_datetime', date('Y-m-d'))->count('appointment_id');
        // 今日服务
        $today = Db::select("select service_time,count(*) as total from (select left(appointment_doing_datetime,10) as service_time from app_appointment where appointment_status = 'DONE') as appointment where service_time ='".date('Y-m-d')."'");
        $data['todayService'] = $today[0]->total;

        return $data;
    }
}