<?php

namespace app\admin\controller\user;

use app\admin\controller\BaseController;
use app\admin\server\user\UsersServer;
use app\api\server\user\CityServer;
use support\Request;


/**
 * 省市区
 * Class Users
 * @package app\admin\controller\user
 */
class Address extends BaseController
{

    /**
     * Notes:获取省市区县
     * @return \support\Response
     * User: QJF
     * Date: 2022/9/15
     */
    public function getCityList()
    {
        $city_id        = $this->request->post('city_id');
        $result         = CityServer::getCityList($city_id);
        return json_success($result, '成功');
    }

    /**
     * Notes:获取用户信息
     * @return \support\Response
     * User: yym
     * Date: 2022/7/26
     */
    public function getUserInfo()
    {
        $user_id = $this->request->get('user_id');
        $this->validateCheck('user\UserValidate', ['user_id' => $user_id], 'info');
        return json_success(UsersServer::getUserInfo($user_id), '成功');
    }

    /**
     * Notes:会员列表
     * @return \support\Response
     * User: yym
     * Date: 2022/8/4
     */
    public function getUserList()
    {
        $keywords = (string)$this->request->get('keywords', '');//搜索内容
        $category = (int)$this->request->get('category', '');//会员类型
        $status   = (int)$this->request->get('status', '');//会员状态
        [$page, $limit] = $this->getPage();
        return json_success(UsersServer::getUserList($keywords, $category, $status, $page, $limit), '获取成功');
    }

    /**
     * Notes:会员认证审核
     * @return \support\Response
     * User: yym
     * Date: 2022/8/4
     */
    public function authUser()
    {
        $user_id  = $this->request->post('user_id');//会员编号
        $status   = $this->request->post('status');//审核状态 0=待审核 1=审核通过 2=审核驳回 3=主动撤销
        $content  = $this->request->post('content', '');//审核意见
        $category = $this->request->post('category');//分类 实名认证、会员升级
        $admin_id = $this->request->admin_id;
        $this->validateCheck('user\UserValidate', ['user_id' => $user_id, 'status' => $status, 'content' => $content, 'category' => $category], 'auth');
        UsersServer::authUser($admin_id, $user_id, $status, $content, $category);
        return json_success([], '操作成功');
    }

    /**
     * Notes:获取会员体检信息
     * @return \support\Response
     * @throws \Exception
     * User: yym
     * Date: 2022/9/21
     */
    public function getUserReport()
    {
        $user_id = $this->request->get('user_id');//会员编号
        $this->validateCheck('user\UserValidate', ['user_id' => $user_id], 'report');
        return json_success(UsersServer::getUserReport($user_id), '获取成功');
    }
}
