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

use app\admin\controller\BaseController;
use app\admin\model\MerchantShop;
use app\admin\server\medical\AppointmentLogServer;
use app\admin\server\medical\AppointmentServer;
use app\admin\server\medical\MedicalCarePostageServer;
use app\admin\server\medical\MedicalCareProductServer;
use app\admin\server\medical\ShopServer;
use app\admin\server\package\PackageGoodsServer;

class Appointment extends BaseController
{
    /**
     * Notes:预约服务列表
     * @return \support\Response
     * User: QJF
     * Date: 2022/9/30
     */
    public function getMentList()
    {
        [$page, $limit] = $this->getPage();
        $keywords = $this->request->get('keywords');
        $result         = AppointmentServer::getMentList($page, $limit,$keywords);
        return json_success($result, '成功');
    }
    /**
     * Notes:添加预约服务
     * @return \support\Response
     * User: QJF
     * Date: 2022/9/28
     *
     */
    public function addMent()
    {
        $param     = $this->request->post();
        $this->validateCheck('medical\MentValidate',
            [
                'appointment_category_id'             => $param['appointment_category_id'],
                'appointment_shop_id'             => $param['appointment_shop_id'],
                'appointment_name'            => $param['appointment_name'],
                'appointment_price'         => $param['appointment_price'],
                'appointment_type'             => $param['appointment_type'],
                'appointment_hour_count'          => $param['appointment_hour_count'],
                'appointment_status'          => $param['appointment_status'],
                'appointment_service_instructions' => $param['appointment_service_instructions']
            ],
            'add');
        $result         = AppointmentServer::insertMent($param);
        return json_success($result, '添加成功');
    }
    /**
     * Notes:修改预约服务
     * @return \support\Response
     * User: QJF
     * Date: 2022/9/30
     */
    public function updateMent()
    {
        $param      = $this->request->post();
        $this->validateCheck('medical\MentValidate',
            [
                'appointment_id'               => $param['appointment_id'],
                'appointment_category_id'             => $param['appointment_category_id'],
                'appointment_shop_id'             => $param['appointment_shop_id'],
                'appointment_name'            => $param['appointment_name'],
                'appointment_price'         => $param['appointment_price'],
                'appointment_type'             => $param['appointment_type'],
                'appointment_hour_count'          => $param['appointment_hour_count'],
                'appointment_status'          => $param['appointment_status'],
                'appointment_service_instructions' => $param['appointment_service_instructions']
            ], 'update');
         $result         = AppointmentServer::updateMent($param);
        return json_success($result, '修改成功');
    }

    /**
     * Notes:删除预约服务
     * @return \support\Response
     * User: QJF
     * Date: 2022/9/23
     */
    public function delMent()
    {
        $appointment_id = $this->request->get('appointment_id');
        $this->validateCheck('medical\MentValidate', ['appointment_id' => $appointment_id], 'del');
        $result         = AppointmentServer::delMent($appointment_id);
        if ($result){
            return json_success($result, '删除成功');
        }else{
            throw new \Exception('删除失败！');
        }

    }
    /**
     * Notes:查看预约服务
     * @return \support\Response
     * User: QJF
     * Date: 2022/9/28
     */
    public function infoMent()
    {
        $appointment_id = $this->request->get('appointment_id');
        $this->validateCheck('medical\MentValidate', ['appointment_id' => $appointment_id], 'info');
        $result         = AppointmentServer::infoMent($appointment_id);
        if ($result){
            return json_success($result, '获取成功');
        }else{
            throw new \Exception('获取失败！');
        }

    }
    //预约服务上下架
    public function showMent(){
        $appointment_id = $this->request->get('appointment_id');
        $appointment_status= $this->request->get('appointment_status');
        $result         = AppointmentServer::showMent($appointment_id,$appointment_status);
        if ($result){
            return json_success($result, '成功');
        }else{
            throw new \Exception('失败！');
        }
    }
    /**
     * Notes:查看预约记录
     * @return \support\Response
     * User: QJF
     * Date: 2022/10/22
     */
    public function mentLogList()
    {
        [$page, $limit] = $this->getPage();
        $result         = AppointmentLogServer::getMentLogList($page, $limit);
        return json_success($result, '成功');
    }
    /**
     * Notes:查看预约记录
     * @return \support\Response
     * User: QJF
     * Date: 2022/10/22
     */
    public function mentLogInfo()
    {
        $log_appointment_id = $this->request->get('log_id');
        $result         = AppointmentLogServer::infoMentLog($log_appointment_id);
        if ($result){
            return json_success($result, '获取成功');
        }else{
            throw new \Exception('获取失败！');
        }
    }
}
