123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947 |
- <?php
- namespace Admin\Controller;
- class ConfigController extends AdminController
- {
- protected function _initialize()
- {
- parent::_initialize();
- $allow_action=array("index","upload","edit","image","coin","coinEdit","coinStatus","textStatus","coinImage","text","textEdit","qita","qitaEdit","daohang","daohangEdit","daohangStatus","dhfooter","dhfooterEdit","dhfooterStatus","dhadmin","dhadminEdit","dhadminStatus","ctmarket","ctmarketEdit","marketo","marketoEdit","marketoEdit2","marketoEdit3","marketoStatus","ctmarketoStatus","mining","miningEdit");
- if(!in_array(ACTION_NAME,$allow_action)){
- $this->error("页面不存在!".ACTION_NAME);
- }
- }
- //系统设置首页
- public function index(){
- $this->data = M('Config')->where(array('id' => 1))->find();
- $this->display();
- }
- //编加网站基本配置
- public function edit(){
- $data = I('post.');
- if (M('Config')->where(array('id' => 1))->save($data)) {
- $this->success('修改成功!');
- } else {
- $this->error('修改失败');
- }
- }
- public function image(){
- $upload = new \Think\Upload();
- $upload->maxSize = 3145728;
- $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
- $upload->rootPath = './Upload/public/';
- $upload->autoSub = false;
- $info = $upload->upload();
- foreach ($info as $k => $v) {
- $path = $v['savepath'] . $v['savename'];
- echo $path;
- exit();
- }
- }
- public function upload()
- {
- $upload = new \Think\Upload();
- $upload->maxSize = 314572800000;
- $upload->exts = array('apk');
- $upload->rootPath = './Upload/public/';
- $upload->autoSub = false;
- $info = $upload->upload();
- foreach ($info as $k => $v) {
- $path = $v['savepath'] . $v['savename'];
- echo $path;
- exit();
- }
- }
-
- public function coin($name = NULL, $field = NULL, $status = NULL)
- {
- $where = array();
- if ($field && $name) {
- if ($field == 'username') {
- $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
- } else {
- $where[$field] = $name;
- }
- }
- if ($status) {
- $where['status'] = $status - 1;
- }
- $count = M('Coin')->where($where)->count();
- $Page = new \Think\Page($count, 100);
- $show = $Page->show();
- $list = M('Coin')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
-
-
- ////增加币名称OK
- public function coinEdit($id = NULL)
- {
- if (empty($_POST)) {
- if (empty($id)) {
- $this->data = array();
- } else {
- $this->data = M('Coin')->where(array('id' => trim($_GET['id'])))->find();
- }
- $this->display();
- } else {
-
- if ($_POST['id']) {
-
- $_POST['addtime'] = date("Y-m-d H:i:s",time());
- $rs = M('Coin')->save($_POST);
-
- } else {
-
- if (!check($_POST['name'], 'n')) {
- $this->error('币种简称只能是小写字母!');
- }
- $_POST['name'] = strtolower($_POST['name']);
- if (check($_POST['name'], 'username')) {
- $this->error('币种名称格式不正确!');
- }
- if (M('Coin')->where(array('name' => $_POST['name']))->find()) {
- $this->error('币种存在!');
- }
-
- $_POST['addtime'] = date("Y-m-d H:i:s",time());
- $rea = M()->execute('ALTER TABLE `tw_user_coin` ADD `' . $_POST['name'] . '` DECIMAL(20,8) UNSIGNED NOT NULL DEFAULT 0.00000000');
- $reb = M()->execute('ALTER TABLE `tw_user_coin` ADD `' . $_POST['name'] . 'd` DECIMAL(20,8) UNSIGNED NOT NULL DEFAULT 0.00000000');
- $rec = M()->execute('ALTER TABLE `tw_user_coin` ADD `' . $_POST['name'] . 'b` VARCHAR(200) NOT NULL DEFAULT 0');
- $rs = M('Coin')->add($_POST);
- }
- if ($rs) {
- $this->success('操作成功!',U('Config/coin'));
- } else {
- $this->error('数据未修改!');
- }
- }
- }
- public function coinStatus()
- {
- if (IS_POST) {
- $id = array();
- $id = implode(',', $_POST['id']);
- } else {
- $id = $_GET['id'];
- }
- if (empty($id)) {
- $this->error('请选择要操作的数据!');
- }
- $where['id'] = array('in', $id);
- $method = $_GET['type'];
- // $this->error($method);
- switch (strtolower($method)) {
- case 'forbid':
- $data = array('status' => 0);
- break;
- case 'resume':
- $data = array('status' => 1);
- break;
- case 'delt':
- $rs = M('Coin')->where($where)->select();
- foreach ($rs as $k => $v) {
- $rs[] = M()->execute('ALTER TABLE `tw_user_coin` DROP COLUMN ' . $v['name']);
- $rs[] = M()->execute('ALTER TABLE `tw_user_coin` DROP COLUMN ' . $v['name'] . 'd');
- $rs[] = M()->execute('ALTER TABLE `tw_user_coin` DROP COLUMN ' . $v['name'] . 'b');
- }
- if (M('Coin')->where($where)->delete()) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- break;
- default:
- $this->error('参数非法');
- }
- if (M('Coin')->where($where)->save($data)) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- }
- public function coinImage()
- {
- $upload = new \Think\Upload();
- $upload->maxSize = 3145728;
- $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
- $upload->rootPath = './Upload/coin/';
- $upload->autoSub = false;
-
- $info = $upload->upload();
- foreach ($info as $k => $v) {
- $path = $v['savepath'] . $v['savename'];
- echo $path;
- exit();
- }
- }
- //系统参数设置
- public function qita(){
- $this->data = M('Config')->where(array('id' => 1))->find();
- $this->display();
- }
- //系统参数编辑
- public function qitaEdit(){
- $data = I('post.');
- if (M('Config')->where(array('id' => 1))->save($data)) {
- $this->success('修改成功!');
- } else {
- $this->error('修改失败');
- }
- }
-
-
- // 前端导航配置
- public function daohang($name = NULL, $field = NULL, $status = NULL, $lang = NULL)
- {
- $where = array();
- if ($field && $name) {
- if ($field == 'username') {
- $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
- } else if ($field == 'title') {
- $where['title'] = array('like', '%' . $name . '%');
- } else {
- $where[$field] = $name;
- }
- }
- if ($status) {
- $where['status'] = $status - 1;
- }
- if ($lang) {
- $where['lang'] = $lang;
- }
-
- $count = M('Daohang')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('Daohang')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
- public function daohangEdit($id = NULL)
- {
- //dump($_POST);
- if (empty($_POST)) {
- if ($id) {
- $this->data = M('Daohang')->where(array('id' => trim($id)))->find();
- } else {
- $this->data = null;
- }
- $this->display();
- } else {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- if ($_POST['id']) {
- $rs = M('Daohang')->save($_POST);
- } else {
- $_POST['addtime'] = time();
- $rs = M('Daohang')->add($_POST);
- }
- if ($rs) {
- $closeUrl = S('closeUrl');
- if($_POST['get_login']) {
- $closeUrl[] = $_POST['url'];
- } else {
- if($key = array_search($_POST['url'], $closeUrl)) {
- unset($closeUrl[$key]);
- }
- }
- $closeUrl = array_unique($closeUrl);
- sort($closeUrl);
- S('closeUrl', $closeUrl);
- $this->success('编辑成功!',U('Config/daohang'));
- } else {
- $this->error('编辑失败!');
- }
- }
- }
- public function daohangStatus($id = NULL, $type = NULL, $mobile = 'Daohang')
- {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if (empty($type)) {
- $this->error('参数错误1!');
- }
- if (strpos(',', $id)) {
- $id = implode(',', $id);
- }
- $where['id'] = array('in', $id);
- switch (strtolower($type)) {
- case 'forbid':
- $data = array('status' => 0);
- break;
- case 'resume':
- $data = array('status' => 1);
- break;
- case 'repeal':
- $data = array('status' => 2, 'endtime' => time());
- break;
- case 'del':
- $data = array('status' => -1);
- break;
- case 'delete':
- if (M($mobile)->where($where)->delete()) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- break;
- default:
- $this->error('操作失败!');
- }
- if (M($mobile)->where($where)->save($data)) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- }
-
- // 页脚导航配置
- public function dhfooter($name = NULL, $field = NULL, $status = NULL)
- {
- $where = array();
- if ($field && $name) {
- if ($field == 'username') {
- $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
- } else if ($field == 'title') {
- $where['title'] = array('like', '%' . $name . '%');
- } else {
- $where[$field] = $name;
- }
- }
-
- if ($status) {
- $where['status'] = $status - 1;
- }
- $count = M('footer')->where($where)->count();
- $Page = new \Think\Page($count, 15);
- $show = $Page->show();
- $list = M('footer')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
-
- public function dhfooterEdit($id = NULL)
- {
- if (empty($_POST)) {
- if ($id) {
- $this->data = M('footer')->where(array('id' => trim($id)))->find();
- } else {
- $this->data = null;
- }
- $this->display();
- } else {
- if ($_POST['id']) {
- $rs = M('footer')->save($_POST);
- } else {
- $_POST['addtime'] = time();
- $rs = M('footer')->add($_POST);
- }
- if ($rs) {
- $closeUrl = S('closeUrl');
- if($_POST['get_login']) {
- $closeUrl[] = $_POST['url'];
- } else {
- if($key = array_search($_POST['url'], $closeUrl)) {
- unset($closeUrl[$key]);
- }
- }
- $closeUrl = array_unique($closeUrl);
- sort($closeUrl);
- S('closeUrl', $closeUrl);
- $this->success('编辑成功!',U('Config/dhfooter'));
- } else {
- $this->error('编辑失败!');
- }
- }
- }
- public function dhfooterStatus($id = NULL, $type = NULL, $mobile = 'footer')
- {
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if (empty($type)) {
- $this->error('参数错误1!');
- }
- if (strpos(',', $id)) {
- $id = implode(',', $id);
- }
- $where['id'] = array('in', $id);
- switch (strtolower($type)) {
- case 'forbid':
- $data = array('status' => 0);
- break;
- case 'resume':
- $data = array('status' => 1);
- break;
- case 'repeal':
- $data = array('status' => 2, 'endtime' => time());
- break;
- case 'del':
- $data = array('status' => -1);
- break;
- case 'delete':
- if (M($mobile)->where($where)->delete()) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- break;
- default:
- $this->error('操作失败!');
- }
- if (M($mobile)->where($where)->save($data)) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- }
-
- // 后端导航配置
- public function dhadmin($name = NULL, $field = NULL, $status = NULL, $hide = NULL)
- {
- $where = array();
- if ($field && $name) {
- if ($field == 'username') {
- $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
- } else if ($field == 'title') {
- $where['title'] = array('like', '%' . $name . '%');
- } else {
- $where[$field] = $name;
- }
- }
- if ($status) {
- $where['status'] = $status - 1;
- }
- if ($hide) {
- $where['hide'] = $hide;
- }
-
- $where_1 = $where;
- $where_1['pid'] = 0;
- $where_2 = $where;
-
- $list = M('menu')->where($where_1)->order('sort asc')->select();
- foreach ($list as $k => $v) {
- $where_2['pid'] = $v['id'];
- $list[$k]['voo'] = M('menu')->where($where_2)->order('sort asc')->select();
- }
-
- $this->assign('list', $list);
- $this->display();
- }
-
- public function dhadminEdit($id = NULL)
- {
- if (empty($_POST)) {
- $liste = '';
-
- if ($id) {
- $this->data = M('menu')->where(array('id' => trim($id)))->find();
- } else {
- $this->data = null;
- }
-
- $liste = M('menu')->where('pid = 0')->order('sort asc')->select();
- $this->assign('liste', $liste);
- $this->display();
- } else {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
-
- if (empty($_POST['title'])) {
- $this->error('标题错误');
- }
- if ($_POST['id']) {
- $rs = M('menu')->save($_POST);
- } else {
- $_POST['addtime'] = time();
- $rs = M('menu')->add($_POST);
- }
- if ($rs) {
- $this->success('编辑成功!',U('Config/dhadmin'));
- } else {
- $this->error('编辑失败!');
- }
- }
- }
- public function dhadminStatus($id = NULL, $type = NULL, $mobile = 'menu')
- {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if (empty($type)) {
- $this->error('参数错误1!');
- }
- if (strpos(',', $id)) {
- $id = implode(',', $id);
- }
- $where['id'] = array('in', $id);
- switch (strtolower($type)) {
- case 'forbid':
- $data = array('hide' => 1);
- break;
- case 'resume':
- $data = array('hide' => 0);
- break;
- case 'repeal':
- $data = array('hide' => 2);
- break;
-
- case 'delete':
- $data = array('status' => -1);
- break;
- case 'del':
- if (M($mobile)->where($where)->delete()) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- break;
- default:
- $this->error('操作失败!');
- }
- if (M($mobile)->where($where)->save($data)) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- }
-
- ////市场配置OK
- public function ctmarket(){
- $count = M('ctmarket')->count();
- $Page = new \Think\Page($count, 100);
- $show = $Page->show();
- $list = M('ctmarket')->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
- /////OK
- public function marketo($field = NULL, $name = NULL)
- {
- $where = array();
- if ($field && $name) {
- if ($field == 'username') {
- $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
- } else {
- $where[$field] = $name;
- }
- }
-
- $count = M('Market')->where($where)->count();
- $Page = new \Think\Page($count, 100);
- $show = $Page->show();
- $list = M('Market')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
- $this->assign('list', $list);
- $this->assign('page', $show);
- $this->display();
- }
-
-
- ///链上币种市场配置修改
- public function ctmarketEdit($id = NULL){
- if(empty($_POST)){
- $id = $_GET['id'];
- $this->data = M('ctmarket')->where(array('id' => $id))->find();
- $this->display();
- }else{
- $coinname = $_POST['coinname'];
- $status = $_POST['status'];
- $state = $_POST['state'];
- $sort = $_POST['sort'];
- $id = $_POST['id'];
- $data['coinname'] = strtolower($coinname);
- $data['name'] = strtolower($coinname)."_usdt";
- $data['symbol'] = strtolower($coinname)."usdt";
- $data['title'] = strtoupper($coinname)."/USDT";
- $data['status'] = $status;
- $data['state'] = $state;
- $data['sort'] = $sort;
- $data['addtime'] = date("Y-m-d H:i:s",time());
- //编辑
- if($id > 0){
- $re = M("ctmarket")->where(array('id'=>$id))->save($data);
- if($re){
- $this->success('操作成功!',U('Config/ctmarket'));
- }else{
- $this->error('操作失败!');
- }
-
- }else{//新增
- $re =M("ctmarket")->add($data);
- if($re){
- $this->success('操作成功!',U('Config/ctmarket'));
- }else{
- $this->error('操作失败!');
- }
- }
-
- }
-
- }
-
- // 平台币市场配置修改
- public function marketoEdit($id = NULL)
- {
- $getCoreConfig = getCoreConfig();
- if(!$getCoreConfig){
- $this->error('核心配置有误');
- }
- if (empty($_POST)) {
- if (empty($id)) {
- $this->data = array();
- } else {
- $this->data = M('Market')->where(array('id' => $id))->find();
- }
- $time_arr = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23');
- $time_minute = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59');
-
- $this->assign('time_arr', $time_arr);
- $this->assign('time_minute', $time_minute);
- $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
- $this->display();
- } else {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- $round = array(0, 1, 2, 3, 4, 5, 6);
- if (!in_array($_POST['round'], $round)) {
- $this->error('小数位数格式错误!');
- }
-
- if(!$_POST['hou_price']){
- $_POST['hou_price'] = '0.00000000';
- }
- if ($_POST['id']) {
- $rs = M('Market')->save($_POST);
- } else {
- $buyname = $_POST['buyname'];
- $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
- unset($_POST['buyname']);
- unset($_POST['sellname']);
- if (M('Market')->where(array('name' => $_POST['name']))->find()) {
- $this->error('市场存在!');
- }
-
- $jiaoyiqu = strtolower($getCoreConfig['indexcat'][$_POST['jiaoyiqu']]);
- if ($buyname != $jiaoyiqu) {
- $this->error('所属交易区和买方币种不一致!'.$buyname);
- }
- $rs = M('Market')->add($_POST);
- }
- if ($rs) {
- $this->success('操作成功!',U('Config/marketo'));
- } else {
- $this->error('操作失败!');
- }
- }
- }
-
- // 市场配置2修改
- public function marketoEdit2($id = NULL)
- {
- $getCoreConfig = getCoreConfig();
- if(!$getCoreConfig){
- $this->error('核心配置有误');
- }
- if (empty($_POST)) {
- if (empty($id)) {
- $this->data = array();
- } else {
- $this->data = M('Market')->where(array('id' => $id))->find();
- }
-
- $time_arr = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23');
- $time_minute = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59');
- $this->assign('time_arr', $time_arr);
- $this->assign('time_minute', $time_minute);
- $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
- $this->display();
- } else {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- $round = array(0, 1, 2, 3, 4, 5, 6);
- if (!in_array($_POST['round'], $round)) {
- $this->error('小数位数格式错误!');
- }
- if ($_POST['id']) {
- $rs = M('Market')->save($_POST);
- } else {
- $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
- unset($_POST['buyname']);
- unset($_POST['sellname']);
- if (M('Market')->where(array('name' => $_POST['name']))->find()) {
- $this->error('市场存在!');
- }
- $rs = M('Market')->add($_POST);
- }
- if ($rs) {
- $this->success('操作成功!',U('Config/marketo'));
- } else {
- $this->error('操作失败!');
- }
- }
- }
-
- // 市场配置3修改
- public function marketoEdit3($id = NULL)
- {
- $getCoreConfig = getCoreConfig();
- if(!$getCoreConfig){
- $this->error('核心配置有误');
- }
- if (empty($_POST)) {
- if (empty($id)) {
- $this->data = array();
- } else {
- $this->data = M('Market')->where(array('id' => $id))->find();
- }
-
- $time_arr = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23');
- $time_minute = array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59');
- $this->assign('time_arr', $time_arr);
- $this->assign('time_minute', $time_minute);
- $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
-
- $round = number_format("0",$this->data['round']-1).'1';
- $this->assign('round', $round);
-
- $this->display();
-
- } else {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- $round = array(0, 1, 2, 3, 4, 5, 6);
- if (!in_array($_POST['round'], $round)) {
- $this->error('小数位数格式错误!');
- }
- if ($_POST['id']) {
- $rs = M('Market')->save($_POST);
- } else {
- $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
- unset($_POST['buyname']);
- unset($_POST['sellname']);
- if (M('Market')->where(array('name' => $_POST['name']))->find()) {
- $this->error('市场存在!');
- }
- $rs = M('Market')->add($_POST);
- }
- if ($rs) {
- $this->success('操作成功!',U('Config/marketo'));
- } else {
- $this->error('操作失败!');
- }
- }
- }
-
- public function marketoStatus($id = NULL, $type = NULL, $mobile = 'Market')
- {
- if (APP_DEMO) {
- $this->error('测试站暂时不能修改!');
- }
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if (empty($type)) {
- $this->error('参数错误1!');
- }
- if (strpos(',', $id)) {
- $id = implode(',', $id);
- }
- $where['id'] = array('in', $id);
- switch (strtolower($type)) {
- case 'forbid':
- $data = array('status' => 0);
- break;
- case 'resume':
- $data = array('status' => 1);
- break;
- case 'repeal':
- $data = array('status' => 2, 'endtime' => time());
- break;
- case 'delete':
- $data = array('status' => -1);
- break;
- case 'del':
- if (M($mobile)->where($where)->delete()) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- break;
- default:
- $this->error('操作失败!');
- }
- if (M($mobile)->where($where)->save($data)) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- }
-
- ////修改市场配置状态
- public function ctmarketoStatus($id = NULL, $type = NULL, $mobile = 'ctmarket'){
- if (empty($id)) {
- $this->error('参数错误!');
- }
- if (empty($type)) {
- $this->error('参数错误1!');
- }
- if (strpos(',', $id)) {
- $id = implode(',', $id);
- }
- $where['id'] = array('in', $id);
- switch (strtolower($type)) {
- case 'forbid':
- $data = array('status' => 2);
- break;
- case 'resume':
- $data = array('status' => 1);
- break;
- case 'del':
- if (M($mobile)->where($where)->delete()) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- break;
- default:
- $this->error('操作失败!');
- }
- if (M($mobile)->where($where)->save($data)) {
- $this->success('操作成功!');
- } else {
- $this->error('操作失败!');
- }
- }
-
- }
- ?>
|