...
|
...
|
@@ -190,7 +190,7 @@ class Helpers |
|
|
*/
|
|
|
public static function transPrice($price)
|
|
|
{
|
|
|
return (!empty($price) && !is_float($price)) ? $price . '.00' : number_format($price, 2, '.', '');
|
|
|
return number_format($price, 2, '.', '');
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -566,8 +566,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']);
|
...
|
...
|
@@ -576,52 +576,70 @@ class Helpers |
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 格式化购物车商品
|
|
|
*
|
|
|
* @param array $cartGoods 购物车商品列表
|
|
|
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
|
|
|
* @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
|
|
|
* @return array 处理之后的购物车商品数据
|
|
|
*/
|
|
|
public static function formatCartGoods($cartGoods)
|
|
|
public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true)
|
|
|
{
|
|
|
$arr = array();
|
|
|
|
|
|
$oneGoods = array();
|
|
|
foreach ($cartGoods as $key => $value) {
|
|
|
$oneGoods['id'] = $value['product_sku'];
|
|
|
$oneGoods['skn'] = $value['product_skn'];
|
|
|
$oneGoods['name'] = $value['product_name'];
|
|
|
$oneGoods['thumb'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 120, 120) : '';
|
|
|
$oneGoods['color'] = $value['color_name'];
|
|
|
$oneGoods['size'] = $value['size_name'];
|
|
|
$oneGoods['price'] = self::transPrice($value['sales_price']);
|
|
|
$oneGoods['count'] = $value['buy_number'];
|
|
|
$oneGoods['lowStocks'] = ($value['buy_number'] < $value['storage_number']);
|
|
|
//gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
|
|
|
if (!isset($value['goods_type'])) {
|
|
|
$oneGoods['isSoldOut'] = true;
|
|
|
} elseif ($value['goods_type'] == 'gift' && !isset($value['isAdvanceBuy'])) {
|
|
|
$oneGoods['isGift'] = true;
|
|
|
} elseif ($value['goods_type'] == 'price_gift') {
|
|
|
$oneGoods['isAdvanceBuy'] = true;
|
|
|
}
|
|
|
// 上市期
|
|
|
if (!empty($value['expect_arrival_time'])) {
|
|
|
$oneGoods['appearDate'] = $value['expect_arrival_time'];
|
|
|
}
|
|
|
// 商品链接
|
|
|
if (isset($value['cn_alphabet']) ) {
|
|
|
$oneGoods['url'] = self::url('/product/pro_' . $value['product_id'] . '_' . $value['goods_id'] . '/' . $value['cn_alphabet'] . '.html');
|
|
|
}
|
|
|
|
|
|
$arr[$key] = $oneGoods;
|
|
|
}
|
|
|
$oneGoods = array();
|
|
|
foreach ($cartGoods as $key => $value) {
|
|
|
$oneGoods = array();
|
|
|
$oneGoods['id'] = $value['product_sku'];
|
|
|
$oneGoods['skn'] = $value['product_skn'];
|
|
|
$oneGoods['name'] = $value['product_name'];
|
|
|
$oneGoods['thumb'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 120, 160) : '';
|
|
|
$oneGoods['color'] = $value['color_name'];
|
|
|
$oneGoods['size'] = $value['size_name'];
|
|
|
$oneGoods['checked'] = $value['selected'] === 'Y';
|
|
|
$oneGoods['price'] = self::transPrice($value['last_vip_price']);
|
|
|
$oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'];
|
|
|
$oneGoods['count'] = $value['buy_number'];
|
|
|
|
|
|
if ($isValid) {
|
|
|
// 库存不足
|
|
|
$oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']);
|
|
|
} else { // 失效商品
|
|
|
$oneGoods['inValid'] = true;
|
|
|
}
|
|
|
|
|
|
//gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
|
|
|
if (!isset($value['goods_type'])) {
|
|
|
$oneGoods['inValid'] = true;
|
|
|
} elseif ($value['goods_type'] == 'gift' && !isset($value['isAdvanceBuy'])) {
|
|
|
$oneGoods['isGift'] = true;
|
|
|
$oneGoods['salesPrice'] = self::transPrice($value['sales_price']);
|
|
|
$oneGoods['price'] = self::transPrice($value['last_price']);
|
|
|
} elseif ($value['goods_type'] == 'price_gift') {
|
|
|
$oneGoods['showCheckbox'] = true;
|
|
|
$oneGoods['isAdvanceBuy'] = true;
|
|
|
$oneGoods['salesPrice'] = self::transPrice($value['sales_price']);
|
|
|
$oneGoods['price'] = self::transPrice($value['last_price']);
|
|
|
} else {
|
|
|
$oneGoods['showCheckbox'] = true;
|
|
|
}
|
|
|
|
|
|
// 上市期
|
|
|
if ($isAdvanceCart && !empty($value['expect_arrival_time'])) {
|
|
|
$oneGoods['appearDate'] = $value['expect_arrival_time'];
|
|
|
}
|
|
|
// 商品链接
|
|
|
$oneGoods['link'] = self::url('/product/show_' . $value['product_skn'] . '.html');
|
|
|
|
|
|
$arr[$key] = $oneGoods;
|
|
|
}
|
|
|
|
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 格式化加价购商品
|
|
|
* 格式化加价购和赠品商品
|
|
|
*
|
|
|
* @param array $advanceGoods 加价购商品列表
|
|
|
* @param int $count 计商品件数
|
...
|
...
|
@@ -631,33 +649,38 @@ class Helpers |
|
|
{
|
|
|
$arr = array();
|
|
|
|
|
|
$gift = array();
|
|
|
$oneGoods = array();
|
|
|
foreach ($advanceGoods as $value) {
|
|
|
$gift = array();
|
|
|
$gift['promotionTitle'] = $value['promotion_title'];
|
|
|
|
|
|
foreach ($value['goods_list'] as $single) {
|
|
|
$oneGoods['id'] = $single['product_skn'];
|
|
|
$oneGoods['name'] = $single['product_name'];
|
|
|
$oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 120) : '';
|
|
|
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
|
|
|
$oneGoods['price'] = $single['last_price'];
|
|
|
$oneGoods['marketPrice'] = $single['market_price'];
|
|
|
$oneGoods['count'] = $single['storage_number'];
|
|
|
|
|
|
$gift['goods'][] = $oneGoods;
|
|
|
}
|
|
|
$gift = array();
|
|
|
$oneGoods = array();
|
|
|
$number = 0;
|
|
|
foreach ($advanceGoods as $value) {
|
|
|
$gift = array();
|
|
|
$gift['promotionId'] = $value['promotion_id'];
|
|
|
$gift['promotionTitle'] = $value['promotion_title'];
|
|
|
|
|
|
$number = 0;
|
|
|
foreach ($value['goods_list'] as $single) {
|
|
|
$oneGoods = array();
|
|
|
$oneGoods['id'] = $single['product_skn'];
|
|
|
$oneGoods['name'] = $single['product_name'];
|
|
|
$oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : '';
|
|
|
$oneGoods['price'] = self::transPrice($single['last_price']);
|
|
|
$oneGoods['marketPrice'] = self::transPrice($single['market_price']);
|
|
|
$oneGoods['count'] = $single['storage_number'];
|
|
|
|
|
|
$gift['goods'][] = $oneGoods;
|
|
|
$number ++;
|
|
|
}
|
|
|
|
|
|
$arr[] = $gift;
|
|
|
$arr[] = $gift;
|
|
|
|
|
|
// 计算加价购商品数目
|
|
|
$count += count($value['goods_list']);
|
|
|
}
|
|
|
// 计算加价购商品数目
|
|
|
//$count += count($value['goods_list']);
|
|
|
$count += $number;
|
|
|
}
|
|
|
|
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 订单状态,按订单支付类型和订单状态
|
|
|
* @var array
|
...
|
...
|
|