function admin() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'message', roleModel::POWER_ALL)) { $this->view = new view(config('view'), 'admin/message.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $messageModel = $this->model('message'); $start = filter::int($this->get->start); $length = filter::int($this->get->length); $start = empty($start) ? 0 : $start; $length = empty($length) ? 10 : $length; $this->get->start = $start; $this->get->length = $length; $count = $messageModel->select('count(*)'); $count = $count[0]['count(*)']; $this->view->assign('count', $count); $message = $messageModel->fetchAll($start, $length); $this->view->assign('message', $message); return $this->view->display(); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }
function admin() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'hotorder', roleModel::POWER_ALL)) { $this->view = new view(config('view'), 'admin/hot_admin.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $hotorderModel = $this->model('hotorder'); $filter = array(); $hotorder = $hotorderModel->fetchAll($filter); foreach ($hotorder as &$product) { $img = $this->model('productimg')->getByPid($product['id']); if (isset($img[0]['thumbnail_path'])) { $product['img'] = $img[0]['thumbnail_path']; } } $this->view->assign('hotorder', $hotorder); return $this->view->display(); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }
/** * 新用户注册活动管理界面 */ function admin() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'register', roleModel::POWER_ALL)) { $this->view = new view(config('view'), 'admin/register_admin.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $id = 1; $registerModel = $this->model('register'); $reigster = $registerModel->get($id); $this->view->assign('register', $reigster); $themeModel = $this->model('theme'); $theme = $themeModel->select(); $this->view->assign('theme', $theme); $productModel = $this->model('product'); $product = $productModel->where('stock>?', array(0))->select(); $this->view->assign('product', $product); $couponModel = $this->model('coupon'); $coupon = $couponModel->select(); $this->view->assign('coupon', $coupon); return $this->view->display(); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }
/** * 从满减优惠中移除商品 */ function remove() { $this->response->addHeader('Content-Type', 'application/json'); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'fullcut', roleModel::POWER_UPDATE)) { $pid = filter::int($this->post->pid); $fid = filter::int($this->post->fid); $fullcutdetailModel = $this->model('fullcutdetail'); if ($fullcutdetailModel->remove($fid, $pid)) { return json_encode(array('code' => 1, 'result' => 'ok')); } return json_encode(array('code' => 0, 'result' => '移除失败')); } return json_encode(array('code' => 2, 'result' => '没有权限')); }
/** * 创建管理员角色 * @param string post name 角色名称 * @return string */ function create() { $this->response->addHeader('Content-Type', 'application/json'); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'role', roleModel::POWER_INSERT)) { $name = $this->post->name; if (!empty($name)) { $result = $roleModel->add($name); if ($result) { return json_encode(array('code' => 1, 'result' => 'ok')); } } return json_encode(array('code' => 0, 'result' => '请填写管理组名')); } return json_encode(array('code' => 2, 'result' => '权限不足')); }
/** * 添加配送方案 */ function create() { $this->response->addHeader('Content-Type', 'application/json'); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'system', roleModel::POWER_INSERT)) { $name = $this->post->name; $code = $this->post->code; $max = $this->post->max; $price = $this->post->price; $shipModel = $this->model('ship'); if ($shipModel->create($name, $code, $max, $price)) { return json_encode(array('code' => 1, 'result' => 'ok')); } return json_encode(array('code' => 2, 'result' => 'failed')); } return json_encode(array('code' => 3, 'result' => '没有权限')); }
function admin() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'jpush', roleModel::POWER_ALL)) { $this->view = new view(config('view'), 'admin/jpush.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $jpush = $this->model('jpush')->fetch('jpush.content,jpush.time,admin.username'); $this->view->assign('jpush', $jpush); return $this->view->display(); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }
/** * 系统日志页面 */ function index() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'log', roleModel::POWER_ALL)) { $this->view = new view(config('view'), 'admin/log.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $logModel = $this->model('log'); $this->view->assign('log', $logModel->select()); $this->response->setBody($this->view->display()); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }
/** * 查看资金流水记录 */ function lists() { $filter = array(); if (login::user()) { $filter['uid'] = $this->session->id; } else { if (!login::admin()) { return new json(json::NOT_LOGIN); } } $start = empty($this->get->start) ? 0 : $this->get->start; $start = intval($start); $length = empty($this->get->length) ? 10 : $this->get->length; $length = intval($length); $filter['start'] = $start; $filter['length'] = $length; $filter['order'] = array(array('time' => 'desc'), array('id' => 'desc')); $result = $this->model('swift')->fetchAll($filter); return new json(json::OK, NULL, $result); }
/** * 更改映射关系对应的价格库存或者是商品编号 自动更新 */ function updatevalue() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'product', roleModel::POWER_UPDATE)) { $data = json_decode(htmlspecialchars_decode($this->post->data)); $pid = $this->post->pid; $collectionModel = $this->model('collection'); foreach ($data as $value) { $array = array(); $type = $value->type; $did = $value->did; $val = $value->value; $didd = explode(',', $did); foreach ($didd as $a) { list($x, $y) = explode(':', $a); $array[$x] = $y; } $collectionModel->create($array, $pid, $type, $val); } return json_encode(array('code' => 1, 'result' => 'ok')); } return json_encode(array('code' => 2, 'result' => '没有权限')); }
/** * 收货地址的管理界面 */ function admin() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'user', roleModel::POWER_ALL)) { $this->view = new view(config('view'), 'admin/address.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $filter = array('order' => array('address.id', 'desc')); $addressModel = $this->model('address'); $address = $addressModel->fetchAll($filter); $this->view->assign('address', $address); return $this->view->display(); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', '__404')); } }
/** * 复制或者剪切的ajax请求 * @return string */ function paste() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'category', roleModel::POWER_UPDATE)) { $id = json_decode($this->post->id); $mode = $this->post->mode; $parent = $this->post->parent == '#' ? 0 : filter::int($this->post->parent); if (empty($id) || empty($mode) || empty($parent)) { return json_encode(array('code' => 0, 'result' => '参数错误')); } $categoryModel = $this->model('category'); if ($categoryModel->paste($id, $mode, $parent)) { return new json(json::OK); } return new json(json::PARAMETER_ERROR, '失败了'); } return new json(json::NOT_LOGIN); }
/** * 商品列表 * @return string */ function ajaxdatatable() { $productModel = $this->model('product'); $resultObj = new \stdClass(); try { if ($this->post->customActionType == 'group_action') { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'product', roleModel::POWER_SELECT)) { if (!empty($this->post->customActionName)) { $logModel = $this->model('log'); foreach ($this->post->id as $id) { $logModel->write($this->session->username, '修改了商品(' . $id . ')的操作方式:' . $this->post->customActionName); switch ($this->post->customActionName) { case 1: case 2: $productModel->where('id=?', array($id))->update('status', $this->post->customActionName); break; case 3: $productModel->remove($id); break; default: break; } } } } } } catch (\Exception $e) { return json_encode(array('code' => 0, 'result' => '参数异常')); } $resultObj->draw = $this->post->draw; $result = $productModel->searchable($this->post); $resultObj->recordsTotal = $productModel->count(); $resultObj->recordsFiltered = count($result); $result = array_slice($result, $this->post->start, $this->post->length); $brandModel = $this->model('brand'); $prototypeModel = $this->model('prototype'); $categoryModel = $this->model('category'); $productimgModel = $this->model('productimg'); foreach ($result as &$product) { if (isset($product['id'])) { if (isset($product['bid'])) { $product['brand'] = $brandModel->get($product['bid'], 'name'); unset($product['bid']); } $product['prototype'] = $prototypeModel->getByPid($product['id']); $product['img'] = $productimgModel->getByPid($product['id']); if (isset($product['category'])) { $product['category'] = $categoryModel->get($product['category'], 'name'); } if (isset($product['activity'])) { switch ($product['activity']) { case 'sale': $product['activity_description'] = $this->model('sale')->getByPid($product['id']); break; case 'seckill': $product['activity_description'] = $this->model('seckill')->getByPid($product['id']); break; case 'fullcut': $product['activity_description'] = $this->model('fullcutdetail')->getByPid($product['id']); break; default: break; } } } if (isset($product['origin'])) { $product['origin'] = $this->model('flag')->getOrigin($product['origin']); } } $resultObj->data = $result; return json_encode($resultObj); }
/** * 完成退款申请 */ function allow() { $id = intval($this->post->id); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'refund', roleModel::POWER_ALL)) { $refundModel = $this->model('refund'); if ($refundModel->updateHandle($id, refundModel::REFUND_HANDLE_FINISH)) { return new json(json::OK); } return new json(json::PARAMETER_ERROR); } return new json(json::NOT_LOGIN); }
/** * 移除主题下面的商品 */ function reproduct() { $this->response->addHeader('Content-Type', 'application/json'); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'theme', roleModel::POWER_UPDATE)) { $tid = filter::int($this->post->tid); $pid = filter::int($this->post->pid); $themeModel = $this->model('theme'); if ($themeModel->removeProduct($tid, $pid)) { return json_encode(array('code' => 1, 'result' => 'ok')); } return json_encode(array('code' => 0, 'result' => 'failed')); } else { return json_encode(array('code' => 2, 'result' => '权限不足')); } }
/** * 创建秒杀活动 */ function create() { $this->response->addHeader('Content-Type', 'application/json'); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'seckill', roleModel::POWER_INSERT)) { $sname = $this->post->sname; $pid = filter::int($this->post->pid); $starttime = $this->post->starttime; $endtime = $this->post->endtime; $price = filter::number($this->post->price); $orderby = filter::int($this->post->orderby); $logo = $this->post->logo; if (!empty($pid)) { $productModel = $this->model('product'); $product = $productModel->get($pid); if (empty($product) || !empty($product['activity'])) { switch ($product['activity']) { case 'sale': $result = '限时优惠'; break; case 'seckill': $result = '秒杀'; break; case 'fullcut': $result = '满减'; break; } return json_encode(array('code' => 4, 'result' => '商品已经参加了' . $result . ',请先移除原活动在来添加')); } $seckillModel = $this->model('seckill'); if ($seckillModel->create($sname, $pid, $starttime, $endtime, $price, $orderby, $logo)) { $productModel->setActivity($pid, 'seckill'); return json_encode(array('code' => 1, 'result' => '推送成功')); } else { return json_encode(array('code' => 2, 'result' => '推送失败')); } } return json_encode(array('code' => 0, 'result' => '参数错误')); } return json_encode(array('code' => 3, 'result' => '权限不足')); }
/** * 移除滚动图 */ function remove() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'carousel', roleModel::POWER_DELETE)) { $id = filter::int($this->post->id); $carouselModel = $this->model('carousel'); if ($carouselModel->remove($id)) { return new json(json::OK); } return new json(json::PARAMETER_ERROR, '删除失败'); } else { return new json(json::NO_POWER); } }
/** * 删除一个o2o账号 * @return string */ function remove() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'o2ouser', roleModel::POWER_DELETE)) { $id = $this->get->id; $o2oModel = $this->model('o2ouser'); $o2oModel->remove($id); $userModel = $this->model('user'); $userModel->clearOid($id); $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('o2o', 'admin')); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }
/** * 删除满减活动规则 */ function remove() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'fullcut', roleModel::POWER_DELETE)) { $id = filter::int($this->get->id); if (!empty($id)) { $fullcutModel = $this->model('fullcut'); $fullcutModel->remove($id); } $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('fullcut', 'admin')); } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }
/** * 把商品从限时折扣中移除 */ function remove() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'sale', roleModel::POWER_DELETE)) { $id = filter::int($this->get->id); if (!empty($id)) { $saleModel = $this->model('sale'); $sale = $saleModel->get($id); if (isset($sale['pid'])) { $saleModel->remove($id); $productModel = $this->model('product'); $productModel->setActivity($sale['pid']); } } } $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('sale', 'admin')); }
private function init($name) { $roleModel = $this->model('role'); $powername = isset($this->_module_power[$name]) ? $this->_module_power[$name] : $name; if (!(login::admin() && $roleModel->checkPower($this->session->role, $powername, roleModel::POWER_ALL))) { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); switch ($name) { case 'drawal': $filter = array('order' => array('time', 'desc'), 'parameter' => 'bankcard.bank,bankcard.name,bankcard.number,user.username,drawal.id,drawal.money,drawal.time,drawal.handle,drawal.handletime,drawal.note'); $drawal = $this->model('drawal')->fetch($filter); $this->view->assign('drawal', $drawal); break; case 'shipmodify': $id = $this->get->id; $shipModel = $this->model('ship'); $ship = $shipModel->get($id); $this->view->assign('ship', $ship); break; default: } }
/** * 提现请求列表 */ function lists() { $start = intval($this->get->start); $length = intval($this->get->length); $start = empty($start) ? 0 : $start; $length = empty($length) ? 10 : $length; $filter = array('start' => $start, 'length' => $length, 'order' => array('drawal.time', 'desc')); if (login::user()) { $filter['uid'] = $this->session->id; } else { if (!login::admin()) { return new json(json::NOT_LOGIN); } } $filter['parameter'] = 'drawal.money,drawal.handle,drawal.handletime,drawal.time,drawal.id,user.username,user.telephone,bankcard.number,bankcard.name,bankcard.bank'; $drawalModel = $this->model('drawal'); $result = $drawalModel->fetch($filter); return new json(json::OK, NULL, $result, true); }
/** * 品牌管理页面 */ function manager() { $roleModel = $this->model('role'); $start = empty(filter::int($this->get->start)) ? 0 : filter::int($this->get->start); $length = empty(filter::int($this->get->length)) ? 10 : filter::int($this->get->length); if (login::admin() && $roleModel->checkPower($this->session->role, 'brand', roleModel::POWER_SELECT)) { $this->view = new view(config('view'), 'admin/brand_manager.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $brandModel = $this->model('brand'); $result = $brandModel->fetchByProduct($start, $length); $this->view->assign('brand', $result); $this->response->setBody($this->view->display()); } else { $this->http->jump($this->http->url('index', '__404')); } }
/** * ajax调用用户数据列表 */ function userlistajax() { $roleModel = $this->model('role'); $resultObj = new \stdClass(); $resultObj->draw = $this->post->draw; $resultObj->recordsTotal = 0; $resultObj->recordsFiltered = 0; $resultObj->data = array(); if (login::admin() && $roleModel->checkPower($this->session->role, 'user', roleModel::POWER_SELECT)) { $userModel = $this->model('user'); $num = $userModel->select('count(*)'); $result = $userModel->searchable($_POST); foreach ($result as &$user) { $user['gravatar'] = file::realpathToUrl($user['gravatar']); } $resultObj->recordsTotal = (int) $num[0]['count(*)']; $resultObj->recordsFiltered = count($result); $resultObj->data = array_slice($result, $this->post->start, $this->post->length); } return json_encode($resultObj); }
/** * 删除评论 */ function del() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'comment', roleModel::POWER_DELETE)) { $id = filter::int($this->post->id); if (!empty($id)) { $commentModel = $this->model('comment'); if ($commentModel->remove($id)) { //删除磁盘图片 $comment_picModel = $this->model('comment_pic'); $comment_pic = $comment_picModel->getByCid($id, 'path'); foreach ($comment_pic as $pic) { filesystem::unlink($pic); } $this->model('log')->write($this->session->username, '删除了一条评论'); //删除图片记录 $comment_picModel->removeByCid($id); return json_encode(array('code' => 1, 'result' => 'ok')); } return json_encode(array('code' => 0, 'result' => 'failed')); } return json_encode(array('code' => 2, 'result' => '参数错误')); } return json_encode(array('code' => 3, 'result' => '没有权限')); }
/** * 移除设定中的国旗 * @return string */ function removeflag() { $this->response->addHeader('Content-Type', 'application/json'); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'system', roleModel::POWER_UPDATE)) { $id = filter::int($this->post->id); if (empty($id)) { return json_encode(array('code' => 3, 'result' => '参数错误')); } $flagModel = $this->model('flag'); if ($flagModel->remove($id)) { return json_encode(array('code' => 1, 'result' => 'ok')); } } return json_encode(array('code' => 2, 'result' => '权限不足')); }
/** * ajax请求所有订单数据 */ function ajaxorderlist() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'orderlist', roleModel::POWER_ALL)) { if (!empty($this->post->customActionType) && $this->post->customActionType == 'group_action') { $orderlistModel = $this->model('orderlist'); $id = $this->post->id; switch ($this->post->customActionName) { case 'remove': $orderlistModel->remove($id); break; case 'costums': foreach ($this->post->id as $id) { $this->costums($id); } break; } } $resultObj = new \stdClass(); $resultObj->draw = $this->post->draw; $orderModel = $this->model('orderlist'); $result = $orderModel->searchable($this->post); foreach ($result as &$order) { $order['refund'] = $this->model('refund')->getByOid($order['id']); $order['waybills'] = empty($order['waybills']) ? array() : unserialize($order['waybills']); } $resultObj->recordsFiltered = count($result); $resultObj->recordsTotal = $orderModel->count(); $resultObj->data = array_slice($result, $this->post->start, $this->post->length); return json_encode($resultObj); } return false; }
/** * 删除优惠券 * @return string */ function remove() { $this->response->addHeader('Content-Type', 'appication/json'); $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'coupon', roleModel::POWER_DELETE)) { $id = filter::int($this->post->id); if (!empty($id)) { $couponModel = $this->model('coupon'); if ($couponModel->remove($id)) { return json_encode(array('code' => 1, 'result' => '删除成功')); } return json_encode(array('code' => 3, 'result' => '删除失败')); } return json_encode(array('code' => 0, 'result' => '参数错误')); } return json_encode(array('code' => 2, 'result' => '没有权限')); }
function create() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'help', roleModel::POWER_INSERT)) { if ($this->post->submit === NULL) { $this->view = new view(config('view'), 'admin/help_create.html'); $this->view->assign('role', $roleModel->get($this->session->role)); $systemModel = $this->model('system'); $system = $systemModel->fetch('system'); $system = $systemModel->toArray($system, 'system'); $this->view->assign('system', $system); $this->response->setBody($this->view->display()); } else { $helpModel = $this->model('help'); if ($helpModel->create($this->post->title, $this->post->content)) { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('help', 'admin')); } } } else { $this->response->setCode(302); $this->response->addHeader('Location', $this->http->url('admin', 'index')); } }