Authored by yangyang

购物车添加相同sku商品bug

... ... @@ -59,10 +59,10 @@ class CartData
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 购物车接口返回的数据
*/
public static function selectGoods($uid, $sku, $shoppingKey)
public static function selectGoods($uid, $sku, $shoppingKey, $hasPromotion = false)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.selected';
$param['method'] = $hasPromotion ? 'app.Shopping.selectedAndCart' : 'app.Shopping.selected';
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
$param['uid'] = $uid;
... ... @@ -108,10 +108,10 @@ class CartData
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $shoppingKey)
public static function removeFromCart($uid, $sku, $shoppingKey, $hasPromotion = false)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.remove';
$param['method'] = $hasPromotion ? 'app.Shopping.removeAndCart' : 'app.Shopping.remove';;
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
... ... @@ -133,10 +133,10 @@ class CartData
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
public static function addToFav($uid, $sku, $hasPromotion = false)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.addfavorite';
$param['method'] = $hasPromotion ? 'app.Shopping.addfavoriteAndCart' : 'app.Shopping.addfavorite';
$param['product_sku_list'] = $sku;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
... ...
... ... @@ -135,7 +135,7 @@ class CartModel
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 处理之后的数据的数据
*/
public static function selectGoods($uid, $skuList, $shoppingKey)
public static function selectGoods($uid, $skuList, $shoppingKey, $hasPromotion = false)
{
$result = array('code' => 400, 'message' => '出错啦~');
... ... @@ -144,7 +144,7 @@ class CartModel
break;
}
$select = CartData::selectGoods($uid, $skuList, $shoppingKey);
$select = CartData::selectGoods($uid, $skuList, $shoppingKey,$hasPromotion);
if ($select && isset($select['code'])) {
$result['code'] = $select['code'];
$result['message'] = $select['message'];
... ... @@ -163,14 +163,14 @@ class CartModel
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $count, $shoppingKey)
public static function removeFromCart($uid, $sku, $count, $shoppingKey, $hasPromotion = false)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array($sku => intval($count) ));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey);
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey, $hasPromotion);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
... ... @@ -186,7 +186,7 @@ class CartModel
* @param string $sku 商品sku列表
* @return array 接口返回的数据
*/
public static function addToFav($uid, $sku)
public static function addToFav($uid, $sku, $hasPromotion = false)
{
$result = array('code' => 400, 'message' => '出错啦~');
... ... @@ -201,7 +201,7 @@ class CartModel
// 处理sku
$sku_list = json_encode(array($sku => 1));
$add = CartData::addToFav($uid, $sku_list);
$add = CartData::addToFav($uid, $sku_list, $hasPromotion);
if ($add && isset($add['code'])) {
$result['code'] = $add['code'];
$result['message'] = $add['message'];
... ...
... ... @@ -103,7 +103,8 @@ class IndexController extends AbstractAction
$productId = $this->post('skuList', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::selectGoods($uid, $productId, $shoppingKey);
$hasPromotion = $this->post('hasPromotion', false);
$result = CartModel::selectGoods($uid, $productId, $shoppingKey, $hasPromotion);
}
$this->echoJson($result);
... ... @@ -121,6 +122,7 @@ class IndexController extends AbstractAction
$count = $this->post('count', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$hasPromotion = $this->post('hasPromotion', false);
$result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey);
}
... ... @@ -137,7 +139,8 @@ class IndexController extends AbstractAction
if ($this->isAjax()) {
$productId = $this->post('id', 0);
$uid = $this->getUid(true);
$result = CartModel::addToFav($uid, $productId);
$hasPromotion = $this->post('hasPromotion', false);
$result = CartModel::addToFav($uid, $productId, $hasPromotion);
}
$this->echoJson($result);
... ...