BrandData.php 1.36 KB
<?php

namespace LibModels\Wap\Product;

use Api\Yohobuy;
use Api\Sign;

/**
 * 商品品牌相关的数据模型
 * 
 * @name BrandData
 * @package 
 * @copyright yoho.inc
 * @version 1.0 (2015-10-28 11:12:35)
 * @author fei.hong <fei.hong@yoho.cn>
 */
class BrandData
{

    /**
     * 收藏
     * 
     * @param int $id 品牌ID
     * @param int $uid 用户ID
     * @param bool $isBrand 是品牌还是商品
     * @return array
     */
    public static function favorite($id, $uid, $isBrand = true)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.favorite.add';
        $param['id'] = $id;
        $param['uid'] = $uid;
        $param['type'] = $isBrand ? 'brand' : 'product';
        $param['client_secret'] = Sign::getSign($param);

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

    /**
     * 取消收藏
     * 
     * @param int $id 品牌ID
     * @param int $uid 用户ID
     * @param bool $isBrand 是品牌还是商品
     * @return array
     */
    public static function favoriteCancel($id, $uid, $isBrand = true)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.favorite.cancel';
        $param['fav_id'] = $id;
        $param['uid'] = $uid;
        $param['type'] = $isBrand ? 'brand' : 'product';
        $param['client_secret'] = Sign::getSign($param);

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

}