/** * 购物车 */ 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 joingroupAction() { if (ComTool::isAjax()) { if (isset($_POST['captcha'])) { $captcha = trim($this->post('captcha')); if (!ComTool::checkCaptcha($captcha)) { ComTool::ajax(100001, '验证码错误'); } } $city = trim($this->post('city')); ComTool::checkEmpty($city, '请选择城市'); $area = trim($this->post('area')); ComTool::checkEmpty($area, '请选择区域'); $group = trim($this->post('group')); ComTool::checkEmpty($group, '请选择圈子'); $addr_desc = trim($this->post('addr_desc')); ComTool::checkEmpty($addr_desc, '请填写详细位置'); ComTool::checkMaxLen($addr_desc, 32, '详细位置最多32位'); $currUser = $this->getCurrentUser(); $groupsNumLimit = Cola::getConfig('_groupsNumLimit'); $groups = UserGroupData::getGroupsByUid($currUser['id']); foreach ($groups as $v) { if ($group == $v['group_id']) { ComTool::ajax(100001, '已加入该圈子'); } } if (count($groups) > $groupsNumLimit) { ComTool::ajax(100001, '已加入圈子数超过限制'); } $res = UserGroupData::add(array('user_id' => $currUser['id'], 'group_id' => $group, 'detail' => $addr_desc, 'status' => 1)); ComTool::result($res, '操作失败,请刷新重试', '操作成功'); } }