Authored by Rock Zhang

修改单个选取购物车商品以及全选购物车商品的接口

Code Review By Rock Zhang
... ... @@ -72,10 +72,11 @@ class ShoppingcartController extends AbstractAction
$result = array();
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$shoppingKey = $this->getSession('shoppingKey');
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
$skuList = $this->post('skuList', null);
$result = CartModel::selectGoods($uid, $skuList, $shoppingKey);
}
if (empty($result)) {
... ...
... ... @@ -96,22 +96,25 @@ class CartModel
* 购物车商品选择与取消接口返回的数据处理
*
* @param int $uid 用户ID
* @param string $sku 商品sku列表
* @param string $skuList 商品sku列表
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public static function selectGoods($uid, $sku, $shoppingKey)
public static function selectGoods($uid, $skuList, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => 1));
do {
if (empty($skuList)) {
break;
}
$select = CartData::selectGoods($uid, $sku_list, $shoppingKey);
if ($select && isset($select['code'])) {
$result['code'] = $select['code'];
$result['message'] = $select['message'];
}
$select = CartData::selectGoods($uid, $skuList, $shoppingKey);
if ($select && isset($select['code'])) {
$result['code'] = $select['code'];
$result['message'] = $select['message'];
}
}while(0);
return $result;
}
... ...