Exemplo n.º 1
0
 public function removeCart()
 {
     $postCartIdsData = input::get('cart_id');
     $tmpCartIds = array();
     foreach ($postCartIdsData as $cartId => $v) {
         if ($v == '1') {
             $tmpCartIds['cart_id'][] = $cartId;
         }
     }
     $params['cart_id'] = implode(',', $tmpCartIds['cart_id']);
     $params['user_id'] = userAuth::id();
     try {
         $res = app::get('topc')->rpcCall('trade.cart.delete', $params);
         if ($res === false) {
             throw new Exception(app::get('topc')->_('删除失败'));
         }
     } catch (Exception $e) {
         $msg = $e->getMessage();
         return $this->splash('error', null, $msg, true);
     }
     userAuth::syncCookieWithCartNumber(app::get('topc')->rpcCall('trade.cart.getCount', ['user_id' => userAuth::id()], 'buyer'));
     $url = url::action('topc_ctl_cart@index');
     return $this->splash('success', $url, '删除成功', true);
 }