<?php

namespace App\Services\WeChat;

use App\Models\Common\TokenModel;

class AccessToken
{


    public function get($user_name = null)
    {
        if (empty($user_name)) {
            $user_name = Config('wechat.fpdx.public_id');
        }
        $data = TokenModel::where('user_name', $user_name)->first();
        if ($data) {
            return $data->access_token;
        } else {
            throw new WeChatException("公众号异常", 500);
        }
    }
}
