init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace Admin\Controller;
|
||||
|
||||
use Think\Controller;
|
||||
|
||||
//[1.7.90]
|
||||
class UsergroupController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$arr = array(
|
||||
'addgroup' => '/index.php/Admin/Usergroup/addgroup', //修改等级
|
||||
'change' => '/index.php/Admin/Usergroup/change', //修改等级状态
|
||||
'delgroup' => '/index.php/Admin/Usergroup/delgroup', //删除等级
|
||||
);
|
||||
$authArr = checkFunction($arr);
|
||||
$this->assign('authArr', $authArr);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function indexshow()
|
||||
{
|
||||
$user = session('admin_userinfo');
|
||||
$info = M('retail_group')->where(array('pid' => $user['pid']))->page((int)$_POST['page'], (int)$_POST['limit'])->order('id desc')->select();
|
||||
$count = M('retail_group')->where(array('pid' => $user['pid']))->count();
|
||||
if ($info) {
|
||||
foreach ($info as $key => &$val) {
|
||||
$val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
|
||||
}
|
||||
}
|
||||
$res['code'] = 0;
|
||||
$res['msg'] = '';
|
||||
$res['data'] = $info;
|
||||
$res['count'] = $count;
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代理商等级列表供选择
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public function getAgentGroup()
|
||||
{
|
||||
$user = session('admin_userinfo');
|
||||
$info = M('retail_group')->where(array('pid' => $user['pid']))->field('id,name')->order('id desc')->select();
|
||||
$this->ajaxReturn([
|
||||
'status' => 1,
|
||||
'message' => empty($info) ? '暂无数据' : '获取成功',
|
||||
'data' => $info,
|
||||
]);
|
||||
}
|
||||
|
||||
//添加等级
|
||||
public function addgroup()
|
||||
{
|
||||
$data = I('get.id');
|
||||
if ($data) {
|
||||
$group = M('retail_group')->where(array('id' => $data))->find();
|
||||
$this->assign('group', $group);
|
||||
}
|
||||
$this->display();
|
||||
}
|
||||
|
||||
//修改状态
|
||||
public function change()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = I('post.');
|
||||
$user = session('admin_userinfo');
|
||||
if ($data['status'] == 2) {
|
||||
$agentdiscountid = M('retail_agent')->where(array('partnerid' => $user['pid'], 'status' => 1, 'discountid' => $data['id']))->find();
|
||||
if ($agentdiscountid) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '已有代理商占用此等级,暂无法操作';
|
||||
$this->ajaxReturn($res);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$save = M('retail_group')->where(array('id' => $data['id']))->save(array('status' => $data['status']));
|
||||
if ($save) {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '操作成功';
|
||||
} else {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '操作失败';
|
||||
}
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
}
|
||||
|
||||
public function addagentgroup()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = I('post.');
|
||||
if (!$data['id']) {
|
||||
$user = session('admin_userinfo');
|
||||
$data['pid'] = $user['pid'];
|
||||
$data['addtime'] = time();
|
||||
$info = M('retail_meal')->where(array('pid' => $user['pid']))->find();
|
||||
if (!$info) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '请先添加套餐';
|
||||
$this->ajaxReturn($res);
|
||||
exit;
|
||||
}
|
||||
$add = M('retail_group')->add($data);
|
||||
} else {
|
||||
$add = M('retail_group')->where(array('id' => $data['id']))->save($data);
|
||||
}
|
||||
if ($add) {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '操作成功';
|
||||
} else {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '操作失败';
|
||||
}
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delgroup()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$id = I('post.id');
|
||||
$user = session('admin_userinfo');
|
||||
$agentdiscountid = M('retail_agent')->where(array('partnerid' => $user['pid'], 'status' => 1, 'discountid' => $id))->find();
|
||||
if ($agentdiscountid) {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '已有代理商占用此等级,无法删除';
|
||||
} else {
|
||||
$del = M('retail_group')->where(array('id' => $id))->delete();
|
||||
if ($del) {
|
||||
$res['status'] = 1;
|
||||
$res['msg'] = '操作成功';
|
||||
} else {
|
||||
$res['status'] = 0;
|
||||
$res['msg'] = '操作失败';
|
||||
}
|
||||
}
|
||||
$this->ajaxReturn($res);
|
||||
}
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户