ClassData.php 3.99 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(API_URL, $param);
    }

    /**
     * 查询品类商品数据
     * 
     * @param  string $gender    "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
     * @param  integer $brand    品牌Id
     * @param  integer $sort     品类查询sort参数
     * @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 selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $order = 's_t_desc', $limit = 60, $page = 1)
    {
        // 构建必传参数
        $param = Yohobuy::param();

        $selectItems = array(
            'gender' => $gender,
            'brand' => $brand,
            'sort' => $sort,
            'color' => $color,
            'size' => $size,
            'price' => $price,
            'p_d' => $p_d
        );
        // 拉取筛选参数
        $queriedParams = array_filter($selectItems);
        $param += $queriedParams;

        $param['method'] = 'app.search.category';
        $param['page'] = $page;
        $param['limit'] = $limit;
        $param['gender'] = $gender;
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(API_URL, $param);
    }

    /**
     * 查询商品数据
     * 
     * @param  string $gender    "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
     * @param  integer $brand    品牌Id
     * @param  integer $sort     品类查询sort参数
     * @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 filterClassData($condition)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.search.category';
        $param += $condition;
        if (!isset($param['order'])) {
            $param['order'] = 's_t_desc';
        }
        if (!isset($param['limit'])) {
            $param['limit'] = 60;
        }
        if (!isset($param['page'])) {
            $param['page'] = 1;
        }
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(API_URL, $param);
    }

    /**
     * 学生专享商品
     *
     */
    public static function filterStudentsData($condition)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.student.discount';
        $param += $condition;
        if (!isset($param['order'])) {
            $param['order'] = 's_t_desc';
        }
        if (!isset($param['limit'])) {
            $param['limit'] = 60;
        }
        if (!isset($param['page'])) {
            $param['page'] = 1;
        }
        $param['client_secret'] = Sign::getSign($param);

        return Yohobuy::get(API_URL, $param);
    }

}