ShopData.php 3.8 KB
<?php

namespace LibModels\Web\Product;

use Api\Yohobuy;
use Api\Sign;
/**
 * 品牌店铺的接口
 * @info  http://git.dev.yoho.cn/yoho-documents/api-interfaces/blob/master/%E5%95%86%E5%93%81%E5%88%97%E8%A1%A8/brandShops.md
 * @copyright yoho.inc
 * @author xiaoxiao.hao <xiaoxiao.hao@yoho.cn>
 */
class ShopData
{
    /**
     * 获取店铺装修的所有资源接口
     * @param type int $shopId 店铺id
     * @return type []
     */
    public static function shopsDecoratorList($shopId)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.shopsdecorator.getList';
        $param['shop_id'] = intval($shopId);
        $param['client_secret'] = Sign::getSign($param);
        
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    /**
     * 查询店铺介绍接口
     * @param type int $shopId 店铺id
     * @return type []
     */
    public static function getIntro($shopId, $uid = '')
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.shops.getIntro';
        $param['shop_id'] = intval($shopId);
        $param['uid'] = $uid;
        $param['client_secret'] = Sign::getSign($param);
        
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    
    /**
     * 查询店铺下面的所有品牌
     * @param type int $shopId 店铺id
     * @return type []
     */
    public static function getShopsBrands($shopId)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.shops.getShopsBrands';
        $param['shop_id'] = intval($shopId);
        $param['client_secret'] = Sign::getSign($param);
        
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    
    /**
     * 搜索店铺内商品 || 查询该店铺下全部商品
     * @param type int $shopId 店铺id
     * @return type []
     */
    public static function getSearch($shopId)
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.search.li';
        $param['shop'] = intval($shopId);
        $param['client_secret'] = Sign::getSign($param);
        
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    
    /**
     * 查询该店铺下所有二级品类
     * @param type int $shopId 店铺id
     * @param type string $yhChannel 频道
     * @param type string $gender 性别
     * @return type []
     */
    public static function getSortInfo($shopId, $yhChannel = '', $gender = '')
    {
        $param = Yohobuy::param();
        $param['method'] = 'app.shop.getSortInfo';
        $param['shop_id'] = intval($shopId);
        $param['yh_channel'] = $yhChannel;
        $param['gender'] = $gender;
        $param['client_secret'] = Sign::getSign($param);
        
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    
    /**
     * 收藏|取消 店铺接口
     * @param type int $shopId 店铺id
     * @param type Boolean $isfavorite true:收藏,false:取消
     * @param type string $type 收藏的类型,brand、product、shop
     * @return type []
     */
    public static function setFavorite($shopId, $isfavorite, $uid, $type = 'shop')
    {
        $param = Yohobuy::param();
        $param['method'] = $isfavorite ? 'app.favorite.add' : 'app.favorite.cancel';
        $param['id'] = intval($shopId);
        $param['fav_id'] = intval($shopId);
        $param['uid'] = $uid;
        $param['type'] = $type;
        $param['client_secret'] = Sign::getSign($param);
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
    /**
     * 根据domain查找shop_id
     * @param type string $domain 品牌域名
     * @return type []
     */
    public static function byDomain($domain)
    {
        $param = Yohobuy::param();
        $param['method'] = 'web.brand.byDomain';
        $param['domain'] = $domain;
        $param['client_secret'] = Sign::getSign($param);
        return Yohobuy::get(Yohobuy::API_URL, $param);
    }
}