添加当购物车商品为空时不能进入购物车结算页的逻辑
Showing
6 changed files
with
34 additions
and
3 deletions
@@ -10,6 +10,20 @@ use Plugin\Helpers; | @@ -10,6 +10,20 @@ use Plugin\Helpers; | ||
10 | */ | 10 | */ |
11 | class ShoppingcartController extends AbstractAction | 11 | class ShoppingcartController extends AbstractAction |
12 | { | 12 | { |
13 | + /** | ||
14 | + * 通过当前用户审判是否跳到登录 | ||
15 | + * | ||
16 | + * @param boolean $useSession (true:从服务端session中检查, false:从客户端cookie中检查) | ||
17 | + * @return void | ||
18 | + */ | ||
19 | + protected function auditJumpLogin($useSession = true) | ||
20 | + { | ||
21 | + $uid = $this->getUid($useSession); | ||
22 | + if (!$uid) { | ||
23 | + $this->go(Helpers::url('/signin.html', array('refer' => $this->server('HTTP_REFERER', SITE_MAIN)))); | ||
24 | + } | ||
25 | + } | ||
26 | + | ||
13 | /* | 27 | /* |
14 | * 购物车首页 | 28 | * 购物车首页 |
15 | */ | 29 | */ |
@@ -221,17 +235,28 @@ class ShoppingcartController extends AbstractAction | @@ -221,17 +235,28 @@ class ShoppingcartController extends AbstractAction | ||
221 | */ | 235 | */ |
222 | public function orderEnsureAction() | 236 | public function orderEnsureAction() |
223 | { | 237 | { |
238 | + // 审判跳转登录页 | ||
239 | + $this->auditJumpLogin(); | ||
240 | + | ||
224 | $this->setTitle('购物车'); | 241 | $this->setTitle('购物车'); |
225 | $this->setNavHeader('购物车'); | 242 | $this->setNavHeader('购物车'); |
226 | 243 | ||
227 | - $cartType = $this->post('cartType', 'ordinary'); | 244 | + // 购物车商品为空跳转到购物车页面 |
245 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); | ||
246 | + $uid = $this->getUid(true); | ||
247 | + $cartGoods = CartModel::getCartData($uid, $shoppingKey); | ||
248 | + if (empty($cartGoods) || isset($cartGoods['isEmptyCart'])) { | ||
249 | + $this->go(Helpers::url('/shoppingcart')); | ||
250 | + } | ||
251 | + | ||
252 | + $cartType = $this->get('cartType', 'ordinary'); | ||
228 | $cookieData = $this->getCookie('order-info', null); | 253 | $cookieData = $this->getCookie('order-info', null); |
229 | $uid = $this->getUid(true); | 254 | $uid = $this->getUid(true); |
230 | $data = array( | 255 | $data = array( |
231 | 'orderEnsurePage' => true, | 256 | 'orderEnsurePage' => true, |
232 | 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData) | 257 | 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData) |
233 | ); | 258 | ); |
234 | - // var_dump($data); | 259 | + |
235 | $this->_view->display('order-ensure', $data); | 260 | $this->_view->display('order-ensure', $data); |
236 | } | 261 | } |
237 | 262 | ||
@@ -288,7 +313,6 @@ class ShoppingcartController extends AbstractAction | @@ -288,7 +313,6 @@ class ShoppingcartController extends AbstractAction | ||
288 | 313 | ||
289 | if ($this->isAjax()) { | 314 | if ($this->isAjax()) { |
290 | $uid = $this->getUid(true); | 315 | $uid = $this->getUid(true); |
291 | - $page = $this->get('page', 1); | ||
292 | $result = CartModel::getCouponList($uid); | 316 | $result = CartModel::getCouponList($uid); |
293 | } | 317 | } |
294 | 318 | ||
@@ -304,6 +328,9 @@ class ShoppingcartController extends AbstractAction | @@ -304,6 +328,9 @@ class ShoppingcartController extends AbstractAction | ||
304 | */ | 328 | */ |
305 | public function selectAddressAction() | 329 | public function selectAddressAction() |
306 | { | 330 | { |
331 | + // 审判跳转登录页 | ||
332 | + $this->auditJumpLogin(); | ||
333 | + | ||
307 | // 设置网站标题 | 334 | // 设置网站标题 |
308 | $this->setTitle('选择地址'); | 335 | $this->setTitle('选择地址'); |
309 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); | 336 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); |
@@ -323,9 +350,13 @@ class ShoppingcartController extends AbstractAction | @@ -323,9 +350,13 @@ class ShoppingcartController extends AbstractAction | ||
323 | */ | 350 | */ |
324 | public function selectCouponAction() | 351 | public function selectCouponAction() |
325 | { | 352 | { |
353 | + // 审判跳转登录页 | ||
354 | + $this->auditJumpLogin(); | ||
355 | + | ||
326 | // 设置网站标题 | 356 | // 设置网站标题 |
327 | $this->setTitle('选择优惠券'); | 357 | $this->setTitle('选择优惠券'); |
328 | $this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure')); | 358 | $this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure')); |
359 | + | ||
329 | $this->_view->display('select-coupon', array( | 360 | $this->_view->display('select-coupon', array( |
330 | 'selectCouponPage' => true, | 361 | 'selectCouponPage' => true, |
331 | 'pageFooter' => true | 362 | 'pageFooter' => true |
-
Please register or login to post a comment