ClassData.php 2.06 KB
<?php
namespace LibModels\Wap\Category;

use Api\Yohobuy;
use Api\Sign;

/**
 * 品类数据接口操作类
 * 
 * @name ClassData
 * @package Library/LibModels/wap/Category
 * @copyright yoho.inc
 * @version 1.0 (2015-10-10)
 * @author gtskk <rocky.zhang@yoho.cn>
 */
class ClassData
{
	/**
	 * 获取品类数据
	 * 
	 * @return array 品类数据
	 */
    public static function getClassesData()
    {
		// 构建必传参数
		$param = Yohobuy::param();

		$param['method'] = 'app.sort.get';
        $param['client_secret'] = Sign::getSign($param);
        
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }

	/**
	 * 查询品类商品数据
	 * 
	 * @param  string $gender    "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
	 * @param  integer $brand    品牌Id
	 * @param  integer $sort     品类Id
	 * @param  integer $color    颜色Id
	 * @param  integer $size     尺码Id
	 * @param  string $price     价格
	 * @param  string $p_d       折扣
	 * @param  string $order     排序方式,默认s_t_desc
	 * @param  integer $limit    限制查询的数目,默认为60
	 * @param  integer $page     查询第几页,默认为第1页
	 * @param  integer $channel  表示频道号,1位男生,2为女生
	 * @return array             品类商品数据
	 */
	public static function selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $channel = 1, $order = 's_t_desc', $limit = 60, $page = 1)
	{
	    $selectItems = array(
	        'gender' => $gender,
	        'brand' => $brand,
	        'sort' => $sort,
	        'color' => $color,
	        'size' => $size,
	        'price' => $price,
	        'p_d' => $p_d
	    );
	    // 拉取筛选参数
	    $queriedParams = array_filter($selectItems, function($v) {return $v !== null;});

	    // 构建必传参数
	    $param = Yohobuy::param();

	    $param['method'] = 'app.search.category';
	    $param['page'] = $page;
	    $param['limit'] = $limit;
	    $param['yh_channel'] = $channel;
	    $param['client_secret'] = Sign::getSign($param);
	    
	    return Yohobuy::get(Yohobuy::API_URL, $param);
	}
}