...
|
...
|
@@ -51,6 +51,75 @@ class CartModel |
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移出购物车
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sku 商品sku列表
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
public static function removeFromCart($uid, $sku)
|
|
|
{
|
|
|
$result = array('code' => 400, 'message' => '出错啦~');
|
|
|
|
|
|
// 处理sku
|
|
|
$sku_list = json_encode(array($sku => 1));
|
|
|
|
|
|
$remove = CartData::removeFromCart($uid, $sku_list);
|
|
|
if ($remove && isset($remove['code'])) {
|
|
|
$result['code'] = $remove['code'];
|
|
|
$result['message'] = $remove['message'];
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移入收藏夹
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sku 商品sku列表
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
public static function addToFav($uid, $sku)
|
|
|
{
|
|
|
$result = array('code' => 400, 'message' => '出错啦~');
|
|
|
|
|
|
// 处理sku
|
|
|
$sku_list = json_encode(array($sku => 1));
|
|
|
|
|
|
$add = CartData::addToFav($uid, $sku_list);
|
|
|
if ($add && isset($add['code'])) {
|
|
|
$result['code'] = $add['code'];
|
|
|
$result['message'] = $add['message'];
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改购物车商品数据
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $param 要更改的数据
|
|
|
* @return array 接口返回的数据
|
|
|
*/
|
|
|
public static function modifyCartProduct($uid, $param)
|
|
|
{
|
|
|
$result = array('code' => 400, 'message' => '出错啦~');
|
|
|
|
|
|
// 处理要更改的数据
|
|
|
$swapData = json_encode(array($param));
|
|
|
|
|
|
$modify = CartData::addToFav($uid, $swapData);
|
|
|
if ($modify && isset($modify['code'])) {
|
|
|
$result['code'] = $modify['code'];
|
|
|
$result['message'] = $modify['message'];
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 处理不同类型的购物车数据
|
...
|
...
|
@@ -65,7 +134,7 @@ class CartModel |
|
|
$oneGoods = array();
|
|
|
// 购买的商品列表
|
|
|
foreach ($data['goods_list'] as $value) {
|
|
|
$oneGoods['id'] = $value['product_id'];
|
|
|
$oneGoods['id'] = $value['product_sku'];
|
|
|
$oneGoods['name'] = $value['product_name'];
|
|
|
$oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120);
|
|
|
$oneGoods['color'] = $value['color_name'];
|
...
|
...
|
|