...
|
...
|
@@ -57,20 +57,198 @@ class PlusstarData |
|
|
|
|
|
/**
|
|
|
* 品牌介绍
|
|
|
*
|
|
|
* @param int $id 唯一的ID
|
|
|
* @param string $gender $gender "1,3"表示男, "2,3"表示女
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $udid cookie记录唯一标识
|
|
|
* @return array(
|
|
|
* "getBrandInfo" => array(品牌详情信息),
|
|
|
* "getUidBrandFav" => false,
|
|
|
* "getArticleByBrand" => array(3篇相关资讯),
|
|
|
* "getNewProduct" => array(6篇新品到着),
|
|
|
* "getUidProductFav" => array(用户是否收藏新品)
|
|
|
* )
|
|
|
*/
|
|
|
public static function brandInfo($id)
|
|
|
public static function brandInfo($id, $gender, $uid, $udid = null)
|
|
|
{
|
|
|
$isUidOk = $uid && is_numeric($uid);
|
|
|
|
|
|
// 品牌详情信息
|
|
|
$result = array();
|
|
|
$result['getBrandInfo'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/plustar/', 'getBrandInfo', array(array('id' => $id)) );
|
|
|
$result['getUidBrandFav'] = false;
|
|
|
$result['getNewProduct'] = array();
|
|
|
$result['getUidProductFav'] = array();
|
|
|
$result['getArticleByBrand'] = array();
|
|
|
|
|
|
Yohobuy::yarConcurrentCall('http://service.api.yohobuy.com/guang/service/v1/plustar/', 'getBrandInfo', array('id' => 289), function($retval, $callinfo) use(&$result) {
|
|
|
$result[ $callinfo['method'] ] = empty($retval['data']) ? array() : $retval['data'];
|
|
|
});
|
|
|
Yohobuy::yarConcurrentCall('http://service.api.yohobuy.com/guang/service/v1/plustar/', 'getList', array('id' => 289), function($retval, $callinfo) use(&$result) {
|
|
|
$result[ $callinfo['method'] ] = empty($retval['data']) ? array() : $retval['data'];
|
|
|
// 判断
|
|
|
if (!isset($result['getBrandInfo']['brand_id'])) {
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
// 是否收藏店铺
|
|
|
if ($isUidOk) {
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidBrandFav', array($uid, $id), function($retval) use(&$result) {
|
|
|
$result['getUidBrandFav'] = empty($retval['data']) ? false : $retval['data'];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 相关资讯列表 (3篇)
|
|
|
$result['getArticleByBrand'] = array();
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'guang/service/v1/article/', 'getArticleByBrand', array($result['getBrandInfo']['brand_id'], 3, $udid), function($retval) use(&$result) {
|
|
|
$result['getArticleByBrand'] = empty($retval) ? array() : $retval;
|
|
|
});
|
|
|
Yohobuy::yarConcurrentLoop();
|
|
|
|
|
|
// 新品到着列表 (6篇)
|
|
|
$result['getNewProduct'] = array();
|
|
|
$result['getUidProductFav'] = array();
|
|
|
|
|
|
do {
|
|
|
// 调用搜索接口
|
|
|
$param = Yohobuy::param();
|
|
|
$param['method'] = 'app.search.li';
|
|
|
$param['brand'] = $result['getBrandInfo']['brand_id'];
|
|
|
$param['page'] = '0';
|
|
|
$param['limit'] = '6';
|
|
|
$param['gender'] = $gender;
|
|
|
$param['order'] = 's_t_desc';
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$newProduct = Yohobuy::get(Yohobuy::API_URL, $param);
|
|
|
if (empty($newProduct['data']['product_list'])) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//$result['getNewProduct'] = $newProduct['data']['product_list'];
|
|
|
|
|
|
$skn = '';
|
|
|
foreach ($newProduct['data']['product_list'] as $value) {
|
|
|
if (empty($value['goods_list'])) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 用户是否收藏该商品
|
|
|
$skn = $value['product_skn'];
|
|
|
$result['getUidProductFav'][ $skn ] = false;
|
|
|
if ($isUidOk) {
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result,&$skn) {
|
|
|
$result['getUidProductFav'][ $skn ] = empty($retval['data']) ? false : $retval['data'];
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// @todo 需要根据页面结构封装返回数据
|
|
|
}
|
|
|
} while (false);
|
|
|
|
|
|
// 调用发起请求
|
|
|
Yohobuy::yarConcurrentLoop();
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
|
// @todo 根据页面展示数据封装
|
|
|
// $url = '';
|
|
|
// if($uid > 0){
|
|
|
// $isLike = Favorite::getUidProductFav($uid, $new_goods_info['product_skn']);
|
|
|
// }
|
|
|
// if($client_type == 'web'){
|
|
|
// $baseUrl = QUtilsConfig::$websiteRoot['yohobuy'];
|
|
|
// }else{
|
|
|
// $baseUrl = QUtilsConfig::$websiteRoot['h5'];
|
|
|
// }
|
|
|
// $goods_url = MakeUrl::h5ProductDetailUrl($baseUrl,$new_goods_info['product_id'],$new_goods_info['goods_list'][0]['goods_id'],$new_goods_info['cn_alphabet']);
|
|
|
// $url = MakeUrl::makeUrl('go.productDetail',$goods_url, array('product_skn'=>$new_goods_info['product_skn']),$client_type);
|
|
|
// if((int)$new_goods_info['market_price'] == (int)$new_goods_info['sales_price'])
|
|
|
// {
|
|
|
// $new_goods_info['market_price'] = '';
|
|
|
// }
|
|
|
// $tags = array(
|
|
|
// 'isNew' => false,
|
|
|
// 'isSale' => false,
|
|
|
// 'isLimit' => false,
|
|
|
// 'isYohood' => false,
|
|
|
// 'midYear' => false,
|
|
|
// 'yearEnd' => false,
|
|
|
// );
|
|
|
// foreach ($new_goods_info['tags'] as $v){
|
|
|
// if($v == 'is_new'){
|
|
|
// $tags['isNew'] = true;
|
|
|
// }elseif($v == 'is_discount'){
|
|
|
// $tags['isSale'] = true;
|
|
|
// }elseif($v == 'is_limited'){
|
|
|
// $tags['isLimit'] = true;
|
|
|
// }elseif($v == 'is_yohood'){
|
|
|
// $tags['isYohood'] = true;
|
|
|
// }elseif($v == 'mid-year'){
|
|
|
// $tags['midYear'] = true;
|
|
|
// }elseif($v == 'year-end'){
|
|
|
// $tags['yearEnd'] = true;
|
|
|
// }
|
|
|
// }
|
|
|
// $newPatterns[$new_goods_info['product_skn']]= array (
|
|
|
// 'id'=>$new_goods_info['product_skn'],
|
|
|
// 'product_id'=>$new_goods_info['product_id'],
|
|
|
// 'product_skn'=>$new_goods_info['product_skn'],
|
|
|
// 'thumb' => $new_goods_info['default_images'],
|
|
|
// 'name' => $new_goods_info['product_name'],
|
|
|
// 'isLike' => $isLike,
|
|
|
// 'price' => $new_goods_info['market_price'],
|
|
|
// 'salePrice' => $new_goods_info['sales_price'],
|
|
|
// 'isSale' => $new_goods_info['is_discount'] == 'Y' ? true : false,
|
|
|
// 'isFew' => $new_goods_info['is_soon_sold_out'] == 'Y' ? true : false,
|
|
|
// 'isNew' => $new_goods_info['is_new'] == 'Y' ? true : false,
|
|
|
// 'url' => $url,
|
|
|
// 'tags' => $tags
|
|
|
// );
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 品牌收藏/取消收藏
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $id 唯一的ID
|
|
|
* @param string $opt 操作(ok:表示确定,cancel:表示取消)
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function favoriteBrand($uid, $id, $opt = 'ok')
|
|
|
{
|
|
|
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'toggleBrandFav', array($uid, $id));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 商品收藏/取消收藏
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $skn 商品标识
|
|
|
* @param string $opt 操作(ok:表示确定,cancel:表示取消)
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function favoriteProduct($uid, $skn, $opt = 'ok')
|
|
|
{
|
|
|
if ($opt === 'cancel') {
|
|
|
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'addUidProductFav', array($uid, $skn));
|
|
|
} else {
|
|
|
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'shops/service/v1/favorite/', 'delUidProductFav', array($uid, $skn));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 资讯点赞/取消赞
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $id 唯一的ID
|
|
|
* @param string $opt 操作(ok:表示确定,cancel:表示取消)
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function praiseArticle($uid, $id, $opt = 'ok')
|
|
|
{
|
|
|
if ($opt === 'cancel') {
|
|
|
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/favorite/', 'cancelPraise', array($id, $uid));
|
|
|
} else {
|
|
|
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . 'guang/service/v1/favorite/', 'setPraise', array($id, $uid));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|