do fixes bug to lifestyle maylike data empty filter
Showing
3 changed files
with
81 additions
and
20 deletions
framework @ 75bbc3b0
@@ -67,14 +67,43 @@ class RecomData | @@ -67,14 +67,43 @@ class RecomData | ||
67 | */ | 67 | */ |
68 | public static function mayLikeLifestyle($page = 1, $limit = 50) | 68 | public static function mayLikeLifestyle($page = 1, $limit = 50) |
69 | { | 69 | { |
70 | - $param = Yohobuy::param(); | ||
71 | - $param['method'] = 'app.search.lifeStyle'; | ||
72 | - $param['page'] = $page; | ||
73 | - $param['limit'] = $limit; | ||
74 | - $param['yh_channel'] = '4'; | ||
75 | - $param['client_secret'] = Sign::getSign($param); | 70 | +// $param = Yohobuy::param(); |
71 | +// $param['method'] = 'app.search.lifeStyle'; | ||
72 | +// $param['page'] = $page; | ||
73 | +// $param['limit'] = $limit; | ||
74 | +// $param['yh_channel'] = '4'; | ||
75 | +// $param['client_secret'] = Sign::getSign($param); | ||
76 | +// | ||
77 | +// return Yohobuy::get(Yohobuy::API_URL, $param); | ||
76 | 78 | ||
77 | - return Yohobuy::get(Yohobuy::API_URL, $param); | 79 | + // 人气单品 |
80 | + $param = array( | ||
81 | + array( | ||
82 | + 'stocknumber' => 1, | ||
83 | + 'status' => 1, | ||
84 | + 'order' => 's_n_desc', | ||
85 | + 'viewNum' => $limit, | ||
86 | + 'msort' => '10', | ||
87 | + ), | ||
88 | + 'N', false | ||
89 | + ); | ||
90 | + $result['top'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/search/service/v1/product', 'search', $param, 3600); // 缓存1小时 | ||
91 | + | ||
92 | + // 新品到着 | ||
93 | + $param = array( | ||
94 | + array('status' => 1, 'stocknumber' => 1, 'gender' => ''), | ||
95 | + array( | ||
96 | + array('misort' => 103, 'viewNum' => 10), //数码3c | ||
97 | + array('misort' => 266, 'viewNum' => 10), //居家 | ||
98 | + array('misort' => 280, 'viewNum' => 10), //玩具娱乐 | ||
99 | + array('misort' => 101, 'viewNum' => 10), //办公文具 | ||
100 | + array('misort' => 259, 'viewNum' => 10), //美妆 | ||
101 | + ), | ||
102 | + false | ||
103 | + ); | ||
104 | + $result['new'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/search/service/v1/product', 'searchBySortList', $param, 3600); // 缓存1小时 | ||
105 | + | ||
106 | + return $result; | ||
78 | } | 107 | } |
79 | 108 | ||
80 | } | 109 | } |
@@ -59,7 +59,6 @@ class RecomController extends AbstractAction | @@ -59,7 +59,6 @@ class RecomController extends AbstractAction | ||
59 | $data['goods'][] = Helpers::formatProduct($value, true); | 59 | $data['goods'][] = Helpers::formatProduct($value, true); |
60 | } | 60 | } |
61 | $this->_view->display('maylike', $data); | 61 | $this->_view->display('maylike', $data); |
62 | - | ||
63 | } while (false); | 62 | } while (false); |
64 | 63 | ||
65 | echo ' '; | 64 | echo ' '; |
@@ -121,31 +120,64 @@ class RecomController extends AbstractAction | @@ -121,31 +120,64 @@ class RecomController extends AbstractAction | ||
121 | break; | 120 | break; |
122 | } | 121 | } |
123 | 122 | ||
123 | + /* 创意生活只有一页数据 */ | ||
124 | + $page = $this->get('page', 1); | ||
125 | + if (intval($page) > 1) { | ||
126 | + break; | ||
127 | + } | ||
128 | + | ||
124 | /* 取可能喜欢的数据 */ | 129 | /* 取可能喜欢的数据 */ |
125 | $recom = RecomData::mayLikeLifestyle(); | 130 | $recom = RecomData::mayLikeLifestyle(); |
126 | - if (empty($recom['data']['product_list'])) { | 131 | + |
132 | + /* 构建人气单品数据 */ | ||
133 | + if (empty($recom['top']['data']['product_list'])) { | ||
127 | break; | 134 | break; |
128 | } | 135 | } |
129 | 136 | ||
130 | - /* 构建模板需要的商品数据 */ | ||
131 | $data = array(); | 137 | $data = array(); |
132 | - $build = array(); | ||
133 | - if (!empty($recom['data']['product_list']['top'])) { | 138 | + |
134 | $build = array(); | 139 | $build = array(); |
135 | $build['show'] = true; | 140 | $build['show'] = true; |
136 | - foreach ($recom['data']['product_list']['top'] as $value) { | ||
137 | - $build['goods'][] = Helpers::formatProduct($value, true); | 141 | + foreach ($recom['top']['data']['product_list'] as $value) { |
142 | + $build['goods'][] = Helpers::formatProduct($value, true, false, false); | ||
138 | } | 143 | } |
139 | $data['goodsContainer'][] = $build; | 144 | $data['goodsContainer'][] = $build; |
145 | + | ||
146 | + /* 构建新品到着数据 */ | ||
147 | + if (empty($recom['new']['data']['product_list'])) { | ||
148 | + break; | ||
140 | } | 149 | } |
141 | - if (!empty($recom['data']['product_list']['new'])) { | ||
142 | $build = array(); | 150 | $build = array(); |
143 | - foreach ($recom['data']['product_list']['new'] as $value) { | ||
144 | - $build['show'] = false; | ||
145 | - $build['goods'][] = Helpers::formatProduct($value, true); | 151 | + $build['show'] = true; |
152 | + foreach ($recom['new']['data']['product_list'] as $value) { | ||
153 | + $build['goods'][] = Helpers::formatProduct($value, true, false, false); | ||
146 | } | 154 | } |
147 | $data['goodsContainer'][] = $build; | 155 | $data['goodsContainer'][] = $build; |
148 | - } | 156 | + |
157 | +// if (empty($recom['data']['product_list'])) { | ||
158 | +// break; | ||
159 | +// } | ||
160 | +// | ||
161 | +// /* 构建模板需要的商品数据 */ | ||
162 | +// $data = array(); | ||
163 | +// $build = array(); | ||
164 | +// if (!empty($recom['data']['product_list']['top'])) { | ||
165 | +// $build = array(); | ||
166 | +// $build['show'] = true; | ||
167 | +// foreach ($recom['data']['product_list']['top'] as $value) { | ||
168 | +// $build['goods'][] = Helpers::formatProduct($value, true); | ||
169 | +// } | ||
170 | +// $data['goodsContainer'][] = $build; | ||
171 | +// } | ||
172 | +// if (!empty($recom['data']['product_list']['new'])) { | ||
173 | +// $build = array(); | ||
174 | +// foreach ($recom['data']['product_list']['new'] as $value) { | ||
175 | +// $build['show'] = false; | ||
176 | +// $build['goods'][] = Helpers::formatProduct($value, true); | ||
177 | +// } | ||
178 | +// $data['goodsContainer'][] = $build; | ||
179 | +// } | ||
180 | + | ||
149 | $this->_view->display('maylikelife', $data); | 181 | $this->_view->display('maylikelife', $data); |
150 | 182 | ||
151 | } while (false); | 183 | } while (false); |
-
Please register or login to post a comment