Authored by Rock Zhang

修复限购商品支付的有关问题

Code Review By Rock Zhang
... ... @@ -473,7 +473,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
} else if (limitProductCode) {
// 当前面板选择的是限购商品
url = 'http://m.yohobuy.com/cart/index/orderEnsure?limitproductcode=' + limitProductCode + '&sku=' +
url = $('#limitProductPay').val() + '?limitproductcode=' + limitProductCode + '&sku=' +
productSku + '&skn=' + skn + '&buy_number=' + buyNumber;
//打开结算页面,结束函数执行。
... ...
... ... @@ -75,6 +75,7 @@ isLimitGood() && (function() {
a.push(data);
orderInfo('skuList', JSON.stringify(a));
orderInfo('limitUrlSufix', location.search);
})();
if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) {
... ...
... ... @@ -26,7 +26,7 @@ $('.address-item').on('touchend', function() {
orderInfo('addressId', addressId);
orderInfo('address', address);
window.location.href = $this.data('href');
window.location.href = $this.data('href') + (orderInfo('limitUrlSufix') || '');
}).on('touchend', '.edit', function() {
window.location.href = $(this).data('href');
return false;
... ...
... ... @@ -68,7 +68,7 @@ $('#likeBtn').on('touchstart', function() {
$('#addtoCart').on('touchstart', function() {
$('.cart-bar').hide();
productCode || chosePanel.setLimitGoodModeWithSknId(productCode, skn);
productCode && chosePanel.setLimitGoodModeWithSknId(productCode, skn);
chosePanel.show();
//统计代码:用于统计用户加入购物车的动作
... ...
... ... @@ -43,7 +43,7 @@
<ul class="sale-invoice">
{{#if isOrdinaryCart}}
<li class="coupon">
<a href="/cart/index/selectCoupon">
<a href="{{#if isLimit}}javascript:void(0);{{else}}/cart/index/selectCoupon{{/if}}">
<span class="title">优惠券</span>
{{# coupon}}
<!--<span class="coupon-count">
... ... @@ -57,7 +57,7 @@
</span>
{{^}}
<span class="not-used coupon-use">
未使用
{{#if isLimit}}该商品不可使用优惠券{{else}}未使用{{/if}}
<i class="iconfont">&#xe614;</i>
</span>
{{/if}}
... ...
... ... @@ -158,9 +158,10 @@
{{#if noLimitCode}}
<a href="javascript:;" class="sold-out">立即购买</a>
{{/if}}
<input type="hidden" name="limitCodeUrl" value="{{limitCodeUrl}}">
<input type="hidden" id="limitCodeUrl" name="limitCodeUrl" value="{{limitCodeUrl}}">
<input type="hidden" id="limitProductPay" name="limitProductPay" value="{{limitProductPay}}">
{{#limitProductCode}}
<input type="hidden" name="limitProductCode" value="{{.}}">
<input type="hidden" id="limitProductCode" name="limitProductCode" value="{{.}}">
{{/limitProductCode}}
<a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a>
... ...
... ... @@ -336,28 +336,22 @@ class CartModel
'buy_number' => $buyNumber
)
));
$result['isLimit'] = true;
}
$pay = CartData::cartPay($uid, $cartType, 0, $skuList);
// 限购商品结算接口返回逻辑判定
if ($isLimitGoods) {
if (!$pay) {
$result['needReload'] = true;
} elseif (isset($pay['code']) && $pay['code'] != 200) {
$result['error'] = true;
}
return $result;
}
do {
if (!$pay || $pay['code'] != 200 || empty($pay['data']['goods_list'])) {
if ($isLimitGoods) {
$result['error'] = true;
} else {
$result['cartUrl'] = Helpers::url('/cart/index/index');
}
// 普通或者预售商品为空返回
if (!$pay || empty($pay['data']['goods_list'])) {
$result['cartUrl'] = Helpers::url('/cart/index/index');
return $result;
}
break;
}
if ($pay && isset($pay['code']) && $pay['code'] === 200) {
$payReturn = $pay['data'];
$address = array();
$orderCompute = array();
... ... @@ -518,7 +512,8 @@ class CartModel
$coupons['couponName'] = $orderInfo['couponName'];
}
$result['coupon'] = $coupons;
}
} while (false);
return $result;
}
... ...
... ... @@ -327,6 +327,7 @@ class DetailModel
$result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];
$result['cartInfo']['limitCodeUrl'] = self::getLimitCodeUrl($baseInfo['erpProductId']);
$result['cartInfo']['limitProductPay'] = Helpers::url('/cart/index/orderEnsure');
} else {
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
}
... ...
... ... @@ -306,10 +306,7 @@ class IndexController extends AbstractAction
if (isset($order['cartUrl'])) { // 普通或者预售商品为空时
$this->go($order['cartUrl']);
}
if (isset($order['needReload'])) { // 限购商品支付接口返回为空时
$this->go(Helpers::url($this->server('REQUEST_URI')));
}
if (isset($order['error'])) { // 限购商品支付接口返回为错误时
if (isset($order['error'])) { // 限购商品支付接口返回为空或错误时
$this->error();
}
... ...