<?php

/**
 * Description of 
 *
 * @author zhiyuan
 * Date: 2021/6/12
 * Time: 10:32 PM
 */

namespace  Api\PhpServices\LifeAccount;

use Api\PhpUtils\Common\TimeOut;
use Api\PhpUtils\Http\Request;
use App\Exception\custom\CodeSpecialException;

class Account
{
    /**
     * 批量获取生活号角色表数据
     *
     *@param $params['role_id'] 主键id
     *
     */
    public static function getRoleList($params)
    {
        $url = config('interface', 'merchant.account.get_role_list');
        if (!$url) {
            throw new CodeSpecialException("failed");
        }
        if (!array_key_exists('role_id', $params) || !array_key_exists('page', $params) || !array_key_exists('page_size', $params)) {
            throw new CodeSpecialException("failed");
        }
        $list  = (new TimeOut())->runGet($url, $params);
        if (!$list) {
            throw new CodeSpecialException("timeout");
        }
        return $list;
    }

    /**
     * 批量获取生活号表数据
     *
     *@param $params['user_id'] 主键id
     *
     */
    public static function getLifeList($params)
    {
        $url = config('interface', 'merchant.account.get_life_list');
        if (!$url) {
            throw new CodeSpecialException("failed");
        }
        $list  = (new TimeOut())->runGet($url, $params);
        if (!$list) {
            throw new CodeSpecialException("timeout");
        }
        return $list;
    }

    /**
     * 批量获取用户表数据
     *
     *@param $params['user_id'] 主键id
     *
     */
    public static function getUserList($params)
    {
        $url = config('interface', 'merchant.account.get_user_list');
        if (!$url) {
            throw new CodeSpecialException("failed");
        }
        $list  = (new TimeOut())->runGet($url, $params);
        if (!$list) {
            throw new CodeSpecialException("timeout");
        }
        return $list;
    }
}
