/** * 我的订单 */ public function orderAction() { $pageSize = 20; $curPage = intval($this->param('p', 1)); $curPage = $curPage < 1 ? 1 : $curPage; $curUser = $this->getCurrentUser(); $where = "user_id='{$curUser['id']}' and status='1'"; $totalItems = OrderData::count($where); $list = array(); if ($totalItems) { $totalPages = ceil($totalItems / $pageSize); $curPage = $curPage > $totalPages ? $totalPages : $curPage; $start = $pageSize * ($curPage - 1); $sql = "select * from `order` where {$where} order by create_time desc limit {$start},{$pageSize}"; $list = OrderData::sql($sql); if ($list) { $pageHtml = ComTool::pageHtml($curPage, $pageSize, $totalItems, $this->urlroot . 'my/order/p'); } } $this->assign('list', $list); $this->assign('pageHtml', $pageHtml); $this->display(); }
/** * 删除订单 */ public function delAction() { if (ComTool::isAjax()) { if (!$this->isLogin()) { ComTool::ajax(Cola::getConfig('_error.mustlogin'), '请先登录,即将跳转至登录页面'); } $currUser = $this->getCurrentUser(); $orderId = $this->post('oid', ''); if (!$orderId) { ComTool::ajax(100001, '未知订单'); } $orderId = ComTool::escape($orderId); $updateTime = time(); $sql = "update `order` set `status`=4,update_time='{$updateTime}' where id='{$orderId}' and user_id='{$currUser['id']}'"; $res = OrderData::sql($sql); if ($res === false) { ComTool::ajax(100001, '服务器忙,请重试'); } //暂时不删除订单详情(order_detail表) ComTool::ajax(100000, 'ok'); } }