<?php
namespace app\admin\server\medical;


use app\admin\model\Appointment;
use app\admin\model\AppointmentLog;
use app\admin\model\MedicalCareOrder;
use app\admin\model\MedicalCareOrderProduct;
use app\admin\model\MedicalCarePostage;
use app\admin\model\PackageOrderDetail;
use app\admin\model\SystemAdmin;
use app\admin\model\SystemMenu;
use app\admin\model\SystemRole;

class AppointmentLogServer
{
    /**
     * Notes:预约服务记录
     * @param string $keywords
     * @param int $page
     * @param int $limit
     * @return array
     * User: QJF
     * Date: 2022/10/22
     */
    public static function getMentLogList(int $page, int $limit)
    {
        [$list, $count] =  AppointmentLog::geMentLogList($page, $limit);

        return compact('list', 'page', 'limit', 'count');
    }
    /**
     * Notes:产品预约详情
     * @param int $package_id
     * @return int
     * User: QJF
     * Date: 2022/10/22
     */
    public static function infoMentLog($log_appointment_id)
    {
        AppointmentLog::affairBegin();
        try {
            $where = [];
            $where['log_id'] = $log_appointment_id;

            $result = AppointmentLog::with(['User','Appointment','Subject','Salesman','Visit','DocTor'])->where($where)->first();
            if (!empty($result)){
                AppointmentLog::affairCommit();
                return $result;
            }else{
                return false;
            }
        }catch (\Exception $exception){
            SystemRole::affairRollback();
            throw new \Exception($exception->getMessage(), 500);
        }
    }
}
