Authored by 梁志锋

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

... ... @@ -29,11 +29,15 @@ class DetailData
* @param int $uid 用户ID
* @return array
*/
public static function baseInfo($productId, $uid)
public static function baseInfo($productId, $uid, $productSkn = null)
{
$param = Yohobuy::param();
$param['method'] = 'h5.product.data';
if ($productId !== null) {
$param['productId'] = $productId;
} elseif ($productSkn !== null) {
$param['product_skn'] = $productSkn;
}
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
... ...
... ... @@ -546,8 +546,8 @@ class Helpers
$arr[$key]['appearDate'] = $vo['expect_arrival_time'];
}
// 商品链接
if ($haveLink && isset($vo['product_id'])) {
$arr[$key]['link'] = self::url('/product/pro_' . $vo['product_id'] . '_' . $vo['goods_id'] . '/' . $vo['cn_alphabet'] . '.html');
if ($haveLink && isset($vo['product_skn'])) {
$arr[$key]['link'] = self::url('/product/show_' . $vo['product_skn'] . '.html');
}
// 累计购买数
$count += intval($vo['buy_number']);
... ...
... ... @@ -20,24 +20,30 @@ class DetailModel
/**
* 商品基本信息
*
* @param int $productId 商品ID
* @param int $productId 商品ID SKN 和 ID 只需要传一个
* @param int $goodsId 某个颜色的商品
* @param int $uid 当前登录用户ID, 未登录为0
* @param int $productSkn SKN 和 ID 只需要传一个
* @return array
*/
public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel)
public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel, $productSkn = null)
{
$result = array();
$baseInfo = array();
// 通过ID获取
if (is_numeric($productId) && is_numeric($goodsId)) {
// 调用服务
$baseInfo = DetailData::baseInfo($productId, $uid);
}
// 通过SKN获取
elseif (is_numeric($productSkn)) {
$baseInfo = DetailData::baseInfo(null, $uid, $productSkn);
}
// 商品名称
if (empty($baseInfo['productName'])) {
return $result;
}
$result['goodsName'] = $baseInfo['productName'];
// 商品促销短语
... ... @@ -190,7 +196,7 @@ class DetailModel
);
$colorStorageNum += intval($size['goodsSizeStorageNum']);
$sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
$colorStorageGroup[$size['sizeName']][$value['colorName']] = $size['goodsSizeStorageNum'];
$colorStorageGroup[$size['sizeName']][$value['colorId']] = $size['goodsSizeStorageNum'];
}
// 颜色分组
... ... @@ -277,7 +283,6 @@ class DetailModel
// 底部简介的URL链接
$result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');
$result['id'] = $productId;
}
return $result;
}
... ...
... ... @@ -49,6 +49,39 @@ class DetailController extends AbstractAction
}
/**
* 商品详情 (SKN)
*
* @param int productSkn
*/
public function showAction()
{
$productSkn = $this->param('productSkn');
if (!is_numeric($productSkn)) {
$this->error();
}
$uid = $this->getUid();
$vipLevel = 0;
if (isset($this->_vip)) {
$vipLevel = Helpers::getVipLevel($this->_vip);
}
$data = \Product\DetailModel::getBaseInfo(null, null, $uid, $vipLevel, $productSkn);
if (array() === $data) {
$this->error();
}
$data['goodsDetailPage'] = true;
$data['pageFooter'] = true;
if (isset($data['goodsName'])) {
$this->setTitle($data['goodsName']);
}
$this->setNavHeader('商品详情');
// 渲染模板
$this->_view->display('index', $data);
}
/**
* 尺码描述信息
*/
public function introAction()
... ...
... ... @@ -147,6 +147,13 @@ routes.productintro.route.controller = Detail
routes.productintro.route.action = Intro
routes.productintro.map.1 = productSkn
routes.productskn.type = "regex"
routes.productskn.match = "#/product/show_([0-9]+).html#"
routes.productskn.route.module = Product
routes.productskn.route.controller = Detail
routes.productskn.route.action = Show
routes.productskn.map.1 = productSkn
; 订单相关
routes.cart.type = "rewrite"
routes.cart.match = "/home/order/detail$"
... ...
... ... @@ -20,3 +20,10 @@ routes.productintro.route.module = Product
routes.productintro.route.controller = Detail
routes.productintro.route.action = Intro
routes.productintro.map.1 = productSkn
routes.productskn.type = "regex"
routes.productskn.match = "#/product/show_([0-9]+).html#"
routes.productskn.route.module = Product
routes.productskn.route.controller = Detail
routes.productskn.route.action = Show
routes.productskn.map.1 = productSkn
... ...