Authored by Rock Zhang

添加当购物车商品为空时不能进入购物车结算页的逻辑

... ... @@ -10,6 +10,20 @@ use Plugin\Helpers;
*/
class ShoppingcartController extends AbstractAction
{
/**
* 通过当前用户审判是否跳到登录
*
* @param boolean $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @return void
*/
protected function auditJumpLogin($useSession = true)
{
$uid = $this->getUid($useSession);
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN))));
}
}
/*
* 购物车首页
*/
... ... @@ -221,17 +235,28 @@ class ShoppingcartController extends AbstractAction
*/
public function orderEnsureAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('购物车');
$this->setNavHeader('购物车');
$cartType = $this->post('cartType', 'ordinary');
// 购物车商品为空跳转到购物车页面
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(true);
$cartGoods = CartModel::getCartData($uid, $shoppingKey);
if (empty($cartGoods) || isset($cartGoods['isEmptyCart'])) {
$this->go(Helpers::url('/shoppingcart'));
}
$cartType = $this->get('cartType', 'ordinary');
$cookieData = $this->getCookie('order-info', null);
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
);
// var_dump($data);
$this->_view->display('order-ensure', $data);
}
... ... @@ -288,7 +313,6 @@ class ShoppingcartController extends AbstractAction
if ($this->isAjax()) {
$uid = $this->getUid(true);
$page = $this->get('page', 1);
$result = CartModel::getCouponList($uid);
}
... ... @@ -304,6 +328,9 @@ class ShoppingcartController extends AbstractAction
*/
public function selectAddressAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('选择地址');
$this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure'));
... ... @@ -323,9 +350,13 @@ class ShoppingcartController extends AbstractAction
*/
public function selectCouponAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('选择优惠券');
$this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure'));
$this->_view->display('select-coupon', array(
'selectCouponPage' => true,
'pageFooter' => true
... ...