Plusstar.php 1.61 KB
<?php
namespace Guang;
use LibModels\Web\Guang\PlusstarData;
use WebPlugin\Images;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
class PlusstarModel
{
    
    /**
     * 获取Plustar列表
     * 
     * @param string $brandType
     * @param string $gender
     * @param int $isRecommend
     * @return array
     */
    public static function getPlustarList($brandType, $gender, $isRecommend = 0)
    {
        $key = WebCacheConfig::KEY_WEB_GUANG_PLUSSTAR_DATA.'_'.$brandType.'_'.$isRecommend;
        $data = Cache::get($key);
        if(empty($data)) {
            $list = PlusstarData::getList($brandType, $gender, $isRecommend);;
            $brandList = $brandIds = array();
            if(isset($list['data']['data']['list'])) {
                $brandList = current($list['data']['data']['list']);
            }
            if(isset($brandList['data'])) {
                foreach ($brandList['data'] as $brand) {
                    $pos = 0;
                    if(isset($brand['data'][0])) {
                        $src = Images::getImageUrl($brand['data'][0]['src'], 320, 160, 1);
                    }
                    $brandIds[] = $brand['brand_id'];
                    $data[$brand['brand_id']] = array(
                        'brand_id' => $brand['brand_id'],
                        'name'=> $brand['brand_name'],
                        'sort_id' => $brand['sort_id'],
                        'src' => $src,
                        'desc' =>'',
                        'url'=> '',
                    );
                }
            }
            Cache::set($key, $data, 600);
        }
        return $data;
    }
}
?>