fixes bug refs YW-1052
Showing
13 changed files
with
117 additions
and
46 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'; // 搜索的过滤条件 |
@@ -212,5 +212,16 @@ class BrandData | @@ -212,5 +212,16 @@ class BrandData | ||
212 | { | 212 | { |
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 | + | ||
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 | + } | ||
215 | 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 | ||
@@ -36,15 +37,13 @@ class DetailData | @@ -36,15 +37,13 @@ class DetailData | ||
36 | 37 | ||
37 | // 客户端类型 | 38 | // 客户端类型 |
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; | ||
47 | - } | 46 | + $result['getArticle'] = $article; |
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 | // 获取资讯相关的其它资讯 |
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; | ||
67 | - }); | 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) { | ||
66 | + $result['getOtherArticle'] = empty($retval) ? array() : $retval; | ||
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( |
@@ -192,6 +192,53 @@ class ListModel | @@ -192,6 +192,53 @@ class ListModel | ||
192 | 192 | ||
193 | return $result; | 193 | return $result; |
194 | } | 194 | } |
195 | + | ||
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 | + } | ||
195 | 242 | ||
196 | /** | 243 | /** |
197 | * 获取所有的品牌名称列表 | 244 | * 获取所有的品牌名称列表 |
@@ -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,18 +26,26 @@ class InfoController extends AbstractAction | @@ -26,18 +26,26 @@ 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 | + } |
42 | + | ||
43 | + // 获取详情内容信息, 异常则跳到错误页面 | ||
44 | + $detail = DetailData::package($id, $isApp); | ||
45 | + if (empty($detail['getArticle'])) { | ||
46 | + $this->_view->display('index', $data); | ||
47 | + return; | ||
48 | + } | ||
41 | 49 | ||
42 | $data = array(); | 50 | $data = array(); |
43 | $data['guangDetail'] = true; // 模板中使用JS的标识 | 51 | $data['guangDetail'] = true; // 模板中使用JS的标识 |
@@ -179,7 +187,7 @@ class InfoController extends AbstractAction | @@ -179,7 +187,7 @@ class InfoController extends AbstractAction | ||
179 | $data['shareImg'] = Helpers::getImageUrl($detail['getArticle']['cover_image'], 640, 320); | 187 | $data['shareImg'] = Helpers::getImageUrl($detail['getArticle']['cover_image'], 640, 320); |
180 | } | 188 | } |
181 | } | 189 | } |
182 | - | 190 | + |
183 | // 标识有微信分享 | 191 | // 标识有微信分享 |
184 | $data['hasWxShare'] = true; | 192 | $data['hasWxShare'] = true; |
185 | 193 | ||
@@ -188,7 +196,7 @@ class InfoController extends AbstractAction | @@ -188,7 +196,7 @@ class InfoController extends AbstractAction | ||
188 | $detail = array(); | 196 | $detail = array(); |
189 | $data = array(); | 197 | $data = array(); |
190 | } | 198 | } |
191 | - | 199 | + |
192 | /** | 200 | /** |
193 | * APP里使用的收藏内容的接口 | 201 | * APP里使用的收藏内容的接口 |
194 | * | 202 | * |
@@ -202,15 +210,14 @@ class InfoController extends AbstractAction | @@ -202,15 +210,14 @@ class InfoController extends AbstractAction | ||
202 | if (!$this->isAjax()) { | 210 | if (!$this->isAjax()) { |
203 | break; | 211 | break; |
204 | } | 212 | } |
205 | - | 213 | + |
206 | $id = $this->get('id'); | 214 | $id = $this->get('id'); |
207 | $type = $this->get('type'); | 215 | $type = $this->get('type'); |
208 | // 收藏 | 216 | // 收藏 |
209 | if ($type == 'fav') { | 217 | if ($type == 'fav') { |
210 | - | ||
211 | - } | ||
212 | - } | ||
213 | - while (false); | 218 | + |
219 | + } | ||
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]; | ||
94 | - } | ||
95 | - | 92 | + if ($brandLogo && isset($brandLogo['id'])) { |
93 | + $brandId = $brandLogo['id']; | ||
94 | + } | ||
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'); |
@@ -114,7 +119,7 @@ class IndexController extends AbstractAction | @@ -114,7 +119,7 @@ class IndexController extends AbstractAction | ||
114 | 'gender' => FILTER_DEFAULT, | 119 | 'gender' => FILTER_DEFAULT, |
115 | 'p_d' => FILTER_DEFAULT,), false); | 120 | 'p_d' => FILTER_DEFAULT,), false); |
116 | $condition['brand'] = $brandId; | 121 | $condition['brand'] = $brandId; |
117 | - | 122 | + |
118 | if ($brandId === 0) { | 123 | if ($brandId === 0) { |
119 | $condition['query'] = $domain; | 124 | $condition['query'] = $domain; |
120 | } | 125 | } |
@@ -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