ListData.php
4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
namespace LibModels\Wap\Product;
use Api\Yohobuy;
use Api\Sign;
/**
* 商品列表相关的数据模型
*
* @name ListData
* @package LibModels/Wap/Product
* @copyright yoho.inc
* @version 1.0 (2015-10-15 20:15:02)
* @author fei.hong <fei.hong@yoho.cn>
*/
class ListData
{
const URI_PRODUCT = 'shops/service/v1/product';
/**
* 根据商品SKN获取商品的简要信息
*
* @param array $skns
* @return array
*/
public static function productInfoBySkns($skns)
{
// // 调用搜索接口
// $param = Yohobuy::param();
// $param['method'] = 'app.search.li';
// $param['query'] = implode(' ', $skns);
// $param['limit'] = count($skns);
// $param['order'] = 's_t_desc';
// $param['client_secret'] = Sign::getSign($param);
//
// return Yohobuy::get(API_URL, $param, 3600); // 有缓存1小时
$condition = array();
$condition['query'] = implode(' ', $skns);
$condition['limit'] = count($skns);
$condition['order'] = 's_t_desc';
return SearchData::searchElasticByCondition($condition, 3600); // 有缓存1小时
}
/**
* 根据商品SKC获取商品的简要信息
*
* @param array $skcs
* @return array
*/
public static function productInfoBySkcs($skcs)
{
return Yohobuy::yarClient(SERVICE_URL . self::URI_PRODUCT, 'getLessInfoByProductSkcs', array(array('productSkcs' => $skcs)));
}
/**
* 获取店铺装修的所有资源接口
* @param int $shopId 店铺id
* @param int $cache 接口缓存
* @author sefon 2016-4-26 21:17:15
* @return array
*/
public static function getShopDecorator($shopId, $cache = 600)
{
$param = Yohobuy::param();
$param['method'] = 'app.shopsdecorator.getList';
$param['shop_id'] = $shopId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
}
/**
* 获取店铺信息
* @param int $shopId 店铺id
* @param int $uid 用户id 判断用户是否收藏店铺
* @param int $cache 接口缓存
* @author sefon 2016-4-26 21:32:57
* @return array
*/
public static function getShopInfo($shopId, $uid = 0, $cache = 600)
{
$param = Yohobuy::param();
$param['method'] = 'app.shops.getIntro';
$param['shop_id'] = $shopId;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
}
/**
* 获取店铺下面的所有品牌
* @param int $shopId 店铺id
* @param int $cache 接口缓存
* @author sefon 2016-4-26 21:48:30
* @return array
*/
public static function getShopBrands($shopId, $cache = 600)
{
$param = Yohobuy::param();
$param['method'] = 'app.shops.getShopsBrands';
$param['shop_id'] = $shopId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
// return Yohobuy::get('http://devapi.yoho.cn:58078/', $param, $cache);
}
/**
* 获取店铺下面的所有分类
* @param int $shopId 店铺id
* @param int $cache 接口缓存
* @author sefon 2016-4-27 21:39:51
* @return array
*/
public static function getShopCategory($shopId, $channel, $cache = 600)
{
$param = Yohobuy::param();
$param['method'] = 'app.shop.getSortInfo';
$param['yh_channel'] = $channel;
$param['shop_id'] = $shopId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
}
public static function getShopDecoratorAndInfo($shopId, $uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.shopsdecorator.getList';
$param['shop_id'] = $shopId;
$param['client_secret'] = Sign::getSign($param);
$urlList['decorator'] = Yohobuy::httpBuildQuery(API_URL, $param);
$param2 = Yohobuy::param();
$param2['method'] = 'app.shops.getIntro';
$param2['shop_id'] = $shopId;
$param2['uid'] = $uid;
$param2['client_secret'] = Sign::getSign($param2);
$urlList['shopInfo'] = Yohobuy::httpBuildQuery(API_URL, $param2);
return Yohobuy::getMulti($urlList);
}
}