do add product detail preference goods
Showing
5 changed files
with
78 additions
and
20 deletions
@@ -63,4 +63,19 @@ class DetailData | @@ -63,4 +63,19 @@ class DetailData | ||
63 | ) ); | 63 | ) ); |
64 | } | 64 | } |
65 | 65 | ||
66 | + /** | ||
67 | + * 为你优选的商品列表 | ||
68 | + * | ||
69 | + * @param int $productSkn 商品SKN号 | ||
70 | + * @return array | ||
71 | + */ | ||
72 | + public static function preference($productSkn) | ||
73 | + { | ||
74 | + $param = Yohobuy::param(); | ||
75 | + $param['product_skn'] = $productSkn; | ||
76 | + $param['client_secret'] = Sign::getSign($param); | ||
77 | + | ||
78 | + return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 缓存1小时 | ||
79 | + } | ||
80 | + | ||
66 | } | 81 | } |
@@ -65,25 +65,25 @@ class HomeController extends AbstractAction | @@ -65,25 +65,25 @@ class HomeController extends AbstractAction | ||
65 | $this->_view->display('index', $data); | 65 | $this->_view->display('index', $data); |
66 | } | 66 | } |
67 | 67 | ||
68 | - /** | ||
69 | - * 为您优选 | ||
70 | - */ | ||
71 | - public function preferenceAction() | ||
72 | - { | ||
73 | - $result = array(); | ||
74 | - | ||
75 | - if ($this->isAjax()) { | ||
76 | - // 优选新品数据 | ||
77 | - $channel = Helpers::getChannelByCookie(); | ||
78 | - $result = UserModel::getPreferenceData($channel); | ||
79 | - } | ||
80 | - | ||
81 | - if (empty($result)) { | ||
82 | - echo ' '; | ||
83 | - } else { | ||
84 | - $this->_view->display('recommend-content', $result); | ||
85 | - } | ||
86 | - } | 68 | + /** |
69 | + * 为您优选 | ||
70 | + */ | ||
71 | + public function preferenceAction() | ||
72 | + { | ||
73 | + $result = array(); | ||
74 | + | ||
75 | + if ($this->isAjax()) { | ||
76 | + // 优选新品数据 | ||
77 | + $channel = Helpers::getChannelByCookie(); | ||
78 | + $result = UserModel::getPreferenceData($channel); | ||
79 | + } | ||
80 | + | ||
81 | + if (empty($result)) { | ||
82 | + echo ' '; | ||
83 | + } else { | ||
84 | + $this->_view->display('recommend-content', $result); | ||
85 | + } | ||
86 | + } | ||
87 | 87 | ||
88 | /** | 88 | /** |
89 | * 用户收藏的商品 | 89 | * 用户收藏的商品 |
@@ -395,4 +395,26 @@ class DetailModel | @@ -395,4 +395,26 @@ class DetailModel | ||
395 | return $result; | 395 | return $result; |
396 | } | 396 | } |
397 | 397 | ||
398 | + /** | ||
399 | + * 获取为你优选的商品 | ||
400 | + * | ||
401 | + * @param int $productSkn 商品SKN | ||
402 | + * @return array | ||
403 | + */ | ||
404 | + public static function getPreference($productSkn) | ||
405 | + { | ||
406 | + $result = array(); | ||
407 | + | ||
408 | + if (is_numeric($productSkn)) { | ||
409 | + $preference = DetailData::preference($productSkn); | ||
410 | + if (!empty($preference['data'])) { | ||
411 | + foreach ($preference['data'] as $value) { | ||
412 | + $result['recommendList'][] = Helpers::formatProduct($value, false, true, true, 299, 388, false, false); | ||
413 | + } | ||
414 | + } | ||
415 | + } | ||
416 | + | ||
417 | + return $result; | ||
418 | + } | ||
419 | + | ||
398 | } | 420 | } |
@@ -47,7 +47,6 @@ class DetailController extends AbstractAction | @@ -47,7 +47,6 @@ class DetailController extends AbstractAction | ||
47 | public function introAction() | 47 | public function introAction() |
48 | { | 48 | { |
49 | $productSkn = $this->param('productSkn'); | 49 | $productSkn = $this->param('productSkn'); |
50 | - $productSkn = 50027562; | ||
51 | if (!is_numeric($productSkn)) { | 50 | if (!is_numeric($productSkn)) { |
52 | $this->error(); | 51 | $this->error(); |
53 | } | 52 | } |
@@ -164,4 +163,26 @@ class DetailController extends AbstractAction | @@ -164,4 +163,26 @@ class DetailController extends AbstractAction | ||
164 | $this->_view->display('consultform', $data); | 163 | $this->_view->display('consultform', $data); |
165 | } | 164 | } |
166 | 165 | ||
166 | + /** | ||
167 | + * 为你优选 | ||
168 | + * | ||
169 | + * @param int productSkn 商品SKN号 | ||
170 | + * @return json | ||
171 | + */ | ||
172 | + public function preferenceAction() | ||
173 | + { | ||
174 | + $result = array(); | ||
175 | + | ||
176 | + if ($this->isAjax()) { | ||
177 | + $productSkn = $this->get('productSkn'); | ||
178 | + $result = \Product\DetailModel::getPreference($productSkn); | ||
179 | + } | ||
180 | + | ||
181 | + if (empty($result)) { | ||
182 | + echo ' '; | ||
183 | + } else { | ||
184 | + $this->_view->display('preference', $result); | ||
185 | + } | ||
186 | + } | ||
187 | + | ||
167 | } | 188 | } |
-
Please register or login to post a comment