/** * 购物车 */ public function cartAction() { $gid = intval($this->param('g', 0)); if (!$gid) { exit('empty g'); } $cid = intval($this->param('c', 0)); if (!$cid) { exit('empty c'); } $category = CategoryData::getById($cid); if ($category['group_id'] != $gid) { exit('该圈子无此分类'); } $cart = array(); $cart = $this->getCart($cid); $group = GroupData::getById($category['group_id']); $currUser = $currUserGroup = array(); $isLogin = $this->isLogin(); if ($isLogin) { $currUser = $this->getCurrentUser(); $userGroups = UserGroupData::getGroupsByUid($currUser['id']); foreach ($userGroups as $userGroup) { if ($group['id'] == $userGroup['group_id']) { $currUserGroup = $userGroup; break; } } } $store = StoreData::getById($category['store_id']); $this->assign('group', $group); $this->assign('store', $store); $this->assign('currUser', $currUser); $this->assign('currUserGroup', $currUserGroup); $this->assign('category', $category); $this->assign('products', $cart['products']); $this->assign('totalPrice', $cart['totalPrice']); $this->display(); }
/** * 退出圈子 */ public function quitgroupAction() { if (ComTool::isAjax()) { $gid = intval($this->post('gid', 0)); ComTool::checkEmpty($gid, "操作失败,请刷新重试"); $currUser = $this->getCurrentUser(); $sql = "delete from user_group where user_id='{$currUser['id']}' and group_id='{$gid}'"; $res = UserGroupData::sql($sql); ComTool::result($res, '操作失败,请刷新重试', '操作成功'); } }