Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

Conflicts:
	library/LibModels/Wap/Product/SearchData.php
	library/Plugin/Helpers.php
framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -17,16 +17,16 @@ use Plugin\Cache;
class Yohobuy
{
// /* 正式环境 */
// const API_URL = 'http://api2.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/* 测试环境 */
const API_URL = 'http://test2.open.yohobuy.com/';
const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
/* 正式环境 */
const API_URL = 'http://api2.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
// /* 测试环境 */
// const API_URL = 'http://test2.open.yohobuy.com/';
// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 私钥列表
*
... ...
... ... @@ -16,7 +16,8 @@ use Api\Sign;
*/
class SearchData
{
protected static $_searchurl = 'http://101.200.31.165/yohosearch/search.json';
protected static $_searchurl = 'http://101.200.31.165/yohosearch/search.json';
/**
* 模糊搜索提供的关键词
... ... @@ -60,8 +61,25 @@ class SearchData
*/
public static function searchLiDatas($query = null, $brand = null, $gender = null, $color = null, $size = null, $price = null, $p_d = null, $sort = null, $order = 's_t_desc', $page = 1, $limit = 60, $channel = null)
{
// 构建必传参数
$param = Yohobuy::param();
// 排序数据映射表
$order_map = array(
's_t_desc' => 'shelve_time:desc',
's_t_asc' => 'shelve_time:asc',
's_p_asc' => 'sales_price:asc',
's_p_desc' => 'sales_price:desc',
's_d_desc' => 'discount:desc',
's_d_asc' => 'discount:asc',
'skn_desc' => 'product_skn:desc',
'skn_asc' => 'product_skn:asc',
'activities_desc' => 'activities.order_by:desc',
'activities_asc' => 'activities.order_by:asc',
's_n_asc' => 'sales_num:asc',
's_n_desc' => 'sales_num:desc',
'activities_id_desc' => 'activities.activity_id:desc',
'activities_id_asc' => 'activities.activity_id:asc',
);
$param = array();
is_null($query) || $param['query'] = $query;
is_null($brand) || $param['brand'] = $brand;
... ... @@ -71,14 +89,13 @@ class SearchData
is_null($price) || $param['price'] = $price;
is_null($p_d) || $param['p_d'] = $p_d;
is_null($sort) || $param['sort'] = $sort;
is_null($channel) || $param['channel'] = $channel;
$param['method'] = 'app.search.li';
$param['order'] = $order;
// is_null($channel) || $param['channel'] = $channel;
$param['order'] = $order_map[$order];
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
$param['viewNum'] = $limit; // 每页记录数
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::get(self::$_searchurl, $param);
}
/**
... ...
... ... @@ -150,6 +150,10 @@ class FloorProcess
$build['textCn'] = $one['title'];
$result['hotCategory']['list'][] = $build;
}
if (isset($data['title']['more_url'])) {
$data['title']['more_url'] = Helpers::getFilterUrl($data['title']['more_url']);
}
return $result;
}
... ... @@ -176,6 +180,10 @@ class FloorProcess
$data['is_show_name'] = $data['title']['is_show'];
$data['name'] = $data['title']['title'];
unset($data['title']);
if (isset($data['title']['more_url'])) {
$data['title']['more_url'] = Helpers::getFilterUrl($data['title']['more_url']);
}
$result['hotCategory'] = $data;
... ... @@ -202,7 +210,7 @@ class FloorProcess
$one['img'] = Helpers::getImageUrl($one['src'], 158, 174);
unset($one['src']);
}
$data['more'] = '/category/brand/index?channel=' . $type;
$data['more'] = '/brands?channel=' . $type;
$result['hotBrands'] = $data;
return $result;
... ... @@ -220,7 +228,7 @@ class FloorProcess
foreach($data as $key=>&$value){
if($key == 'title'){
$value['more_url'] = self::$guangUrl.'?id=2&gender='.self::$channel[$type];
$value['more_url'] = Helpers::url('', array('id' => 2, 'gender' => self::$channel[$type]), 'guang');
}
if($key == 'article'){
foreach($value as &$one){
... ... @@ -258,7 +266,7 @@ class FloorProcess
foreach($data as $key=>&$value){
if($key == 'title'){
$value['more_url'] = self::$guangUrl.'?id=1&gender='.self::$channel[$type];
$value['more_url'] = Helpers::url('', array('id' => 1, 'gender' => self::$channel[$type]), 'guang');
}
if($key == 'list'){
foreach ($value as &$one) {
... ... @@ -307,6 +315,10 @@ class FloorProcess
unset($one['src']);
}
if (isset($data['title']['more_url'])) {
$data['title']['more_url'] = Helpers::getFilterUrl($data['title']['more_url']);
}
unset($data['big_image']);
... ... @@ -343,6 +355,10 @@ class FloorProcess
$one['img'] = Helpers::getImageUrl($one['src'], 191, 191);
unset($one['src']);
}
if (isset($data['title']['more_url'])) {
$data['title']['more_url'] = Helpers::getFilterUrl($data['title']['more_url']);
}
$result['creativeLife'] = $data;
return $result;
... ...
... ... @@ -21,7 +21,7 @@ class Helpers
public static function url($uri, $param, $module = 'index')
{
$url = '';
switch ($module) {
case 'guang': // 逛
$url = 'http://guang' . SUB_DOMAIN;
... ... @@ -38,13 +38,14 @@ class Helpers
default:
$url = 'http://' . $module . SUB_DOMAIN;
}
$url .= $uri;
if (!empty($param)) {
$url .= $uri . '?' . http_build_query($param, null, '&');
$url .= '?' . http_build_query($param, null, '&');
}
return $url;
}
/**
* 根据尺寸获得图片url
* @param string $url 路径
... ... @@ -66,14 +67,15 @@ class Helpers
*/
public static function getFilterUrl($url)
{
$filter = strtr(strstr($url, 'openby:yohobuy=', true), array('.m.yohobuy.com' => SUB_DOMAIN, OLD_MAIN => SITE_MAIN));
$url = strtr($url, array('.m.yohobuy.com' => SUB_DOMAIN, OLD_MAIN => SITE_MAIN));
$filter = strstr($url, 'openby:yohobuy=', true);
if ($filter) {
return rtrim(rtrim($filter, '?'), '&');
} else {
return $url;
}
}
/**
* 根据用户访问的COOKIE判断出性别
*
... ... @@ -91,8 +93,8 @@ class Helpers
return '1,2,3';
}
}
/**
/**
* 根据用户访问的COOKIE判断出频道
*
* @return int
... ... @@ -125,8 +127,9 @@ class Helpers
*/
public static function formatProduct($productData, $showTags = true, $showNew = true, $showSale = true)
{
// 商品信息有问题,则不显示
if (!isset($productData['product_skn'])) {
if (!isset($productData['product_skn']) || !isset($productData['goods_list'][0])) {
return false;
}
... ... @@ -135,24 +138,22 @@ class Helpers
$productData['market_price'] = false;
}
// 如果$productData['default_images']为空,就取$productData['goods_list']中第一个,为空就不处理
if (empty($productData['default_images'])) {
$productData['default_images'] = $productData['goods_list'][0];
}
$result = array();
$result['id'] = $productData['product_skn'];
$result['product_id'] = $productData['product_id'];
// 如果$productData['default_images']为null,就取$productData['goods_list']中第一个,为空就不处理
if(is_null($productData['default_images']) && count($productData['goods_list']))
{
$productData['default_images'] = $productData['default_images'][0];
}
// 如果是来自搜索页搜索出来的图片要先处理一下
$result['thumb'] = Images::getImageUrl($productData['default_images'], 235, 314);
$result['name'] = $productData['product_name'];
$result['price'] = $productData['market_price'];
$result['salePrice'] = $productData['sales_price'];
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
$result['url'] = ''; // @todo
$result['url'] = OLD_MAIN . '/product/pro_' . $productData['product_id'] . '_' . $productData['goods_list'][0]['goods_id']
. '/'. $productData['cn_alphabet'] . '.html';
if ($showTags) {
$result['tags'] = array();
... ... @@ -188,7 +189,7 @@ class Helpers
$result['id'] = $articleData['id'];
$result['showTags'] = $showTag;
$result['img'] = self::getImageUrl($articleData['src'], 640, 640);
$result['url'] = $isApp && !empty($articleData['url']) ? $articleData['url'] : '/info/index?id=' . $articleData['id'];
$result['url'] = $isApp && !empty($articleData['url']) ? $articleData['url'] : '/info/index?id=' . $articleData['id'];
$result['title'] = $articleData['title'];
$result['text'] = $articleData['intro'];
$result['publishTime'] = $articleData['publish_time'];
... ...
<?php
use Action\AbstractAction;
/**
* 下载相关的控制器
*
* @name DownloadController
* @package
* @copyright yoho.inc
* @version 1.0 (2015-10-28 16:30:44)
* @author fei.hong <fei.hong@yoho.cn>
*/
class DownloadController extends AbstractAction
{
/**
* 下载APP
*/
public function mkappAction()
{
// 跳转到老站s
$this->go(OLD_MAIN . '/download/mkapp');
}
}
... ...
<?php
use Action\AbstractAction;
/**
* 个人中心相关的控制器
*
* @name HomeController
* @package
* @copyright yoho.inc
* @version 1.0 (2015-10-28 16:28:32)
* @author fei.hong <fei.hong@yoho.cn>
*/
class HomeController extends AbstractAction
{
/**
* 个人中心入口
*/
public function indexAction()
{
// 目前跳到老站
$this->go(OLD_MAIN . '/home');
}
}
... ...
... ... @@ -73,35 +73,35 @@ class SearchController extends AbstractAction
'discount' => FILTER_VALIDATE_INT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
$query = isset($condition['query']) ? strtolower(trim($condition['query'])) : null;
// 标识用户是否有输入搜索内容
$haveQuery = $query !== null;
// 标识用户搜的是不是一级品类
$isQueryFirstClass = false;
// 标识用户搜的是不是二级品类
$isQuerySecondClass = false;
/* 判断是不是品牌, 是品牌跳到品牌列表页(显示搜索框) */
if ($haveQuery) {
$domain = null;
$brandNames = Product\ListModel::getAllBrandNames();
do {
/* 精确查品牌域名 */
if (isset($brandNames[$query])) {
$domain = $query;
break;
}
/* 精确查品牌名称 */
$domains = array_keys($brandNames, $query, true);
if (isset($domains[0])) {
$domain = $domains[0];
break;
}
/* 模糊查品牌域名 */
foreach ($brandNames as $key => $domains) {
if (strpos($key, $query) !== false) {
... ... @@ -110,22 +110,22 @@ class SearchController extends AbstractAction
}
}
} while (false);
// 清空变量做释放
$brandNames = array();
// 跳转到品牌商品列表页
if ($domain !== null) {
$url = Helpers::url('', array(
'from' => 'search',
'query' => $query,
'gender' => $condition['gender']
), $domain);
'from' => 'search',
'query' => $query,
'gender' => $condition['gender']
), $domain);
$this->go($url);
}
}
/* 判断是不是品类, 是品类加导航标题(不显示搜索框) */
if ($haveQuery) {
$classNames = Category\ClassModel::getClassNames();
... ... @@ -137,30 +137,29 @@ class SearchController extends AbstractAction
$isQueryFirstClass = true;
break;
}
/* 精确查二级品类 */
$sorts = array_keys($classNames['second'], $query, true);
if (isset($sorts[0])) {
$isQuerySecondClass = true;
break;
}
}
while (false);
} while (false);
$classNames = array();
}
$data = array();
// 搜索是一级品类
if ($isQueryFirstClass) {
$this->setTitle('全部' . $query);
$this->setNavHeader('全部' . $query, true, SITE_MAIN);
}
}
// 搜索是二级品类
elseif ($isQuerySecondClass) {
$this->setTitle($query);
$this->setNavHeader($query, true, SITE_MAIN);
}
}
// 搜索其它内容
else {
if ($haveQuery) {
... ... @@ -170,25 +169,29 @@ class SearchController extends AbstractAction
$this->setTitle('搜索');
$this->setNavHeader('搜索', true, SITE_MAIN);
}
$data['goodListPage'] = true;
$data['goodList'] = $condition;
// 查询数据
$listData = SearchData::searchByCondition($condition);
// 处理返回的数据
if (!empty($listData['data']['brand'])) {
$brandData = $listData['data']['brand'];
$data['brandWay'] = array(
'url' => 'http://'. $brandData['brand_domain'] . SUB_DOMAIN,
'thumb' => Helpers::getImageUrl($brandData['brand_ico'], 75, 40),
'name' => $brandData['brand_name']
);
// 设置品牌默认值
$data['goodList']['brand'] = $brandData['id'];
$data['goodList'] += ListProcess::getListData($listData['data']);
if (!isset($condition['query'])) {
$data['goodList'] += Product\ListModel::getClassData($condition);
} else {
$listData = SearchData::searchByCondition($condition);
// 处理返回的数据
if (!empty($listData['data']['brand'])) {
$brandData = $listData['data']['brand'];
$data['brandWay'] = array(
'url' => 'http://' . $brandData['brand_domain'] . SUB_DOMAIN,
'thumb' => Helpers::getImageUrl($brandData['brand_ico'], 75, 40),
'name' => $brandData['brand_name']
);
// 设置品牌默认值
$data['goodList']['brand'] = $brandData['id'];
$data['goodList'] += ListProcess::getListData($listData['data']);
}
$listData = array();
}
$listData = array();
$this->_view->display('list', $data);
}
... ... @@ -211,7 +214,7 @@ class SearchController extends AbstractAction
'price' => FILTER_VALIDATE_INT,
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT, ), false);
'p_d' => FILTER_DEFAULT,), false);
// 转换排序方式
$page = $this->get('page', 1);
... ... @@ -232,15 +235,23 @@ class SearchController extends AbstractAction
$data = array();
// 查询数据
$listData = SearchData::searchByCondition($condition, $order, $page);
// 处理返回的数据
if (isset($listData['data'])) {
if (isset($listData['data']['filter'])) {
unset($listData['data']['filter']);
if (!isset($condition['query'])) {
$data += Product\ListModel::getClassData($condition);
if (isset($data['filter'])) {
unset($data['filter']);
}
} else {
// 查询数据
$listData = SearchData::searchByCondition($condition, $order, $page);
// 处理返回的数据
if (isset($listData['data'])) {
if (isset($listData['data']['filter'])) {
unset($listData['data']['filter']);
}
$data = ListProcess::getListData($listData['data']);
}
$data = ListProcess::getListData($listData['data']);
$listData = array();
}
$listData = array();
if (empty($data)) {
echo ' ';
... ...
... ... @@ -95,21 +95,21 @@ class SideModel
'textEn' => '',
'back' => false,
'isSelect' => ($guangChoosed === 'all') ? true : false,
'url' => '/guang/list/index?gender=1,2,3'
'url' => Helpers::url('', array('gender' => '1,2,3'), 'guang')
),
2 => array(
'textCn' => '只看男生',
'textEn' => 'Boys',
'back' => false,
'isSelect' => ($guangChoosed === 'boys') ? true : false,
'url' => '/guang/list/index?gender=1,3'
'url' => Helpers::url('', array('gender' => '1,3'), 'guang')
),
3 => array(
'textCn' => '只看女生',
'textEn' => 'Girls',
'back' => false,
'isSelect' => ($guangChoosed === 'girls') ? true : false,
'url' => '/guang/list/index?gender=2,3',
'url' => Helpers::url('', array('gender' => '2,3'), 'guang')
),
)
)
... ...
... ... @@ -44,7 +44,7 @@ class ListModel
}
// 调用接口查询数据
$listData = ClassData::filterClassData($condition);
$listData = ClassData::filterClassData($condition);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
$result = ListProcess::getListData($listData['data']);
... ... @@ -86,7 +86,7 @@ class ListModel
}
// 获取品牌banner的数据, 有缓存1小时
$bannerData = BrandData::getBrandBanner($id);
$bannerData = BrandData::getBrandBanner($id);
if (isset($bannerData['data']['banner'])) {
$result['brandHome']['banner'] = Helpers::getImageUrl($bannerData['data']['banner'], 640, 75);
}
... ... @@ -118,17 +118,17 @@ class ListModel
}
// 调用接口查询数据
$listData = BrandData::filterBrandData($condition);
$listData = BrandData::filterBrandData($condition);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
$result = ListProcess::getListData($listData['data']);
if (!empty($listData['data']['brand'])) {
$result['brandWay'] = array(
'url' => 'http://'. $listData['data']['brand_domain'] . SUB_DOMAIN,
'thumb' => Helpers::getImageUrl($listData['data']['brand_ico'], 75, 40),
'name' => $listData['data']['brand_name']
'url' => 'http://'. $listData['data']['brand']['brand_domain'] . SUB_DOMAIN,
'thumb' => Helpers::getImageUrl($listData['data']['brand']['brand_ico'], 75, 40),
'name' => $listData['data']['brand']['brand_name']
);
$title = $listData['data']['brand_name'];
$title = $listData['data']['brand']['brand_name'];
}
}
... ...
<?php
use Action\AbstractAction;
/**
* 购物车相关的控制器
*
* @name IndexController
* @package Cart
* @copyright yoho.inc
* @version 1.0 (2015-10-28 16:34:17)
* @author fei.hong <fei.hong@yoho.cn>
*/
class IndexController extends AbstractAction
{
public function indexAction()
{
// 跳转到老版
$this->go(OLD_MAIN . '/cart/index/index');
}
}
... ...
... ... @@ -24,7 +24,16 @@ class IndexController extends AbstractAction
$uid = $this->getUid();
$udid = $this->getUdid();
$type = $this->get('id', 0);
$gender = $this->get('gender');
$gender = rawurldecode($this->get('gender', '1,2,3'));
// // 设置侧边栏逛的默认选中状态
// if ($gender === '1,3') {
// $this->setNavSide('boys');
// } elseif ($gender === '2,3') {
// $this->setNavSide('girls');
// } else {
// $this->setNavSide('all');
// }
$this->_view->display('index', Guang\IndexModel::getArticleGroup($gender, $type, $uid, $udid));
}
... ...
... ... @@ -39,6 +39,8 @@ class IndexController extends AbstractAction
// 性别参数,不传则从COOKIE获取
if (!isset($condition['gender'])) {
$condition['gender'] = Helpers::getGenderByCookie();
} else {
$condition['gender'] = rawurldecode($condition['gender']);
}
// 品类名称参数, 不传则默认为全部
... ... @@ -105,6 +107,9 @@ class IndexController extends AbstractAction
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,), false);
$condition['brand'] = $brandIds[0];
if (isset($condition['gender'])) {
$condition['gender'] = rawurldecode($condition['gender']);
}
$data['goodListPage'] = true;
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息
... ...
... ... @@ -4,7 +4,7 @@ application.directory = APPLICATION_PATH "/application"
;;website library
application.library = ROOT_PATH "/library"
;;模块配置
application.modules = "Index,Category,Channel,Guang,Passport,Product"
application.modules = "Index,Category,Channel,Guang,Passport,Product,Cart"
;;加载
application.bootstrap = APPLICATION_PATH "/application/Bootstrap.php"
;;view文件的扩展名
... ...
... ... @@ -4,7 +4,7 @@ application.directory = APPLICATION_PATH "/application"
;;website library
application.library = ROOT_PATH "/library"
;;默认模块
application.modules = "Index,Category,Channel,Guang,Passport,Product"
application.modules = "Index,Category,Channel,Guang,Passport,Product,Cart"
;;加载
application.bootstrap = APPLICATION_PATH "/application/Bootstrap.php"
;;view文件的扩展名
... ...
... ... @@ -4,7 +4,7 @@ application.directory = APPLICATION_PATH "/application"
;;website library
application.library = ROOT_PATH "/library"
;;默认模块
application.modules = "Index,Category,Channel,Guang,Passport,Product"
application.modules = "Index,Category,Channel,Guang,Passport,Product,Cart"
;;加载
application.bootstrap = APPLICATION_PATH "/application/Bootstrap.php"
;;view文件的扩展名
... ...
... ... @@ -82,4 +82,11 @@ routes.productsale.route.module = Product
routes.productsale.route.controller = Newsale
routes.productsale.route.action = Discount
; 女生首页
routes.girls.type = "rewrite"
routes.girls.match = "/girl$"
routes.girls.route.module = Index
routes.girls.route.controller = Girls
routes.girls.route.action = index
... ...