Authored by 毕凯

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

... ... @@ -601,7 +601,7 @@ class Helpers
}
/**
* 格式化加价购商品
* 格式化加价购和赠品商品
*
* @param array $advanceGoods 加价购商品列表
* @param int $count 计商品件数
... ... @@ -615,6 +615,7 @@ class Helpers
$oneGoods = array();
foreach ($advanceGoods as $value) {
$gift = array();
$gift['promotionId'] = $value['promotion_id'];
$gift['promotionTitle'] = $value['promotion_title'];
foreach ($value['goods_list'] as $single) {
... ...
... ... @@ -189,50 +189,7 @@ class CartModel
$product = CartData::cartProductData($uid, $skn);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
$data['num'] = $num;
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
$result['data'] = self::procGoodsDetail($product['data'], $num);
}
return $result;
... ... @@ -252,49 +209,7 @@ class CartModel
$product = CartData::giftProductData($skn, $promotionId);
if (isset($product['code']) && $product['code'] === 200) {
$result['code'] = 200;
$data = array();
$productData = $product['data'];
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
$result['data'] = $data;
$result['data'] = self::procGoodsDetail($product['data']);
}
return $result;
... ... @@ -657,6 +572,62 @@ class CartModel
/**
* 处理购物车商品、加价购商品、赠品详情数据
*
* @param array $productData 要处理的商品数据
* @param int $num 购买数目
* @return array $data 处理之后的数据
*/
private static function procGoodsDetail($productData, $num = null)
{
$data = array();
// 品牌信息
if (isset($productData['brand_info']) && !empty($productData['brand_info'])) {
$data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120);
}
$data['name'] = $productData['product_name'];
$data['price'] = $productData['market_price'];
$data['salePrice'] = $productData['sales_price'];
$data['storage'] = $productData['storage_sum'];
if ($num !== null) {
$data['num'] = $num;
}
// 商品选择
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$colors = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
foreach ($goodsList as $val) {
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['name'] = $val['color_name'];
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['name'] = $one['size_name'];
}
$sizes[] = $oneSize;
$oneColor['sizes'] = $sizes;
$colors[] = $oneColor;
}
$data['colors'] = $colors;
}
return $data;
}
/**
* 处理不同类型的购物车数据
*
* @param array $data 不同类型购物车数据
... ...
... ... @@ -191,6 +191,16 @@ class IndexController extends AbstractAction
}
/*
* 获取购物车加价购商品数据模板
*/
public function giftinfoTplAction()
{
if ($this->isAjax()) {
echo file_get_contents($this->_view->getScriptPath() . '/../partials/cart/chose-panel.phtml');
}
}
/*
* 获取购物车加价购商品数据
*/
public function giftinfoAction()
... ...