ListData.php 1.48 KB
<?php

namespace LibModels\Wap\Product;

use Api\Yohobuy;
use Api\Sign;

/**
 * 商品列表相关的数据模型
 * 
 * @name ListData
 * @package LibModels/Wap/Product
 * @copyright yoho.inc
 * @version 1.0 (2015-10-15 20:15:02)
 * @author fei.hong <fei.hong@yoho.cn>
 */
class ListData
{

    const URI_PRODUCT = 'shops/service/v1/product';

    /**
     * 根据商品SKN获取商品的简要信息
     * 
     * @param array $skns
     * @return array
     */
    public static function productInfoBySkns($skns)
    {
//        // 调用搜索接口
//        $param = Yohobuy::param();
//        $param['method'] = 'app.search.li';
//        $param['query'] = implode(' ', $skns);
//        $param['limit'] = count($skns);
//        $param['order'] = 's_t_desc';
//        $param['client_secret'] = Sign::getSign($param);
//
//        return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 有缓存1小时

        $condition = array();
        $condition['query'] = implode(' ', $skns);
        $condition['limit'] = count($skns);
        $condition['order'] = 's_t_desc';

        return SearchData::searchElasticByCondition($condition, 3600); // 有缓存1小时
    }

    /**
     * 根据商品SKC获取商品的简要信息
     * 
     * @param array $skcs
     * @return array
     */
    public static function productInfoBySkcs($skcs)
    {
        return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PRODUCT, 'getLessInfoByProductSkcs', array(array('productSkcs' => $skcs)));
    }

}