code review by fei.hong: do merge yang.yang and shaofeng codes
Showing
6 changed files
with
14 additions
and
128 deletions
@@ -84,13 +84,13 @@ class BrandData | @@ -84,13 +84,13 @@ class BrandData | ||
84 | /** | 84 | /** |
85 | * 通过品牌id获取品牌Folder | 85 | * 通过品牌id获取品牌Folder |
86 | * | 86 | * |
87 | - * @param int $brand_id 品牌id | 87 | + * @param int $brandId 品牌id |
88 | * @param int $status 状态 | 88 | * @param int $status 状态 |
89 | * @return array | 89 | * @return array |
90 | */ | 90 | */ |
91 | - public static function getFolderByBrand($brand_id, $status = 1) | 91 | + public static function getFolderByBrand($brandId, $status = 1) |
92 | { | 92 | { |
93 | - return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_FOLDER, 'getFolderByBrand', array($brand_id, $status)); | 93 | + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_FOLDER, 'getFolderByBrand', array($brandId, $status), 600); |
94 | } | 94 | } |
95 | 95 | ||
96 | /** | 96 | /** |
@@ -101,7 +101,7 @@ class BrandData | @@ -101,7 +101,7 @@ class BrandData | ||
101 | */ | 101 | */ |
102 | public static function getByNodeContent($node, $mode = 'release') | 102 | public static function getByNodeContent($node, $mode = 'release') |
103 | { | 103 | { |
104 | - return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_NODECONTENT, 'getByNodeContent', array($node, $mode)); | 104 | + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_NODECONTENT, 'getByNodeContent', array($node, $mode), 600); |
105 | } | 105 | } |
106 | 106 | ||
107 | /* | 107 | /* |
@@ -286,7 +286,7 @@ class HelperSearch | @@ -286,7 +286,7 @@ class HelperSearch | ||
286 | //即将售罄 | 286 | //即将售罄 |
287 | $isFew = $val['is_soon_sold_out'] === 'Y' ? true : false; | 287 | $isFew = $val['is_soon_sold_out'] === 'Y' ? true : false; |
288 | //SALE | 288 | //SALE |
289 | - $isSale = ($val['is_discount'] == 'Y') ? true : false; | 289 | + $isSale = ($val['is_discount'] == 'Y' && $val['market_price']/$val['sales_price'] >= 2) ? true : false; |
290 | //新品节 | 290 | //新品节 |
291 | //再到着 | 291 | //再到着 |
292 | //年终大促 | 292 | //年终大促 |
@@ -1419,7 +1419,7 @@ class HelperSearch | @@ -1419,7 +1419,7 @@ class HelperSearch | ||
1419 | $result[$key]['isVedio'] = true; | 1419 | $result[$key]['isVedio'] = true; |
1420 | $result[$key]['src'] = $vo; | 1420 | $result[$key]['src'] = $vo; |
1421 | } else { | 1421 | } else { |
1422 | - $result[$key]['href'] = isset($href[1][$key]) ? $href[1][$key] : ''; | 1422 | + $result[$key]['href'] = isset($href[1][$key]) ? str_replace('&', '&', $href[1][$key]) : ''; |
1423 | $result[$key]['src'] = $vo; | 1423 | $result[$key]['src'] = $vo; |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
@@ -1427,6 +1427,7 @@ class HelperSearch | @@ -1427,6 +1427,7 @@ class HelperSearch | ||
1427 | } | 1427 | } |
1428 | } | 1428 | } |
1429 | 1429 | ||
1430 | + | ||
1430 | /** | 1431 | /** |
1431 | * 组织品牌店铺信息 | 1432 | * 组织品牌店铺信息 |
1432 | * @param $shop 搜索接口返回的,店铺数据,用于搜索品牌时显示品牌信息条 | 1433 | * @param $shop 搜索接口返回的,店铺数据,用于搜索品牌时显示品牌信息条 |
@@ -42,21 +42,7 @@ class BrandsModel | @@ -42,21 +42,7 @@ class BrandsModel | ||
42 | { | 42 | { |
43 | //获取$condition和$option 筛选条件和排序条件 | 43 | //获取$condition和$option 筛选条件和排序条件 |
44 | $searchCondition = SearchModel::searchCondition($condition, $options); | 44 | $searchCondition = SearchModel::searchCondition($condition, $options); |
45 | - if (USE_CACHE) { | ||
46 | - $key = WebCacheConfig::KEY_WEB_PRODUCT_INDEX_BRAND; | ||
47 | - if (!empty($searchCondition['userInput'])) { | ||
48 | - $key .= http_build_query($searchCondition['userInput'], null, '&'); | ||
49 | - } | ||
50 | - $key .= http_build_query($condition, null, '&'); | ||
51 | - $channel = HomeModel::getSwitchChannel(); | ||
52 | - //key加上性别参数 | ||
53 | - $key .= $channel; | ||
54 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
55 | - $result = Cache::get($key, 'master'); | ||
56 | - if (!empty($result)) { | ||
57 | - return $result; | ||
58 | - } | ||
59 | - } | 45 | + |
60 | // 并行调用品牌相关接口并封装数据 | 46 | // 并行调用品牌相关接口并封装数据 |
61 | $result = self::getBrandData($searchCondition, $options); | 47 | $result = self::getBrandData($searchCondition, $options); |
62 | 48 | ||
@@ -70,16 +56,6 @@ class BrandsModel | @@ -70,16 +56,6 @@ class BrandsModel | ||
70 | $result['leftContent'][]['picLink']['list'] = $nodeContent; | 56 | $result['leftContent'][]['picLink']['list'] = $nodeContent; |
71 | } | 57 | } |
72 | 58 | ||
73 | - if (USE_CACHE) { | ||
74 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
75 | - if (empty($result)) { | ||
76 | - $result = Cache::get($key, 'slave'); | ||
77 | - } | ||
78 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
79 | - elseif(isset($result['goods']) && !empty($result['goods']) && isset($result['leftContent']) && !empty($result['leftContent'])) { | ||
80 | - Cache::set($key, $result, 1800); // 缓存30分钟 | ||
81 | - } | ||
82 | - } | ||
83 | 59 | ||
84 | return $result; | 60 | return $result; |
85 | } | 61 | } |
@@ -152,7 +128,7 @@ class BrandsModel | @@ -152,7 +128,7 @@ class BrandsModel | ||
152 | 'title' => 'YOHO!有货' | 128 | 'title' => 'YOHO!有货' |
153 | ), | 129 | ), |
154 | array( | 130 | array( |
155 | - 'href' => Helpers::url('/brands/brands'), | 131 | + 'href' => Helpers::url('/brands'), |
156 | 'name' => '品牌一览', | 132 | 'name' => '品牌一览', |
157 | 'title' => '品牌一览' | 133 | 'title' => '品牌一览' |
158 | ), | 134 | ), |
@@ -270,7 +246,7 @@ class BrandsModel | @@ -270,7 +246,7 @@ class BrandsModel | ||
270 | $sortCondition= array( | 246 | $sortCondition= array( |
271 | 'attribute_not' => $searchCondition['sortCondition']['attribute_not'], | 247 | 'attribute_not' => $searchCondition['sortCondition']['attribute_not'], |
272 | 'brand' => $searchCondition['sortCondition']['brand'] | 248 | 'brand' => $searchCondition['sortCondition']['brand'] |
273 | - );; | 249 | + ); |
274 | $urlList['sort'] = SearchData::getClassesUrl($sortCondition); | 250 | $urlList['sort'] = SearchData::getClassesUrl($sortCondition); |
275 | 251 | ||
276 | //组合搜索品牌url | 252 | //组合搜索品牌url |
@@ -33,20 +33,7 @@ class IndexModel | @@ -33,20 +33,7 @@ class IndexModel | ||
33 | public static function getIndexData($customCondition, $customOptions) | 33 | public static function getIndexData($customCondition, $customOptions) |
34 | { | 34 | { |
35 | $searchCondition = SearchModel::searchCondition($customCondition, $customOptions); | 35 | $searchCondition = SearchModel::searchCondition($customCondition, $customOptions); |
36 | - | ||
37 | - if (USE_CACHE) { | ||
38 | - $key = WebCacheConfig::KEY_WEB_PRODUCT_LIST_INDEX; | ||
39 | - if (!empty($searchCondition['userInput'])) { | ||
40 | - $key .= http_build_query($searchCondition['userInput'], null, '&'); | ||
41 | - } | ||
42 | - //key加上性别参数 | ||
43 | - $key .= Helpers::getChannelNameByCookie(); | ||
44 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
45 | - $result = Cache::get($key, 'master'); | ||
46 | - if (!empty($result)) { | ||
47 | - return $result; | ||
48 | - } | ||
49 | - } | 36 | + |
50 | 37 | ||
51 | // 组合搜索商品url | 38 | // 组合搜索商品url |
52 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); | 39 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); |
@@ -68,7 +55,7 @@ class IndexModel | @@ -68,7 +55,7 @@ class IndexModel | ||
68 | $misort = isset($searchCondition['condition']['misort']) ? $searchCondition['condition']['misort'] : 0; | 55 | $misort = isset($searchCondition['condition']['misort']) ? $searchCondition['condition']['misort'] : 0; |
69 | $positionId = isset($searchCondition['options']['positionId']) ? $searchCondition['options']['positionId'] : ''; | 56 | $positionId = isset($searchCondition['options']['positionId']) ? $searchCondition['options']['positionId'] : ''; |
70 | $gender = $searchCondition['condition']['gender'] == '2,3' ? 2 : 1; | 57 | $gender = $searchCondition['condition']['gender'] == '2,3' ? 2 : 1; |
71 | - | 58 | + |
72 | if ($msort && $misort && $positionId) { | 59 | if ($msort && $misort && $positionId) { |
73 | $banner = array(); | 60 | $banner = array(); |
74 | $bannerData = SearchData::getBannerData($positionId, $msort, $misort, $gender); | 61 | $bannerData = SearchData::getBannerData($positionId, $msort, $misort, $gender); |
@@ -89,16 +76,6 @@ class IndexModel | @@ -89,16 +76,6 @@ class IndexModel | ||
89 | } | 76 | } |
90 | $result['leftContent'][] = $res; | 77 | $result['leftContent'][] = $res; |
91 | } | 78 | } |
92 | - if (USE_CACHE) { | ||
93 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
94 | - if (empty($result)) { | ||
95 | - $result = Cache::get($key, 'slave'); | ||
96 | - } | ||
97 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
98 | - elseif(isset($data['product']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) { | ||
99 | - Cache::set($key, $result, 600); // 缓存10分钟 | ||
100 | - } | ||
101 | - } | ||
102 | 79 | ||
103 | return $result; | 80 | return $result; |
104 | } | 81 | } |
@@ -32,20 +32,7 @@ class NewModel | @@ -32,20 +32,7 @@ class NewModel | ||
32 | { | 32 | { |
33 | $urlList = array(); | 33 | $urlList = array(); |
34 | $searchCondition = SearchModel::searchCondition($customCondition, $customOptions); | 34 | $searchCondition = SearchModel::searchCondition($customCondition, $customOptions); |
35 | - if (USE_CACHE) { | ||
36 | - $key = WebCacheConfig::KEY_WEB_PRODUCT_LIST_NEW; | ||
37 | - if (!empty($searchCondition['userInput'])) { | ||
38 | - $key .= http_build_query($searchCondition['userInput'], null, '&'); | ||
39 | - } | ||
40 | - $channel = HomeModel::getSwitchChannel(); | ||
41 | - //key加上性别参数 | ||
42 | - $key .= $channel; | ||
43 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
44 | - $result = Cache::get($key, 'master'); | ||
45 | - if (!empty($result)) { | ||
46 | - return $result; | ||
47 | - } | ||
48 | - } | 35 | + |
49 | // 组合搜索商品url | 36 | // 组合搜索商品url |
50 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); | 37 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); |
51 | // 组合搜索分类url | 38 | // 组合搜索分类url |
@@ -61,17 +48,7 @@ class NewModel | @@ -61,17 +48,7 @@ class NewModel | ||
61 | 48 | ||
62 | // 组织模板数据 | 49 | // 组织模板数据 |
63 | $result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']); | 50 | $result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']); |
64 | - | ||
65 | - if (USE_CACHE) { | ||
66 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
67 | - if (empty($result)) { | ||
68 | - $result = Cache::get($key, 'slave'); | ||
69 | - } | ||
70 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
71 | - elseif(isset($data['product']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) { | ||
72 | - Cache::set($key, $result, 1800); // 缓存30分钟 | ||
73 | - } | ||
74 | - } | 51 | + |
75 | return $result; | 52 | return $result; |
76 | } | 53 | } |
77 | 54 |
@@ -183,20 +183,6 @@ class SearchModel | @@ -183,20 +183,6 @@ class SearchModel | ||
183 | public static function getListData($customCondition = array(), $customOptions = array()) | 183 | public static function getListData($customCondition = array(), $customOptions = array()) |
184 | { | 184 | { |
185 | $searchCondition = self::searchCondition($customCondition, $customOptions); | 185 | $searchCondition = self::searchCondition($customCondition, $customOptions); |
186 | - if (USE_CACHE) { | ||
187 | - $key = WebCacheConfig::KEY_WEB_PRODUCT_LIST_SALE; | ||
188 | - if (!empty($searchCondition['userInput'])) { | ||
189 | - $key .= http_build_query($searchCondition['userInput'], null, '&'); | ||
190 | - } | ||
191 | - $channel = HomeModel::getSwitchChannel(); | ||
192 | - //key加上性别参数 | ||
193 | - $key .= $channel; | ||
194 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
195 | - $result = Cache::get($key, 'master'); | ||
196 | - if (!empty($result)) { | ||
197 | - return $result; | ||
198 | - } | ||
199 | - } | ||
200 | // 组合搜索商品url | 186 | // 组合搜索商品url |
201 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); | 187 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); |
202 | // 组合搜索分类url | 188 | // 组合搜索分类url |
@@ -210,16 +196,6 @@ class SearchModel | @@ -210,16 +196,6 @@ class SearchModel | ||
210 | $data = Yohobuy::getMulti($urlList); | 196 | $data = Yohobuy::getMulti($urlList); |
211 | // 组织模板数据 | 197 | // 组织模板数据 |
212 | $result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']); | 198 | $result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']); |
213 | - if (USE_CACHE) { | ||
214 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
215 | - if (empty($result)) { | ||
216 | - $result = Cache::get($key, 'slave'); | ||
217 | - } | ||
218 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
219 | - elseif (isset($data['product']['product_list']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) { | ||
220 | - Cache::set($key, $result, 1800); // 缓存30分钟 | ||
221 | - } | ||
222 | - } | ||
223 | 199 | ||
224 | // 清空不使用的变量 | 200 | // 清空不使用的变量 |
225 | $searchCondition = array(); | 201 | $searchCondition = array(); |
@@ -242,17 +218,6 @@ class SearchModel | @@ -242,17 +218,6 @@ class SearchModel | ||
242 | public static function searchData($customCondition, $customOptions) | 218 | public static function searchData($customCondition, $customOptions) |
243 | { | 219 | { |
244 | $searchCondition = self::searchCondition($customCondition, $customOptions); | 220 | $searchCondition = self::searchCondition($customCondition, $customOptions); |
245 | - if (USE_CACHE) { | ||
246 | - $key = WebCacheConfig::KEY_WEB_PRODUCT_SEARCH_DATA; | ||
247 | - if (!empty($searchCondition['userInput'])) { | ||
248 | - $key .= http_build_query($searchCondition['userInput'], null, '&'); | ||
249 | - } | ||
250 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
251 | - $result = Cache::get($key, 'master'); | ||
252 | - if (!empty($result)) { | ||
253 | - return $result; | ||
254 | - } | ||
255 | - } | ||
256 | $urlList = array(); | 221 | $urlList = array(); |
257 | // 组合搜索商品url | 222 | // 组合搜索商品url |
258 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); | 223 | $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']); |
@@ -274,16 +239,6 @@ class SearchModel | @@ -274,16 +239,6 @@ class SearchModel | ||
274 | } | 239 | } |
275 | // 组织模板数据 | 240 | // 组织模板数据 |
276 | $result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']); | 241 | $result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']); |
277 | - if (USE_CACHE) { | ||
278 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
279 | - if (empty($result)) { | ||
280 | - $result = Cache::get($key, 'slave'); | ||
281 | - } | ||
282 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
283 | - elseif (isset($data['product']['product_list']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) { | ||
284 | - Cache::set($key, $result, 600); // 缓存10分钟 | ||
285 | - } | ||
286 | - } | ||
287 | 242 | ||
288 | // 清空不使用的变量 | 243 | // 清空不使用的变量 |
289 | $searchCondition = array(); | 244 | $searchCondition = array(); |
-
Please register or login to post a comment