Showing
5 changed files
with
108 additions
and
14 deletions
@@ -22,15 +22,16 @@ class BrandData | @@ -22,15 +22,16 @@ class BrandData | ||
22 | * | 22 | * |
23 | * @param int $id 品牌ID | 23 | * @param int $id 品牌ID |
24 | * @param int $uid 用户ID | 24 | * @param int $uid 用户ID |
25 | + * @param bool $isBrand 是品牌还是商品 | ||
25 | * @return array | 26 | * @return array |
26 | */ | 27 | */ |
27 | - public static function favorite($id, $uid) | 28 | + public static function favorite($id, $uid, $isBrand = true) |
28 | { | 29 | { |
29 | $param = Yohobuy::param(); | 30 | $param = Yohobuy::param(); |
30 | $param['method'] = 'app.favorite.add'; | 31 | $param['method'] = 'app.favorite.add'; |
31 | $param['id'] = $id; | 32 | $param['id'] = $id; |
32 | $param['uid'] = $uid; | 33 | $param['uid'] = $uid; |
33 | - $param['type'] = 'brand'; | 34 | + $param['type'] = $isBrand ? 'brand' : 'product'; |
34 | $param['client_secret'] = Sign::getSign($param); | 35 | $param['client_secret'] = Sign::getSign($param); |
35 | 36 | ||
36 | return Yohobuy::post(Yohobuy::API_URL, $param); | 37 | return Yohobuy::post(Yohobuy::API_URL, $param); |
@@ -41,15 +42,16 @@ class BrandData | @@ -41,15 +42,16 @@ class BrandData | ||
41 | * | 42 | * |
42 | * @param int $id 品牌ID | 43 | * @param int $id 品牌ID |
43 | * @param int $uid 用户ID | 44 | * @param int $uid 用户ID |
45 | + * @param bool $isBrand 是品牌还是商品 | ||
44 | * @return array | 46 | * @return array |
45 | */ | 47 | */ |
46 | - public static function favoriteCancel($id, $uid) | 48 | + public static function favoriteCancel($id, $uid, $isBrand = true) |
47 | { | 49 | { |
48 | $param = Yohobuy::param(); | 50 | $param = Yohobuy::param(); |
49 | $param['method'] = 'app.favorite.cancel'; | 51 | $param['method'] = 'app.favorite.cancel'; |
50 | $param['fav_id'] = $id; | 52 | $param['fav_id'] = $id; |
51 | $param['uid'] = $uid; | 53 | $param['uid'] = $uid; |
52 | - $param['type'] = 'brand'; | 54 | + $param['type'] = $isBrand ? 'brand' : 'product'; |
53 | $param['client_secret'] = Sign::getSign($param); | 55 | $param['client_secret'] = Sign::getSign($param); |
54 | 56 | ||
55 | return Yohobuy::post(Yohobuy::API_URL, $param); | 57 | return Yohobuy::post(Yohobuy::API_URL, $param); |
@@ -205,14 +205,14 @@ class Helpers | @@ -205,14 +205,14 @@ class Helpers | ||
205 | $result['name'] = $productData['product_name']; | 205 | $result['name'] = $productData['product_name']; |
206 | $result['price'] = empty($productData['market_price']) ? false : $productData['market_price']; | 206 | $result['price'] = empty($productData['market_price']) ? false : $productData['market_price']; |
207 | $result['salePrice'] = $productData['sales_price']; | 207 | $result['salePrice'] = $productData['sales_price']; |
208 | - if ($showPoint) { | ||
209 | - $result['price'] && $result['price'] .= '.00'; | ||
210 | - $result['salePrice'] && $result['salePrice'] .= '.00'; | ||
211 | - } | 208 | + if ($showPoint) { |
209 | + $result['price'] && $result['price'] .= '.00'; | ||
210 | + $result['salePrice'] && $result['salePrice'] .= '.00'; | ||
211 | + } | ||
212 | $result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y'); | 212 | $result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y'); |
213 | $result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_' | 213 | $result['url'] = SITE_MAIN . '/product/pro_' . $productData['product_id'] . '_' |
214 | - . $productData['goods_list'][0]['goods_id'] | ||
215 | - . '/' . $productData['cn_alphabet'] . '.html'; | 214 | + . $productData['goods_list'][0]['goods_id'] |
215 | + . '/' . $productData['cn_alphabet'] . '.html'; | ||
216 | // APP访问需要加附加的参数 | 216 | // APP访问需要加附加的参数 |
217 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 | 217 | // 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护 |
218 | if ($isApp) { | 218 | if ($isApp) { |
@@ -31,15 +31,44 @@ class DetailModel | @@ -31,15 +31,44 @@ class DetailModel | ||
31 | 31 | ||
32 | if (is_numeric($productId) && is_numeric($goodsId)) { | 32 | if (is_numeric($productId) && is_numeric($goodsId)) { |
33 | // 调用服务 | 33 | // 调用服务 |
34 | - $baseInfo = DetailData::baseInfo($productId, $uid); | 34 | + $baseInfo = DetailData::baseInfo($productId, $uid); |
35 | + | ||
36 | + // 判断商品是否在架 | ||
37 | + if (empty($baseInfo['status'])) { | ||
38 | + return $result; | ||
39 | + } | ||
35 | 40 | ||
36 | // 商品名称 | 41 | // 商品名称 |
37 | if (isset($baseInfo['productName'])) { | 42 | if (isset($baseInfo['productName'])) { |
38 | $result['goodsName'] = $baseInfo['productName']; | 43 | $result['goodsName'] = $baseInfo['productName']; |
39 | - } else { | ||
40 | - return $result; | ||
41 | - } | 44 | + } |
42 | 45 | ||
46 | + // 商品标签 | ||
47 | + if (!empty($baseInfo['productTagBoList'])) { | ||
48 | + foreach ($baseInfo['productTagBoList'] as $value) { | ||
49 | + switch ($value['tagLabel']) { | ||
50 | + case 'is_soon_sold_out': // 即将售磬 | ||
51 | + $result['tags']['is_soon_sold_out'] = true; | ||
52 | + break; | ||
53 | + case 'is_new': // 新品 | ||
54 | + $result['tags']['is_new'] = true; | ||
55 | + break; | ||
56 | + case 'is_discount': // 在售 | ||
57 | + $result['tags']['is_discount'] = true; | ||
58 | + break; | ||
59 | + case 'is_limited': // 限量 | ||
60 | + $result['tags']['is_limited'] = true; | ||
61 | + break; | ||
62 | + case 'is_yohood': // YOHOOD | ||
63 | + $result['tags']['is_yohood'] = true; | ||
64 | + break; | ||
65 | + case 'is_advance': // 再到着 | ||
66 | + $result['tags']['is_advance'] = true; | ||
67 | + break; | ||
68 | + } | ||
69 | + } | ||
70 | + } | ||
71 | + | ||
43 | // 商品价格 | 72 | // 商品价格 |
44 | if (isset($baseInfo['productPriceBo'])) { | 73 | if (isset($baseInfo['productPriceBo'])) { |
45 | $result['goodsPrice'] = array(); | 74 | $result['goodsPrice'] = array(); |
@@ -176,6 +205,7 @@ class DetailModel | @@ -176,6 +205,7 @@ class DetailModel | ||
176 | 205 | ||
177 | // 底部简介的URL链接 | 206 | // 底部简介的URL链接 |
178 | $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html'); | 207 | $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html'); |
208 | + $result['id'] = $productId; | ||
179 | } | 209 | } |
180 | 210 | ||
181 | return $result; | 211 | return $result; |
@@ -60,7 +60,55 @@ class OptController extends AbstractAction | @@ -60,7 +60,55 @@ class OptController extends AbstractAction | ||
60 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | 60 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); |
61 | break; | 61 | break; |
62 | } | 62 | } |
63 | + } while (false); | ||
64 | + | ||
65 | + $this->echoJson($result); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * 商品收藏/取消收藏 | ||
70 | + * | ||
71 | + * @param int id 商品ID | ||
72 | + * @param string opt 操作标识("ok":表示收藏,"cancel":表示取消收藏) | ||
73 | + * @return json | ||
74 | + */ | ||
75 | + public function favoriteProductAction() | ||
76 | + { | ||
77 | + $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | ||
63 | 78 | ||
79 | + do { | ||
80 | + /* 判断是否是AJAX请求 */ | ||
81 | + if (!$this->isAjax()) { | ||
82 | + break; | ||
83 | + } | ||
84 | + | ||
85 | + /* 判断品牌ID是否有效 */ | ||
86 | + $id = $this->post('id'); | ||
87 | + if (!is_numeric($id)) { | ||
88 | + break; | ||
89 | + } | ||
90 | + | ||
91 | + /* 判断用户是否登录 */ | ||
92 | + $uid = $this->getUid(); | ||
93 | + if (!$uid) { | ||
94 | + $referer = $this->server('HTTP_REFERER', SITE_MAIN); | ||
95 | + $result = array('code' => 400, 'message' => '未登录', 'data' => Helpers::url('/signin.html', array('refer' => $referer))); | ||
96 | + break; | ||
97 | + } | ||
98 | + | ||
99 | + /* 取消收藏 */ | ||
100 | + $opt = $this->post('opt', 'ok'); | ||
101 | + if ($opt !== 'ok') { | ||
102 | + $result = BrandData::favoriteCancel($id, $uid, false); | ||
103 | + break; | ||
104 | + } | ||
105 | + | ||
106 | + /* 收藏 */ | ||
107 | + $result = BrandData::favorite($id, $uid, false); | ||
108 | + if (!isset($result['code'])) { | ||
109 | + $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | ||
110 | + break; | ||
111 | + } | ||
64 | } while (false); | 112 | } while (false); |
65 | 113 | ||
66 | $this->echoJson($result); | 114 | $this->echoJson($result); |
yohobuy/m.yohobuy.com/public/index-pre.php
0 → 100644
1 | +<?php | ||
2 | +use Yaf\Application; | ||
3 | + | ||
4 | +define('SITE_MAIN', 'http://m.yohobuy.com'); // 网站主域名 | ||
5 | +define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名 | ||
6 | +define('COOKIE_DOMAIN', '.m.yohobuy.com'); // COOKIE作用域 | ||
7 | +define('SUB_DOMAIN', '.m.yohobuy.com'); // 子域名后缀 | ||
8 | +define('USE_CACHE', false); // 缓存的开关 | ||
9 | +define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录 | ||
10 | +define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录 | ||
11 | +defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'preview'); | ||
12 | + | ||
13 | +$application = new Application(APPLICATION_PATH . '/configs/application.preview.ini'); | ||
14 | +$application->bootstrap()->run(); |
-
Please register or login to post a comment