<?php
namespace app\plugins\vr_ticket;

use app\plugins\vr_ticket\service\TicketService;

class Hook
{
    public function handle($params = [])
    {
        if(!empty($params['hook_name']))
        {
            $ret = '';
            switch($params['hook_name'])
            {
                // 后台左侧菜单钩子
                case 'plugins_service_admin_menu_data':
                    $this->AdminSidebarInit($params['admin_left_menu']);
                    break;

                // 订单支付成功处理
                case 'plugins_service_order_pay_success_handle_end':
                    $ret = TicketService::onOrderPaid($params);
                    break;

                case 'plugins_service_order_delete_success':
                    // 如果有删除拦截等
                    break;
            }
            return $ret;
        }
    }

    public function AdminSidebarInit(&$params)
    {
        $params[] = [
            'id'        => 'plugins-vr_ticket',
            'name'      => 'VR票务',
            'title'     => 'VR票务',
            'icon'      => 'am-icon-ticket',
            'control'   => 'admin',
            'action'    => 'index',
            'is_show'   => 1,
            'power'     => 'vr_ticket-admin',
            'url'       => PluginsAdminUrl('vr_ticket', 'admin', 'index'),
            'item'      => [
                [
                    'id'    => 'plugins-vr_ticket-venue',
                    'name'  => '场馆配置',
                    'title' => '场馆配置',
                    'is_show' => 1,
                    'control' => 'admin',
                    'action'  => 'VenueList',
                    'url'   => PluginsAdminUrl('vr_ticket', 'admin', 'VenueList'),
                    'power' => 'vr_ticket-venueList',
                ],
                [
                    'id'    => 'plugins-vr_ticket-seat',
                    'name'  => '座位模板',
                    'title' => '座位模板',
                    'is_show' => 1,
                    'control' => 'admin',
                    'action'  => 'SeatTemplateList',
                    'url'   => PluginsAdminUrl('vr_ticket', 'admin', 'SeatTemplateList'),
                    'power' => 'vr_ticket-seatTemplateList',
                ],
                [
                    'id'    => 'plugins-vr_ticket-ticket',
                    'name'  => '电子票',
                    'title' => '电子票',
                    'is_show' => 1,
                    'control' => 'admin',
                    'action'  => 'TicketList',
                    'url'   => PluginsAdminUrl('vr_ticket', 'admin', 'TicketList'),
                    'power' => 'vr_ticket-ticketList',
                ],
                [
                    'id'    => 'plugins-vr_ticket-verifier',
                    'name'  => '核销员',
                    'title' => '核销员',
                    'is_show' => 1,
                    'control' => 'admin',
                    'action'  => 'VerifierList',
                    'url'   => PluginsAdminUrl('vr_ticket', 'admin', 'VerifierList'),
                    'power' => 'vr_ticket-verifierList',
                ],
                [
                    'id'    => 'plugins-vr_ticket-varification',
                    'name'  => '核销记录',
                    'title' => '核销记录',
                    'is_show' => 1,
                    'control' => 'admin',
                    'action'  => 'VerificationList',
                    'url'   => PluginsAdminUrl('vr_ticket', 'admin', 'VerificationList'),
                    'power' => 'vr_ticket-verificationList',
                ],
                [
                    'id'    => 'plugins-vr_ticket-setup',
                    'name'  => '插件设置',
                    'title' => '插件设置',
                    'is_show' => 1,
                    'control' => 'admin',
                    'action'  => 'Setup',
                    'url'   => PluginsAdminUrl('vr_ticket', 'admin', 'Setup'),
                    'power' => 'vr_ticket-setup',
                ]
            ]
        ];
    }
}
?>