Authored by 郝肖肖

头部购物车 列表数据修复

... ... @@ -1315,45 +1315,78 @@ class CartModel
$cartType = array('advance_cart_data', 'ordinary_cart_data');
$cartData = CartData::cartData($uid, $shoppingKey);
foreach ($cartType as $dataKey) {
if (!isset($cartData['data'][$dataKey]['goods_list']) || empty($cartData['data'][$dataKey]['goods_list'])) {
continue;
}
//购物车商品
foreach ($cartData['data'][$dataKey]['goods_list'] as $val) {
$goods['product_url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_id'], $val['cn_alphabet']);
$goods['is_advance'] = $val['is_advance'];
$goods['default_img'] = Helpers::getImageUrl($val['goods_images'], 46, 62);
$goods['product_name'] = $val['product_name'];
$goods['color_name'] = $val['color_name'];
$goods['size_name'] = $val['size_name'];
$goods['show_price'] = $val['real_price'];
$goods['buy_number'] = $val['buy_number'];
$goods['goods_incart_id'] = $val['shopping_cart_id'];
$goods['product_sku'] = $val['product_sku'];
$goods['promotion_id'] = $val['promotion_id'];
$result['main_goods'][] = $goods;
}
if (empty($cartData['data'][$dataKey]['promotion_info'])) {
continue;
if (isset($cartData['data'][$dataKey]['goods_list']) && !empty($cartData['data'][$dataKey]['goods_list'])) {
foreach ($cartData['data'][$dataKey]['goods_list'] as $val) {
$goods['product_url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_id'], $val['cn_alphabet']);
$goods['is_advance'] = $val['is_advance'];
$goods['default_img'] = Helpers::getImageUrl($val['goods_images'], 46, 62);
$goods['product_name'] = $val['product_name'];
$goods['color_name'] = $val['color_name'];
$goods['size_name'] = $val['size_name'];
$goods['show_price'] = $val['real_price'];
$goods['buy_number'] = $val['buy_number'];
$goods['goods_incart_id'] = $val['shopping_cart_id'];
$goods['product_sku'] = $val['product_sku'];
$goods['promotion_id'] = $val['promotion_id'];
$result['main_goods'][] = $goods;
}
}
//活动
foreach ($cartData['data'][$dataKey]['promotion_info'] as $key => $val) {
//包邮
if ($val['promotion_type'] == 'FreeShippingCost') {
preg_match('/\d+/', $val['promotion_title'], $arr);
$result['fit_free_shipping'] = $arr[0];
continue;
//下架购物车商品
if (isset($cartData['data'][$dataKey]['off_shelves_goods_list']) && !empty($cartData['data'][$dataKey]['off_shelves_goods_list'])) {
foreach ($cartData['data'][$dataKey]['off_shelves_goods_list'] as $val) {
$goods['product_url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_id'], $val['cn_alphabet']);
$goods['is_advance'] = $val['is_advance'];
$goods['default_img'] = Helpers::getImageUrl($val['goods_images'], 46, 62);
$goods['product_name'] = $val['product_name'];
$goods['color_name'] = $val['color_name'];
$goods['size_name'] = $val['size_name'];
$goods['show_price'] = $val['real_price'];
$goods['buy_number'] = $val['buy_number'];
$goods['goods_incart_id'] = $val['shopping_cart_id'];
$goods['product_sku'] = $val['product_sku'];
$goods['promotion_id'] = $val['promotion_id'];
$result['main_goods'][] = $goods;
}
//打折
if (!isset($result['first_promotions'])) {
$result['has_promotion'] = true;
$result['has_first_promotion'] = true;
$result['first_promotions']['promotion_id'] = $val['promotion_id'];
$result['first_promotions']['promotion_title'] = $val['promotion_title'];
} else {
$result['has_other_promotion'] = true;
$result['other_promotions'][$key]['promotion_id'] = $val['promotion_id'];
$result['other_promotions'][$key]['promotion_title'] = $val['promotion_title'];
}
//售罄购物车商品
if (isset($cartData['data'][$dataKey]['sold_out_goods_list']) && !empty($cartData['data'][$dataKey]['sold_out_goods_list'])) {
foreach ($cartData['data'][$dataKey]['sold_out_goods_list'] as $val) {
$goods['product_url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_id'], $val['cn_alphabet']);
$goods['is_advance'] = $val['is_advance'];
$goods['default_img'] = Helpers::getImageUrl($val['goods_images'], 46, 62);
$goods['product_name'] = $val['product_name'];
$goods['color_name'] = $val['color_name'];
$goods['size_name'] = $val['size_name'];
$goods['show_price'] = $val['real_price'];
$goods['buy_number'] = $val['buy_number'];
$goods['goods_incart_id'] = $val['shopping_cart_id'];
$goods['product_sku'] = $val['product_sku'];
$goods['promotion_id'] = $val['promotion_id'];
$result['main_goods'][] = $goods;
}
}
//活动
if (isset($cartData['data'][$dataKey]['promotion_info']) && !empty($cartData['data'][$dataKey]['promotion_info'])) {
foreach ($cartData['data'][$dataKey]['promotion_info'] as $key => $val) {
//包邮
if ($val['promotion_type'] == 'FreeShippingCost') {
preg_match('/\d+/', $val['promotion_title'], $arr);
$result['fit_free_shipping'] = $arr[0];
continue;
}
//打折
if (!isset($result['first_promotions'])) {
$result['has_promotion'] = true;
$result['has_first_promotion'] = true;
$result['first_promotions']['promotion_id'] = $val['promotion_id'];
$result['first_promotions']['promotion_title'] = $val['promotion_title'];
} else {
$result['has_other_promotion'] = true;
$result['other_promotions'][$key]['promotion_id'] = $val['promotion_id'];
$result['other_promotions'][$key]['promotion_title'] = $val['promotion_title'];
}
}
}
}
... ...