...
|
...
|
@@ -556,6 +556,86 @@ class Helpers |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 格式化购物车商品
|
|
|
*
|
|
|
* @param array $cartGoods 购物车商品列表
|
|
|
* @param bool $haveLink 控制是否需要商品链接
|
|
|
*/
|
|
|
public static function formatCartGoods($cartGoods, $haveLink = false)
|
|
|
{
|
|
|
$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['appearDate'] = '12月'; // 目前app接口没有返回该数据
|
|
|
$oneGoods['price'] = $value['real_price'];
|
|
|
$oneGoods['count'] = $value['buy_number'];
|
|
|
$oneGoods['lowStocks'] = ($value['buy_number'] < $value['storage_number']);
|
|
|
//gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品;
|
|
|
if (!isset($value['goods_type'])) {
|
|
|
$oneGoods['soldOut'] = true;
|
|
|
} elseif ($value['goods_type'] == 'gift') {
|
|
|
$oneGoods['gift'] = true;
|
|
|
} elseif ($value['goods_type'] == 'price_gift') {
|
|
|
$oneGoods['advanceBuy'] = true;
|
|
|
}
|
|
|
// 上市期
|
|
|
if (!empty($value['expect_arrival_time'])) {
|
|
|
$oneGoods['appearDate'] = $value['expect_arrival_time'];
|
|
|
}
|
|
|
// 商品链接
|
|
|
if ($haveLink && isset($value['product_id'])) {
|
|
|
$oneGoods['link'] = self::url('/product/pro_' . $value['product_id'] . '_' . $value['goods_id'] . '/' . $value['cn_alphabet'] . '.html');
|
|
|
}
|
|
|
|
|
|
$arr[$key] = $oneGoods;
|
|
|
}
|
|
|
|
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 格式化加价购商品
|
|
|
*
|
|
|
* @param array $advanceGoods 加价购商品列表
|
|
|
* @param bool $haveLink 控制是否需要商品链接
|
|
|
*/
|
|
|
public static function formatAdvanceGoods($advanceGoods)
|
|
|
{
|
|
|
$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;
|
|
|
}
|
|
|
|
|
|
$arr[] = $gift;
|
|
|
}
|
|
|
|
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单状态,按订单支付类型和订单状态
|
|
|
* @var array
|
|
|
*/
|
...
|
...
|
|