Authored by hf

do fixes bug refs YW-995 add search filter condition cache

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>国际账号登录 | YOHO!有货</title>
<meta name="keywords" content="Yoho! 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款">
<meta name="description" content="YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="cleartype" content="on">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
<script type="text/javascript">
(function(doc, win) {
var docEl = doc.documentElement;
(function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) {
return;
}
docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
}());
})(document, window);
</script>
<link rel="stylesheet" href="http://static.buy.test.yoho.cn/dist/myohobuy/0.0.6/index.css">
</head>
<body class=passport-body>
<div class="login-international-page passport-page yoho-page">
<div class="header">
<a class="go-back" href=/></a>
<p class="title">登录</p>
</div> <div class="content">
<div class="select-container row">
<span class="select-title">国家和地区</span>
<select id="country-select" class="country-select select in-android-uc">
<option value=+61 >澳大利亚</option>
<option value=+82 >韩国</option>
<option value=+1 >加拿大</option>
<option value=+60 >马来西亚</option>
<option value=+1 >美国</option>
<option value=+81 >日本</option>
<option value=+65 >新加坡</option>
<option value=+44 >英国</option>
<option value=+86 selected>中国</option>
<option value=+853 >中国澳门</option>
<option value=+886 >中国台湾</option>
<option value=+852 >中国香港</option>
</select>
<div class="arrow-right"></div>
</div> <div class="input-container phone-container row has-clear">
<span id="area-code" class="area-code">+86</span>
<input id="phone-num" class="input phone-num" type="text" placeholder="手机号" value=>
</div>
<div class="input-container row has-eye">
<input id="pwd" class="pwd input" type="password" placeholder="密码">
</div>
<span id="btn-login" class="btn btn-login disble row">登录</span>
</div>
</div>
<script src="http://static.buy.test.yoho.cn/dist/myohobuy/0.0.6/lib.js"></script>
<script src="http://static.buy.test.yoho.cn/dist/myohobuy/0.0.6/index.js"></script>
<script>
seajs.use('js/common');
</script>
<script>
seajs.use('js/passport/login/international');
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>登录 | YOHO!有货</title>
<meta name="keywords" content="Yoho! 有货官网,潮流志,潮流男装,潮牌,美国潮牌,日本潮牌,香港潮牌,潮牌店,新品首发,欧美潮流,全球购,代购,时尚,流行,特卖,B2C,正品,购物网站,网上购物,货到付款">
<meta name="description" content="YOHO! 有货,年轻人潮流购物中心,中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。作为YOHO!旗下的购物平台,汇集了全球潮流时尚商品和中国最流行的商品,也是国内最大的原创文化商品平台,也是香港,台湾地区流行商品的集中地。同时包含日本、韩国等众多国外潮流品牌,带给您全新潮流购物体验。">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="cleartype" content="on">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
<script type="text/javascript">
(function(doc, win) {
var docEl = doc.documentElement;
(function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) {
return;
}
docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
}());
})(document, window);
</script>
<link rel="stylesheet" href="http://static.buy.test.yoho.cn/dist/myohobuy/0.0.6/index.css">
</head>
<body class=passport-body>
<div class="login-page passport-page yoho-page">
<div class="header">
<a class="go-back" href=/></a>
<div class="img-header"></div>
</div> <div class="content">
<div class="acc-container input-container row has-clear">
<div class="yoho-logo"></div>
<input id="account" class="input account" type="text" placeholder="手机号/邮箱" autocomplete="off" value=>
</div>
<div class="input-container row has-eye">
<input id="pwd" class="pwd input" type="password" placeholder="密码">
</div>
<span id="btn-login" class="btn btn-login disable">登录</span>
<p class="op-container">
<a class="go-register" href=/reg.html>免费注册</a>
<span id="forget-pwd" class="forget-pwd">忘记密码</span>
</p>
<div class="third-party-login">
<span>其他登录方式</span>
<div class="tp-link">
<a class="alipay" href=/passport/login/alipay></a>
<a class="weibo" href=/passport/login/sina></a>
<a class="qq" href=/passport/login/qq></a>
</div>
</div>
<a class="international" href=/login.html>International Customer</a>
<div class="login-tip">
<div class="info-icon"></div>
Yoho!Family账号可登录YOHO!有货
</div>
<div id="retrive-pwd-mask" class="mask"></div>
<ul id="retrive-pwd-ways" class="retrive-pwd-ways">
<li>
<a href=/passport/back/mobile>通过手机找回密码</a>
</li>
<li>
<a href=/passport/back/email>通过邮箱找回密码</a>
</li>
<li id="cancel-retrive">
取消
</li>
</ul>
</div>
</div>
<script src="http://static.buy.test.yoho.cn/dist/myohobuy/0.0.6/lib.js"></script>
<script src="http://static.buy.test.yoho.cn/dist/myohobuy/0.0.6/index.js"></script>
<script>
seajs.use('js/common');
</script>
<script>
seajs.use('js/passport/login/login');
</script>
</body>
</html>
\ No newline at end of file
... ... @@ -210,7 +210,7 @@ class Yohobuy
* @param int $timeout 超时时间,单位是秒
* @return array
*/
public static function getMulti($urlList = array(), $options = array(), $cache = false, $timeout = 3)
public static function getMulti($urlList = array(), $options = array(), $cache = false, $timeout = 5)
{
/* 开启缓存的情况 */
if ($cache && USE_CACHE) {
... ...
... ... @@ -40,6 +40,7 @@ class CacheConfig
const KEY_ACTION_PRODUCT_BRAND_NAMES = 'key_action_product_brand_names'; // 所有品牌名称列表
const KEY_ACTION_PRODUCT_BRAND_LOGO = 'key_action_product_brand_logo'; // 品牌信息
const KEY_ACTION_INDEX_SEARCH = 'key_action_search_search'; // 搜索的数据
const KEY_ACTION_SEARCH_SEARCH = 'key_action_search_search'; // 搜索的数据
const KEY_ACTION_SEARCH_FILTER = 'key_action_search_filter'; // 搜索的过滤条件
}
... ...
... ... @@ -143,7 +143,8 @@ class SearchData
$param = array();
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
if (!isset($orderMaps[ $condition['order'] ] )) {
// $param['needFilter'] = 1; // 是否需要返回筛选条件
if (!isset($condition['order'])) {
$param['order'] = $orderMaps['s_t_desc'];
} else {
$param['order'] = $orderMaps[ $condition['order'] ];
... ...
... ... @@ -291,7 +291,7 @@ class SearchController extends AbstractAction
}
// 区别各种列表页面的筛选数据
$data = Product\FilterModel::getFilterData($condition);
$data = Product\SearchModel::getFilterData($condition);
}
if (empty($data)) {
... ...
... ... @@ -4,6 +4,8 @@ namespace Product;
use Configs\CacheConfig;
use LibModels\Wap\Product\SearchData;
use LibModels\Wap\Category\BrandData;
use LibModels\Wap\Category\ClassData;
use Plugin\DataProcess\ListProcess;
use Plugin\Cache;
... ... @@ -29,7 +31,7 @@ class SearchModel
$result = array();
if (USE_CACHE) {
$key = CacheConfig::KEY_ACTION_INDEX_SEARCH;
$key = CacheConfig::KEY_ACTION_SEARCH_SEARCH;
if (!empty($condition)) {
$key .= http_build_query($condition, null, '&');
}
... ... @@ -41,7 +43,7 @@ class SearchModel
}
// 调用接口查询数据 (使用新的 Elastic Engine)
$listData = SearchData::searchElasticByCondition($condition);
$listData = SearchData::searchElasticByCondition($condition);
// 调用接口查询数据 (使用老的 Sphinx Engine)
// $listData = SearchData::searchByCondition($condition);
// 处理返回的数据
... ... @@ -63,4 +65,53 @@ class SearchModel
return $result;
}
/**
* 获取筛选的数据
*
* @param array $condition 查询条件
* @return array
*/
public static function getFilterData($condition)
{
$result = array();
if (USE_CACHE) {
$key = CacheConfig::KEY_ACTION_SEARCH_FILTER;
if (!empty($condition)) {
$key .= http_build_query($condition, null, '&');
}
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 区别各种列表页面的筛选数据
if (isset($condition['brand'])) {
$listData = BrandData::filterBrandData($condition);
} else if (isset($condition['sort'])) {
$listData = ClassData::filterClassData($condition);
} else {
$listData = SearchData::searchByCondition($condition);
}
if (isset($listData['data']['filter'])) {
$result['filter'] = ListProcess::getFilterData($listData['data']['filter']);
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
return $result;
}
}
... ...
... ... @@ -15,7 +15,7 @@ use Plugin\Helpers;
*/
class OptController extends AbstractAction
{
/**
* 品牌[店铺]收藏/取消收藏
*
... ... @@ -25,44 +25,47 @@ class OptController extends AbstractAction
*/
public function favoriteBrandAction()
{
$result = array('code' => 400, 'message' => '未登录', 'data' => false);
$result = array('code' => 401, 'message' => '未登录', 'data' => false);
do {
/* 判断是否是AJAX请求 */
if (!$this->isAjax()) {
break;
}
/* 判断品牌ID是否有效 */
$id = $this->post('id');
if (!is_numeric($id)) {
break;
}
/* 判断用户是否登录 */
$uid = $this->getUdid();
if (!$uid) {
break;
}
/* 取消收藏 */
$opt = $this->post('opt', 'ok');
if ($opt !== 'ok') {
$result = BrandData::favoriteCancel($id, $uid);
break;
}
/* 收藏 */
$result = BrandData::favorite($id, $uid);
}
while (false);
if (isset($result['code']) && $result['code'] == 412) {
$referer = $this->server('HTTP_REFERER', SITE_MAIN);
$result['data'] = Helpers::url('/signin.html', array('refer' => $referer));
}
if (!isset($result['code'])) {
break;
}
/* 未登录的情况,加跳转链接 */
if ($result['code'] == 412 || $result['code'] == 400) {
$referer = $this->server('HTTP_REFERER', SITE_MAIN);
$result['data'] = Helpers::url('/signin.html', array('refer' => $referer));
}
} while (false);
$this->echoJson($result);
}
}
... ...