fixes bug refs YW-1052
Showing
13 changed files
with
103 additions
and
32 deletions
@@ -39,6 +39,7 @@ class CacheConfig | @@ -39,6 +39,7 @@ class CacheConfig | ||
39 | const KEY_ACTION_PRODUCT_BRAND_DOMAINS = 'key_action_product_brand_domains'; // 所有品牌域名列表 | 39 | const KEY_ACTION_PRODUCT_BRAND_DOMAINS = 'key_action_product_brand_domains'; // 所有品牌域名列表 |
40 | const KEY_ACTION_PRODUCT_BRAND_NAMES = 'key_action_product_brand_names'; // 所有品牌名称列表 | 40 | const KEY_ACTION_PRODUCT_BRAND_NAMES = 'key_action_product_brand_names'; // 所有品牌名称列表 |
41 | const KEY_ACTION_PRODUCT_BRAND_LOGO = 'key_action_product_brand_logo'; // 品牌信息 | 41 | const KEY_ACTION_PRODUCT_BRAND_LOGO = 'key_action_product_brand_logo'; // 品牌信息 |
42 | + const KEY_ACTION_PRODUCT_BRAND_LOGO_DOMAIN = 'key_action_product_brand_logo_domain'; // 品牌信息通过域名取得 | ||
42 | 43 | ||
43 | const KEY_ACTION_SEARCH_SEARCH = 'key_action_search_search'; // 搜索的数据 | 44 | const KEY_ACTION_SEARCH_SEARCH = 'key_action_search_search'; // 搜索的数据 |
44 | const KEY_ACTION_SEARCH_FILTER = 'key_action_search_filter'; // 搜索的过滤条件 | 45 | const KEY_ACTION_SEARCH_FILTER = 'key_action_search_filter'; // 搜索的过滤条件 |
@@ -213,4 +213,15 @@ class BrandData | @@ -213,4 +213,15 @@ class BrandData | ||
213 | return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByids', array($id )); | 213 | return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByids', array($id )); |
214 | } | 214 | } |
215 | 215 | ||
216 | + /** | ||
217 | + * 通过域名获取品牌LOGO信息 | ||
218 | + * | ||
219 | + * @param int $id 用户ID | ||
220 | + * @return array | ||
221 | + */ | ||
222 | + public static function getBrandLogoByDomain($domain) | ||
223 | + { | ||
224 | + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByDomain', array($domain )); | ||
225 | + } | ||
226 | + | ||
216 | } | 227 | } |
@@ -15,6 +15,7 @@ use Api\Yohobuy; | @@ -15,6 +15,7 @@ use Api\Yohobuy; | ||
15 | */ | 15 | */ |
16 | class DetailData | 16 | class DetailData |
17 | { | 17 | { |
18 | + | ||
18 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; | 19 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; |
19 | const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; | 20 | const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/'; |
20 | 21 | ||
@@ -38,13 +39,11 @@ class DetailData | @@ -38,13 +39,11 @@ class DetailData | ||
38 | $clientType = $isApp ? 'iphone' : 'h5'; | 39 | $clientType = $isApp ? 'iphone' : 'h5'; |
39 | 40 | ||
40 | // 获取资讯 | 41 | // 获取资讯 |
41 | - $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType)); | ||
42 | - if (!isset($article['tag'])) { | 42 | + $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType), 3600); |
43 | + if (!isset($article['author_id'])) { | ||
43 | return $result; | 44 | return $result; |
44 | } | 45 | } |
45 | - else { | ||
46 | $result['getArticle'] = $article; | 46 | $result['getArticle'] = $article; |
47 | - } | ||
48 | 47 | ||
49 | // 获取作者信息 | 48 | // 获取作者信息 |
50 | Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($article['author_id'], $clientType), function ($retval) use (&$result) { | 49 | Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($article['author_id'], $clientType), function ($retval) use (&$result) { |
@@ -62,9 +61,11 @@ class DetailData | @@ -62,9 +61,11 @@ class DetailData | ||
62 | }); | 61 | }); |
63 | 62 | ||
64 | // 获取资讯相关的其它资讯 | 63 | // 获取资讯相关的其它资讯 |
64 | + if (isset($article['tag'])) { | ||
65 | Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getOtherArticle', array($article['tag'], $id, 0, 3, $clientType), function ($retval) use (&$result) { | 65 | Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getOtherArticle', array($article['tag'], $id, 0, 3, $clientType), function ($retval) use (&$result) { |
66 | $result['getOtherArticle'] = empty($retval) ? array() : $retval; | 66 | $result['getOtherArticle'] = empty($retval) ? array() : $retval; |
67 | }); | 67 | }); |
68 | + } | ||
68 | 69 | ||
69 | // 调用发起请求 | 70 | // 调用发起请求 |
70 | Yohobuy::yarConcurrentLoop(); | 71 | Yohobuy::yarConcurrentLoop(); |
@@ -23,7 +23,7 @@ class BoysController extends AbstractAction | @@ -23,7 +23,7 @@ class BoysController extends AbstractAction | ||
23 | } | 23 | } |
24 | 24 | ||
25 | // 设置COOKIE标识用户访问过该页面了 | 25 | // 设置COOKIE标识用户访问过该页面了 |
26 | - Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_BOYS); | 26 | + // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_BOYS); |
27 | 27 | ||
28 | // 设置网站标题 | 28 | // 设置网站标题 |
29 | $this->setTitle('男生首页'); | 29 | $this->setTitle('男生首页'); |
@@ -18,7 +18,7 @@ class GirlsController extends AbstractAction | @@ -18,7 +18,7 @@ class GirlsController extends AbstractAction | ||
18 | $this->setExpires(300); // 缓存5分钟 | 18 | $this->setExpires(300); // 缓存5分钟 |
19 | 19 | ||
20 | // 设置COOKIE标识用户访问过该页面了 | 20 | // 设置COOKIE标识用户访问过该页面了 |
21 | - Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS); | 21 | + // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS); |
22 | 22 | ||
23 | // 设置网站标题 | 23 | // 设置网站标题 |
24 | $this->setTitle('女生首页'); | 24 | $this->setTitle('女生首页'); |
@@ -18,7 +18,7 @@ class KidsController extends AbstractAction | @@ -18,7 +18,7 @@ class KidsController extends AbstractAction | ||
18 | $this->setExpires(300); // 缓存5分钟 | 18 | $this->setExpires(300); // 缓存5分钟 |
19 | 19 | ||
20 | // 设置COOKIE标识用户访问过该页面了 | 20 | // 设置COOKIE标识用户访问过该页面了 |
21 | - Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS); | 21 | + // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS); |
22 | 22 | ||
23 | // 设置网站标题 | 23 | // 设置网站标题 |
24 | $this->setTitle('潮童首页'); | 24 | $this->setTitle('潮童首页'); |
@@ -18,7 +18,7 @@ class LifestyleController extends AbstractAction | @@ -18,7 +18,7 @@ class LifestyleController extends AbstractAction | ||
18 | $this->setExpires(300); // 缓存5分钟 | 18 | $this->setExpires(300); // 缓存5分钟 |
19 | 19 | ||
20 | // 设置COOKIE标识用户访问过该页面了 | 20 | // 设置COOKIE标识用户访问过该页面了 |
21 | - Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE); | 21 | + // Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE); |
22 | 22 | ||
23 | // 设置网站标题 | 23 | // 设置网站标题 |
24 | $this->setTitle('创意生活首页'); | 24 | $this->setTitle('创意生活首页'); |
@@ -16,11 +16,6 @@ class SearchController extends AbstractAction | @@ -16,11 +16,6 @@ class SearchController extends AbstractAction | ||
16 | */ | 16 | */ |
17 | public function indexAction() | 17 | public function indexAction() |
18 | { | 18 | { |
19 | - // 设置客户端浏览器1小时内不改变 | ||
20 | - $this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y'))); | ||
21 | - // 设置浏览器缓存5分钟 | ||
22 | - $this->setExpires(300); // 缓存5分钟 | ||
23 | - | ||
24 | $this->setNavHeader('搜索', true, SITE_MAIN); | 19 | $this->setNavHeader('搜索', true, SITE_MAIN); |
25 | 20 | ||
26 | //$this->_view->html('search'); | 21 | //$this->_view->html('search'); |
@@ -168,7 +168,7 @@ class ListModel | @@ -168,7 +168,7 @@ class ListModel | ||
168 | } | 168 | } |
169 | 169 | ||
170 | // 调用接口查询数据 | 170 | // 调用接口查询数据 |
171 | - $brandLogo = BrandData::getBrandLogo($id); | 171 | + $brandLogo = BrandData::getBrandLogo($id); var_dump($brandLogo); exit; |
172 | // 处理返回的数据 | 172 | // 处理返回的数据 |
173 | if (isset($brandLogo['data'][0])) { | 173 | if (isset($brandLogo['data'][0])) { |
174 | $result = array( | 174 | $result = array( |
@@ -194,6 +194,53 @@ class ListModel | @@ -194,6 +194,53 @@ class ListModel | ||
194 | } | 194 | } |
195 | 195 | ||
196 | /** | 196 | /** |
197 | + * 根据品牌ID获取品牌LOGO | ||
198 | + * | ||
199 | + * @param int $id 品牌ID | ||
200 | + * @param string $title 品牌标题 | ||
201 | + * @return array | false | ||
202 | + */ | ||
203 | + public static function getBrandLogoByDomain($domain, &$title) | ||
204 | + { | ||
205 | + $result = false; | ||
206 | + | ||
207 | + if (USE_CACHE) { | ||
208 | + $key = CacheConfig::KEY_ACTION_PRODUCT_BRAND_LOGO_DOMAIN . strval($domain); | ||
209 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
210 | + $result = Cache::get($key, 'master'); | ||
211 | + if (!empty($result)) { | ||
212 | + return $result; | ||
213 | + } | ||
214 | + } | ||
215 | + | ||
216 | + // 调用接口查询数据 | ||
217 | + $brandLogo = BrandData::getBrandLogoByDomain($domain); | ||
218 | + // 处理返回的数据 | ||
219 | + if (isset($brandLogo['data'])) { | ||
220 | + $result = array( | ||
221 | + 'id' => $brandLogo['data']['id'], | ||
222 | + 'url' => Helpers::url('', null, $brandLogo['data']['brand_domain']), | ||
223 | + 'thumb' => Helpers::getImageUrl($brandLogo['data']['brand_ico'], 75, 40), | ||
224 | + 'name' => $brandLogo['data']['brand_name'], | ||
225 | + ); | ||
226 | + $title = $result['name']; | ||
227 | + } | ||
228 | + | ||
229 | + if (USE_CACHE) { | ||
230 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
231 | + if (empty($result)) { | ||
232 | + $result = Cache::get($key, 'slave'); | ||
233 | + } | ||
234 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
235 | + else { | ||
236 | + Cache::set($key, $result); // 缓存1小时 | ||
237 | + } | ||
238 | + } | ||
239 | + | ||
240 | + return $result; | ||
241 | + } | ||
242 | + | ||
243 | + /** | ||
197 | * 获取所有的品牌名称列表 | 244 | * 获取所有的品牌名称列表 |
198 | * | 245 | * |
199 | * @return array( | 246 | * @return array( |
@@ -28,6 +28,8 @@ class IndexController extends AbstractAction | @@ -28,6 +28,8 @@ class IndexController extends AbstractAction | ||
28 | $gender = $this->get('gender', '1,2,3'); | 28 | $gender = $this->get('gender', '1,2,3'); |
29 | if (is_string($gender)) { | 29 | if (is_string($gender)) { |
30 | $gender = rawurldecode($gender); | 30 | $gender = rawurldecode($gender); |
31 | + } else { | ||
32 | + $gender = Helpers::getGenderByCookie(); | ||
31 | } | 33 | } |
32 | // // 设置侧边栏逛的默认选中状态 | 34 | // // 设置侧边栏逛的默认选中状态 |
33 | // if ($gender === '1,3') { | 35 | // if ($gender === '1,3') { |
@@ -26,19 +26,27 @@ class InfoController extends AbstractAction | @@ -26,19 +26,27 @@ class InfoController extends AbstractAction | ||
26 | $this->error(); | 26 | $this->error(); |
27 | } | 27 | } |
28 | 28 | ||
29 | + $data = array(); | ||
30 | + $data['guangDetail'] = true; // 模板中使用JS的标识 | ||
31 | + $data['guang']['id'] = $id; | ||
32 | + | ||
29 | // 标识是不是APP访问的 | 33 | // 标识是不是APP访问的 |
30 | $isApp = null !== $this->get('app_version', null); | 34 | $isApp = null !== $this->get('app_version', null); |
31 | - // 获取详情内容信息, 异常则跳到错误页面 | ||
32 | - $detail = DetailData::package($id, $isApp); | ||
33 | - if (empty($detail['getArticle'])) { | ||
34 | - $this->error(); | ||
35 | - } | 35 | + // 标识是否是微信访问 |
36 | + $isWeixin = stripos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false; | ||
36 | 37 | ||
37 | // WAP上设置头部导航 | 38 | // WAP上设置头部导航 |
38 | - if (!$isApp) { | 39 | + if (!$isApp && !$isWeixin) { |
39 | $this->setNavHeader('逛', true, SITE_MAIN); | 40 | $this->setNavHeader('逛', true, SITE_MAIN); |
40 | } | 41 | } |
41 | 42 | ||
43 | + // 获取详情内容信息, 异常则跳到错误页面 | ||
44 | + $detail = DetailData::package($id, $isApp); | ||
45 | + if (empty($detail['getArticle'])) { | ||
46 | + $this->_view->display('index', $data); | ||
47 | + return; | ||
48 | + } | ||
49 | + | ||
42 | $data = array(); | 50 | $data = array(); |
43 | $data['guangDetail'] = true; // 模板中使用JS的标识 | 51 | $data['guangDetail'] = true; // 模板中使用JS的标识 |
44 | $data['guang']['id'] = $id; | 52 | $data['guang']['id'] = $id; |
@@ -209,8 +217,7 @@ class InfoController extends AbstractAction | @@ -209,8 +217,7 @@ class InfoController extends AbstractAction | ||
209 | if ($type == 'fav') { | 217 | if ($type == 'fav') { |
210 | 218 | ||
211 | } | 219 | } |
212 | - } | ||
213 | - while (false); | 220 | + } while (false); |
214 | } | 221 | } |
215 | 222 | ||
216 | } | 223 | } |
@@ -85,18 +85,23 @@ class IndexController extends AbstractAction | @@ -85,18 +85,23 @@ class IndexController extends AbstractAction | ||
85 | $this->go(SITE_MAIN); | 85 | $this->go(SITE_MAIN); |
86 | } | 86 | } |
87 | 87 | ||
88 | - /* 通过品牌域名找到对应的品牌ID */ | ||
89 | - $domainList = Product\ListModel::getAllBrandDomains(); | ||
90 | - $brandIds = array_keys($domainList, $domain); | 88 | + // 存标题信息 |
89 | + $title = ''; | ||
90 | + $brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title); | ||
91 | $brandId = 0; | 91 | $brandId = 0; |
92 | - if (isset($brandIds[0])) { | ||
93 | - $brandId = $brandIds[0]; | 92 | + if ($brandLogo && isset($brandLogo['id'])) { |
93 | + $brandId = $brandLogo['id']; | ||
94 | } | 94 | } |
95 | 95 | ||
96 | + /* 通过品牌域名找到对应的品牌ID */ | ||
97 | +// $domainList = Product\ListModel::getAllBrandDomains(); | ||
98 | +// $brandIds = array_keys($domainList, $domain); | ||
99 | +// $brandId = 0; | ||
100 | +// if (isset($brandIds[0])) { | ||
101 | +// $brandId = $brandIds[0]; | ||
102 | +// } | ||
96 | // 当前的登录用户UID | 103 | // 当前的登录用户UID |
97 | $uid = $this->getUid(); | 104 | $uid = $this->getUid(); |
98 | - // 存标题信息 | ||
99 | - $title = ''; | ||
100 | 105 | ||
101 | /* 搜索框相关 */ | 106 | /* 搜索框相关 */ |
102 | $from = $this->get('from'); | 107 | $from = $this->get('from'); |
@@ -131,12 +136,13 @@ class IndexController extends AbstractAction | @@ -131,12 +136,13 @@ class IndexController extends AbstractAction | ||
131 | // 从搜索页过来的,显示搜索框, 和进入品牌引导信息 | 136 | // 从搜索页过来的,显示搜索框, 和进入品牌引导信息 |
132 | if ($from === 'search') { | 137 | if ($from === 'search') { |
133 | $data['goodList'] = array(); | 138 | $data['goodList'] = array(); |
134 | - $data['goodList']['brandWay'] = \Product\ListModel::getBrandLogoByIds($brandId, $title); | 139 | + //$data['goodList']['brandWay'] = \Product\ListModel::getBrandLogoByIds($brandId, $title); |
140 | + $data['goodList']['brandWay'] = $brandLogo; | ||
135 | $data['goodList']['search']['default'] = $query; | 141 | $data['goodList']['search']['default'] = $query; |
136 | $data['goodList']['search']['url'] = Helpers::url('', null, 'search'); | 142 | $data['goodList']['search']['url'] = Helpers::url('', null, 'search'); |
137 | } | 143 | } |
138 | // 品牌一览过来的展示品牌介绍和LOGO | 144 | // 品牌一览过来的展示品牌介绍和LOGO |
139 | - else { | 145 | + elseif ($brandId !== 0) { |
140 | $data['brandHome'] = \Product\ListModel::getBrandIntro($brandId, $uid, $title); | 146 | $data['brandHome'] = \Product\ListModel::getBrandIntro($brandId, $uid, $title); |
141 | $data['goodList'] = array(); | 147 | $data['goodList'] = array(); |
142 | } | 148 | } |
@@ -40,7 +40,7 @@ class OptController extends AbstractAction | @@ -40,7 +40,7 @@ class OptController extends AbstractAction | ||
40 | } | 40 | } |
41 | 41 | ||
42 | /* 判断用户是否登录 */ | 42 | /* 判断用户是否登录 */ |
43 | - $uid = $this->getUdid(); | 43 | + $uid = $this->getUid(); |
44 | if (!$uid) { | 44 | if (!$uid) { |
45 | $referer = $this->server('HTTP_REFERER', SITE_MAIN); | 45 | $referer = $this->server('HTTP_REFERER', SITE_MAIN); |
46 | $result = array('code' => 400, 'message' => '未登录', 'data' => Helpers::url('/signin.html', array('refer' => $referer))); | 46 | $result = array('code' => 400, 'message' => '未登录', 'data' => Helpers::url('/signin.html', array('refer' => $referer))); |
@@ -60,6 +60,7 @@ class OptController extends AbstractAction | @@ -60,6 +60,7 @@ 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 | + | ||
63 | } while (false); | 64 | } while (false); |
64 | 65 | ||
65 | $this->echoJson($result); | 66 | $this->echoJson($result); |
-
Please register or login to post a comment