Authored by yangyang

购物车选择bug修改

... ... @@ -59,7 +59,7 @@ class CartData
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public static function selectGoods($uid, $sku, $shoppingKey, $hasPromotion = false)
public static function selectGoods($uid, $sku, $shoppingKey, $hasPromotion)
{
$param = Yohobuy::param();
$param['method'] = $hasPromotion ? 'app.Shopping.selectedAndCart' : 'app.Shopping.selected';
... ... @@ -111,7 +111,7 @@ class CartData
public static function removeFromCart($uid, $sku, $shoppingKey, $hasPromotion = false)
{
$param = Yohobuy::param();
$param['method'] = $hasPromotion ? 'app.Shopping.removeAndCart' : 'app.Shopping.remove';;
$param['method'] = $hasPromotion ? 'app.Shopping.removeAndCart' : 'app.Shopping.remove';
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
... ...
... ... @@ -135,7 +135,7 @@ class CartModel
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public static function selectGoods($uid, $skuList, $shoppingKey, $hasPromotion = false)
public static function selectGoods($uid, $skuList, $shoppingKey)
{
$result = array('code' => 400, 'message' => '出错啦~');
... ... @@ -143,8 +143,11 @@ class CartModel
if (empty($skuList)) {
break;
}
$select = CartData::selectGoods($uid, $skuList, $shoppingKey,$hasPromotion);
$arr = json_decode($skuList, true);
$arr[0]['promotion_id'] = $arr[0]['hasPromotion'];
$hasPromotion = $arr[0]['hasPromotion'];
$skuList = json_encode($arr);
$select = CartData::selectGoods($uid, $skuList, $shoppingKey, $hasPromotion);
if ($select && isset($select['code'])) {
$result['code'] = $select['code'];
$result['message'] = $select['message'];
... ... @@ -168,8 +171,7 @@ class CartModel
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => intval($count) ));
$sku_list = json_encode(array(array('product_sku'=>$sku,'buy_number'=>intval($count), 'promotion_id'=>$hasPromotion)));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey, $hasPromotion);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
... ...
... ... @@ -103,8 +103,8 @@ class IndexController extends AbstractAction
$productId = $this->post('skuList', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$hasPromotion = $this->post('hasPromotion', false);
$result = CartModel::selectGoods($uid, $productId, $shoppingKey, $hasPromotion);
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
}
$this->echoJson($result);
... ... @@ -123,7 +123,8 @@ class IndexController extends AbstractAction
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$hasPromotion = $this->post('hasPromotion', false);
$result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey);
$result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey, $hasPromotion);
}
$this->echoJson($result);
... ...