FavoriteData.php
2.36 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
<?php
namespace LibModels\Web\Product;
use Api\Yohobuy;
use Api\Sign;
/**
* FavoriteData
* 收藏相关接口
* @author Administrator
*/
class FavoriteData
{
const URL_PRODUCT_FAVORITE = 'shops/service/v1/favorite/';
/**
* 根据uid和商品的skn查询是否被用户收藏
* @param $uid
* @param $productSkn
* @return boolean 收藏 true 未收藏 false
*/
public static function getUidProductFav($uid, $productSkn)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_PRODUCT_FAVORITE, 'getUidProductFav', array($uid, $productSkn));
}
/**
* 根据uid和商品的skn收藏商品
* @param $uid
* @param $productSkn
* @return bool
*/
public static function addUidProductFav($uid, $productSkn, $isBrand = false)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.add';
$param['id'] = $productSkn;
$param['uid'] = $uid;
$param['type'] = $isBrand ? 'brand' : 'product';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 根据uid和商品的skn取消收藏商品
* @param $uid
* @param $productSkn
* @return bool
*/
public static function delUidProductFav($uid, $productSkn, $isBrand = false)
{
$param = Yohobuy::param();
$param['method'] = 'app.favorite.cancel';
$param['fav_id'] = $productSkn;
$param['uid'] = $uid;
$param['type'] = $isBrand ? 'brand' : 'product';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 根据uid和商品的skn收藏或取消收藏商品
* @param $uid
* @param $productSkn
* @return bool
*/
public static function changeFavoriteProduct($uid, $productSkn)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_PRODUCT_FAVORITE, 'toggleProduct', array($uid, $productSkn));
}
/**
* 根据uid和商品的skn添加或取消收藏品牌
* @param $uid
* @param $productSkn
* @return bool
*/
public static function changeFavoriteBrand($uid, $productSkn)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_PRODUCT_FAVORITE, 'toggleBrandFav', array($uid, $productSkn));
}
}