<?php

namespace Modules\Manage\Services;

use Illuminate\Support\Facades\Redis;

class WechatMiniprogramService
{
    /**
     * 微信短剧提审appid
     * @return string
     */
    public static function getDuanjuCheckAppid() {
        return config('manage.miniprogram.duanjuWechatCheck.appid');
    }

    /**
     * 微信短剧提审小程序 accessToken
     * @param string|null $appid
     * @return string
     */
    public static function getDuanjuCheckAccessToken($appid=null) {
        $checkAppid = $appid ?: self::getDuanjuCheckAppid();

        return Redis::get(self::getAccessTokenRedisKey($checkAppid));
    }

    private static function getAccessTokenRedisKey($appid) {
        return 'dj.miniWechat.at.' . $appid;
    }
}
