<?php

namespace app\api\controller\ContactUs;

use app\BaseController;
use app\common\model\ContactUs\ConsultingHotline as ModelConsultingHotline;
use app\Request;
use think\Validate;
use think\exception\ValidateException;
use think\facade\Filesystem;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use app\common\exception\Tool;
use think\facade\Env;


class ConsultingHotline extends BaseController
{
    /**
     * 获取咨询热线列表
     */
    public function getConsultingHotlineList(Request $request): array
    {
        $params = $request->param();
        $con = [];

        $con = Tool::getOptionalQuery(['consulting_hotline_user', 'LIKE'], ['consulting_hotline_phone', 'LIKE'],);

        $query = ModelConsultingHotline::where($con)
            ->field([
                'consulting_hotline_id',
                'consulting_hotline_guid',
                'consulting_hotline_user',
                'consulting_hotline_phone',
                'consulting_hotline_order'
            ])
            ->order('consulting_hotline_order', 'asc')
            ->select();



        return msg(0, "获取咨询热线列表成功!", [
            'data' => $query,
            'count' => count($query)
        ]);
    }

    /**
     * 获取咨询热线详情
     */
    public function getConsultingHotlineInfo(Request $request): array
    {
        $params = $request->param();

        $this->validate($params, ['consulting_hotline_guid' => 'require']);

        $find = ModelConsultingHotline::field([
            'consulting_hotline_id',
            'consulting_hotline_guid',
            'consulting_hotline_user',
            'consulting_hotline_phone',
            'consulting_hotline_order'
        ])
            ->where('consulting_hotline_guid', $params['consulting_hotline_guid'])
            ->find();

        return msg(0, '获取咨询热线详情成功!', ['data' => $find]);
    }
}
