Authored by Rock Zhang

修改普通商品上市期显示的问题;修改只有预售商品时传递的数据格式

Code Review By Rock Zhang
... ... @@ -561,9 +561,10 @@ class Helpers
*
* @param array $cartGoods 购物车商品列表
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
* @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
* @return array 处理之后的购物车商品数据
*/
public static function formatCartGoods($cartGoods, $isValid = true)
public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true)
{
$arr = array();
... ... @@ -592,7 +593,7 @@ class Helpers
$oneGoods['isAdvanceBuy'] = true;
}
// 上市期
if (!empty($value['expect_arrival_time'])) {
if ($isAdvanceCart && !empty($value['expect_arrival_time'])) {
$oneGoods['appearDate'] = $value['expect_arrival_time'];
}
// 商品链接
... ...
... ... @@ -103,7 +103,7 @@ class CartModel
/* 普通购物车 */
$result['commonGoodsCount'] = $ordinaryCount;
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy, false);
/* 预售购物车 */
$result['presellGoodsCount'] = $advanceCount;
$result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
... ... @@ -722,15 +722,16 @@ class CartModel
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @param bool $isAdvanceCart 是否是预售购物车,默认是,(和上市期有关)
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false)
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false, $isAdvanceCart = true)
{
$result = array();
do {
// 数据为空时返回空的标志
if (empty($data)) {
if (empty($data['goods_list'])) {
break;
}
... ... @@ -746,13 +747,13 @@ class CartModel
}
// 购买的可用商品列表
$validGoods = Helpers::formatCartGoods($data['goods_list']);
$validGoods = Helpers::formatCartGoods($data['goods_list'], $isAdvanceCart);
if (!empty($validGoods)) {
$result['goods'] = $validGoods;
}
// 失效商品列表
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], false);
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], $isAdvanceCart, false);
if (!empty($notValidGoods)) {
$result['notValidGoods'] = $notValidGoods;
}
... ...