Authored by 毕凯

Merge branch 'hotfix/DelCartBug' into develop

... ... @@ -12,6 +12,7 @@
namespace Api;
use Plugin\Cache;
class Yohobuy
{
/* 正式环境 */
... ... @@ -68,25 +69,26 @@ class Yohobuy
public static function clientType()
{
if(self::isMobile()) {
// 苹果设备
if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
return 'iphone';
}
// 苹果IPAD
elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
return 'ipad';
}
elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
return 'android';
}
// 其它
else {
return 'h5';
}
}
else {
return 'web';
}
// // 苹果设备
// if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
// return 'iphone';
// }
// // 苹果IPAD
// elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
// return 'ipad';
// }
// elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
// return 'android';
// }
// // 其它
// else {
// return 'android';
// }
}
/**
... ...
... ... @@ -62,9 +62,8 @@ class CartData
public static function selectGoods($uid, $sku, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.selected';
$param['method'] = 'app.Shopping.selectedAndCart';
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
$param['uid'] = $uid;
}
... ... @@ -112,7 +111,7 @@ class CartData
public static function removeFromCart($uid, $sku, $shoppingKey)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.remove';
$param['method'] = 'app.Shopping.removeAndCart';
$param['product_sku_list'] = $sku;
if (!empty($uid)) {
... ... @@ -134,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);
... ...
... ... @@ -387,6 +387,9 @@ class Helpers
case '5': // 小贴士
$result['isTip'] = true;
break;
case '19': // 专题
$result['isSpecialTopic'] = true;
break;
}
}
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -187,15 +187,16 @@ $('.icon-del').on('touchstart', function(e) {
rightBtnText: '确定'
}
}, function() {
var id = $this.closest('.shopping-cart-good').data('id'),
var $shoppingCartGood = $this.closest('.shopping-cart-good'),
count = $this.data('count');
$.ajax({
method: 'post',
url: '/cart/index/del',
data: {
sku: id,
count: count
sku: $shoppingCartGood.data('id'),
count: count,
promotionId: $shoppingCartGood.data('promotion')
}
}).then(function(data) {
if (data.code === 200) {
... ...
... ... @@ -168,13 +168,13 @@ class CartModel
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public static function removeFromCart($uid, $sku, $count, $shoppingKey, $hasPromotion = false)
public static function removeFromCart($uid, $sku, $count, $shoppingKey, $promotionId = 0)
{
$result = array('code' => 400, 'message' => '出错啦~');
// 处理sku
$sku_list = json_encode(array(array('product_sku'=>$sku,'buy_number'=>intval($count), 'promotion_id'=>$hasPromotion)));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey, $hasPromotion);
$sku_list = json_encode(array(array('product_sku'=>$sku,'buy_number'=>intval($count), 'promotion_id'=>$promotionId)));
$remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey);
if ($remove && isset($remove['code'])) {
$result['code'] = $remove['code'];
$result['message'] = $remove['message'];
... ...
... ... @@ -122,7 +122,9 @@ class IndexController extends AbstractAction
$count = $this->post('count', 0);
$uid = $this->getUid(true);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey);
$promotionId = $this->post('promotionId', 0);
$result = CartModel::removeFromCart($uid, $sku, $count, $shoppingKey, $promotionId);
}
$this->echoJson($result);
... ...