...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
namespace Index;
|
|
|
|
|
|
use LibModels\Wap\Home\CartData;
|
|
|
use Plugin\Helpers;
|
|
|
use Plugin\Images;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -98,6 +99,70 @@ class CartModel |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理购物车商品数据
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $skn 商品skn
|
|
|
* @param int $num 购买数目
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
public static function cartProductData($uid, $skn, $num)
|
|
|
{
|
|
|
$result = array('code' => 400, 'message' => '出错啦~');
|
|
|
|
|
|
$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;
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改购物车商品数据
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
...
|
...
|
@@ -135,6 +200,7 @@ class CartModel |
|
|
// 购买的商品列表
|
|
|
foreach ($data['goods_list'] as $value) {
|
|
|
$oneGoods['id'] = $value['product_sku'];
|
|
|
$oneGoods['skn'] = $value['product_skn'];
|
|
|
$oneGoods['name'] = $value['product_name'];
|
|
|
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
|
|
|
$oneGoods['color'] = $value['color_name'];
|
...
|
...
|
|