ConfigController.class.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  1. <?php
  2. namespace Admin\Controller;
  3. class ConfigController extends AdminController
  4. {
  5. protected function _initialize()
  6. {
  7. parent::_initialize();
  8. $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");
  9. if(!in_array(ACTION_NAME,$allow_action)){
  10. $this->error("页面不存在!".ACTION_NAME);
  11. }
  12. }
  13. //系统设置首页
  14. public function index(){
  15. $this->data = M('Config')->where(array('id' => 1))->find();
  16. $this->display();
  17. }
  18. //编加网站基本配置
  19. public function edit(){
  20. $data = I('post.');
  21. if (M('Config')->where(array('id' => 1))->save($data)) {
  22. $this->success('修改成功!');
  23. } else {
  24. $this->error('修改失败');
  25. }
  26. }
  27. public function image(){
  28. $upload = new \Think\Upload();
  29. $upload->maxSize = 3145728;
  30. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
  31. $upload->rootPath = './Upload/public/';
  32. $upload->autoSub = false;
  33. $info = $upload->upload();
  34. foreach ($info as $k => $v) {
  35. $path = $v['savepath'] . $v['savename'];
  36. echo $path;
  37. exit();
  38. }
  39. }
  40. public function upload()
  41. {
  42. $upload = new \Think\Upload();
  43. $upload->maxSize = 314572800000;
  44. $upload->exts = array('apk');
  45. $upload->rootPath = './Upload/public/';
  46. $upload->autoSub = false;
  47. $info = $upload->upload();
  48. foreach ($info as $k => $v) {
  49. $path = $v['savepath'] . $v['savename'];
  50. echo $path;
  51. exit();
  52. }
  53. }
  54. public function coin($name = NULL, $field = NULL, $status = NULL)
  55. {
  56. $where = array();
  57. if ($field && $name) {
  58. if ($field == 'username') {
  59. $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
  60. } else {
  61. $where[$field] = $name;
  62. }
  63. }
  64. if ($status) {
  65. $where['status'] = $status - 1;
  66. }
  67. $count = M('Coin')->where($where)->count();
  68. $Page = new \Think\Page($count, 100);
  69. $show = $Page->show();
  70. $list = M('Coin')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  71. $this->assign('list', $list);
  72. $this->assign('page', $show);
  73. $this->display();
  74. }
  75. ////增加币名称OK
  76. public function coinEdit($id = NULL)
  77. {
  78. if (empty($_POST)) {
  79. if (empty($id)) {
  80. $this->data = array();
  81. } else {
  82. $this->data = M('Coin')->where(array('id' => trim($_GET['id'])))->find();
  83. }
  84. $this->display();
  85. } else {
  86. if ($_POST['id']) {
  87. $_POST['addtime'] = date("Y-m-d H:i:s",time());
  88. $rs = M('Coin')->save($_POST);
  89. } else {
  90. if (!check($_POST['name'], 'n')) {
  91. $this->error('币种简称只能是小写字母!');
  92. }
  93. $_POST['name'] = strtolower($_POST['name']);
  94. if (check($_POST['name'], 'username')) {
  95. $this->error('币种名称格式不正确!');
  96. }
  97. if (M('Coin')->where(array('name' => $_POST['name']))->find()) {
  98. $this->error('币种存在!');
  99. }
  100. $_POST['addtime'] = date("Y-m-d H:i:s",time());
  101. $rea = M()->execute('ALTER TABLE `tw_user_coin` ADD `' . $_POST['name'] . '` DECIMAL(20,8) UNSIGNED NOT NULL DEFAULT 0.00000000');
  102. $reb = M()->execute('ALTER TABLE `tw_user_coin` ADD `' . $_POST['name'] . 'd` DECIMAL(20,8) UNSIGNED NOT NULL DEFAULT 0.00000000');
  103. $rec = M()->execute('ALTER TABLE `tw_user_coin` ADD `' . $_POST['name'] . 'b` VARCHAR(200) NOT NULL DEFAULT 0');
  104. $rs = M('Coin')->add($_POST);
  105. }
  106. if ($rs) {
  107. $this->success('操作成功!',U('Config/coin'));
  108. } else {
  109. $this->error('数据未修改!');
  110. }
  111. }
  112. }
  113. public function coinStatus()
  114. {
  115. if (IS_POST) {
  116. $id = array();
  117. $id = implode(',', $_POST['id']);
  118. } else {
  119. $id = $_GET['id'];
  120. }
  121. if (empty($id)) {
  122. $this->error('请选择要操作的数据!');
  123. }
  124. $where['id'] = array('in', $id);
  125. $method = $_GET['type'];
  126. // $this->error($method);
  127. switch (strtolower($method)) {
  128. case 'forbid':
  129. $data = array('status' => 0);
  130. break;
  131. case 'resume':
  132. $data = array('status' => 1);
  133. break;
  134. case 'delt':
  135. $rs = M('Coin')->where($where)->select();
  136. foreach ($rs as $k => $v) {
  137. $rs[] = M()->execute('ALTER TABLE `tw_user_coin` DROP COLUMN ' . $v['name']);
  138. $rs[] = M()->execute('ALTER TABLE `tw_user_coin` DROP COLUMN ' . $v['name'] . 'd');
  139. $rs[] = M()->execute('ALTER TABLE `tw_user_coin` DROP COLUMN ' . $v['name'] . 'b');
  140. }
  141. if (M('Coin')->where($where)->delete()) {
  142. $this->success('操作成功!');
  143. } else {
  144. $this->error('操作失败!');
  145. }
  146. break;
  147. default:
  148. $this->error('参数非法');
  149. }
  150. if (M('Coin')->where($where)->save($data)) {
  151. $this->success('操作成功!');
  152. } else {
  153. $this->error('操作失败!');
  154. }
  155. }
  156. public function coinImage()
  157. {
  158. $upload = new \Think\Upload();
  159. $upload->maxSize = 3145728;
  160. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
  161. $upload->rootPath = './Upload/coin/';
  162. $upload->autoSub = false;
  163. $info = $upload->upload();
  164. foreach ($info as $k => $v) {
  165. $path = $v['savepath'] . $v['savename'];
  166. echo $path;
  167. exit();
  168. }
  169. }
  170. //系统参数设置
  171. public function qita(){
  172. $this->data = M('Config')->where(array('id' => 1))->find();
  173. $this->display();
  174. }
  175. //系统参数编辑
  176. public function qitaEdit(){
  177. $data = I('post.');
  178. if (M('Config')->where(array('id' => 1))->save($data)) {
  179. $this->success('修改成功!');
  180. } else {
  181. $this->error('修改失败');
  182. }
  183. }
  184. // 前端导航配置
  185. public function daohang($name = NULL, $field = NULL, $status = NULL, $lang = NULL)
  186. {
  187. $where = array();
  188. if ($field && $name) {
  189. if ($field == 'username') {
  190. $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
  191. } else if ($field == 'title') {
  192. $where['title'] = array('like', '%' . $name . '%');
  193. } else {
  194. $where[$field] = $name;
  195. }
  196. }
  197. if ($status) {
  198. $where['status'] = $status - 1;
  199. }
  200. if ($lang) {
  201. $where['lang'] = $lang;
  202. }
  203. $count = M('Daohang')->where($where)->count();
  204. $Page = new \Think\Page($count, 15);
  205. $show = $Page->show();
  206. $list = M('Daohang')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  207. $this->assign('list', $list);
  208. $this->assign('page', $show);
  209. $this->display();
  210. }
  211. public function daohangEdit($id = NULL)
  212. {
  213. //dump($_POST);
  214. if (empty($_POST)) {
  215. if ($id) {
  216. $this->data = M('Daohang')->where(array('id' => trim($id)))->find();
  217. } else {
  218. $this->data = null;
  219. }
  220. $this->display();
  221. } else {
  222. if (APP_DEMO) {
  223. $this->error('测试站暂时不能修改!');
  224. }
  225. if ($_POST['id']) {
  226. $rs = M('Daohang')->save($_POST);
  227. } else {
  228. $_POST['addtime'] = time();
  229. $rs = M('Daohang')->add($_POST);
  230. }
  231. if ($rs) {
  232. $closeUrl = S('closeUrl');
  233. if($_POST['get_login']) {
  234. $closeUrl[] = $_POST['url'];
  235. } else {
  236. if($key = array_search($_POST['url'], $closeUrl)) {
  237. unset($closeUrl[$key]);
  238. }
  239. }
  240. $closeUrl = array_unique($closeUrl);
  241. sort($closeUrl);
  242. S('closeUrl', $closeUrl);
  243. $this->success('编辑成功!',U('Config/daohang'));
  244. } else {
  245. $this->error('编辑失败!');
  246. }
  247. }
  248. }
  249. public function daohangStatus($id = NULL, $type = NULL, $mobile = 'Daohang')
  250. {
  251. if (APP_DEMO) {
  252. $this->error('测试站暂时不能修改!');
  253. }
  254. if (empty($id)) {
  255. $this->error('参数错误!');
  256. }
  257. if (empty($type)) {
  258. $this->error('参数错误1!');
  259. }
  260. if (strpos(',', $id)) {
  261. $id = implode(',', $id);
  262. }
  263. $where['id'] = array('in', $id);
  264. switch (strtolower($type)) {
  265. case 'forbid':
  266. $data = array('status' => 0);
  267. break;
  268. case 'resume':
  269. $data = array('status' => 1);
  270. break;
  271. case 'repeal':
  272. $data = array('status' => 2, 'endtime' => time());
  273. break;
  274. case 'del':
  275. $data = array('status' => -1);
  276. break;
  277. case 'delete':
  278. if (M($mobile)->where($where)->delete()) {
  279. $this->success('操作成功!');
  280. } else {
  281. $this->error('操作失败!');
  282. }
  283. break;
  284. default:
  285. $this->error('操作失败!');
  286. }
  287. if (M($mobile)->where($where)->save($data)) {
  288. $this->success('操作成功!');
  289. } else {
  290. $this->error('操作失败!');
  291. }
  292. }
  293. // 页脚导航配置
  294. public function dhfooter($name = NULL, $field = NULL, $status = NULL)
  295. {
  296. $where = array();
  297. if ($field && $name) {
  298. if ($field == 'username') {
  299. $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
  300. } else if ($field == 'title') {
  301. $where['title'] = array('like', '%' . $name . '%');
  302. } else {
  303. $where[$field] = $name;
  304. }
  305. }
  306. if ($status) {
  307. $where['status'] = $status - 1;
  308. }
  309. $count = M('footer')->where($where)->count();
  310. $Page = new \Think\Page($count, 15);
  311. $show = $Page->show();
  312. $list = M('footer')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  313. $this->assign('list', $list);
  314. $this->assign('page', $show);
  315. $this->display();
  316. }
  317. public function dhfooterEdit($id = NULL)
  318. {
  319. if (empty($_POST)) {
  320. if ($id) {
  321. $this->data = M('footer')->where(array('id' => trim($id)))->find();
  322. } else {
  323. $this->data = null;
  324. }
  325. $this->display();
  326. } else {
  327. if ($_POST['id']) {
  328. $rs = M('footer')->save($_POST);
  329. } else {
  330. $_POST['addtime'] = time();
  331. $rs = M('footer')->add($_POST);
  332. }
  333. if ($rs) {
  334. $closeUrl = S('closeUrl');
  335. if($_POST['get_login']) {
  336. $closeUrl[] = $_POST['url'];
  337. } else {
  338. if($key = array_search($_POST['url'], $closeUrl)) {
  339. unset($closeUrl[$key]);
  340. }
  341. }
  342. $closeUrl = array_unique($closeUrl);
  343. sort($closeUrl);
  344. S('closeUrl', $closeUrl);
  345. $this->success('编辑成功!',U('Config/dhfooter'));
  346. } else {
  347. $this->error('编辑失败!');
  348. }
  349. }
  350. }
  351. public function dhfooterStatus($id = NULL, $type = NULL, $mobile = 'footer')
  352. {
  353. if (empty($id)) {
  354. $this->error('参数错误!');
  355. }
  356. if (empty($type)) {
  357. $this->error('参数错误1!');
  358. }
  359. if (strpos(',', $id)) {
  360. $id = implode(',', $id);
  361. }
  362. $where['id'] = array('in', $id);
  363. switch (strtolower($type)) {
  364. case 'forbid':
  365. $data = array('status' => 0);
  366. break;
  367. case 'resume':
  368. $data = array('status' => 1);
  369. break;
  370. case 'repeal':
  371. $data = array('status' => 2, 'endtime' => time());
  372. break;
  373. case 'del':
  374. $data = array('status' => -1);
  375. break;
  376. case 'delete':
  377. if (M($mobile)->where($where)->delete()) {
  378. $this->success('操作成功!');
  379. } else {
  380. $this->error('操作失败!');
  381. }
  382. break;
  383. default:
  384. $this->error('操作失败!');
  385. }
  386. if (M($mobile)->where($where)->save($data)) {
  387. $this->success('操作成功!');
  388. } else {
  389. $this->error('操作失败!');
  390. }
  391. }
  392. // 后端导航配置
  393. public function dhadmin($name = NULL, $field = NULL, $status = NULL, $hide = NULL)
  394. {
  395. $where = array();
  396. if ($field && $name) {
  397. if ($field == 'username') {
  398. $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
  399. } else if ($field == 'title') {
  400. $where['title'] = array('like', '%' . $name . '%');
  401. } else {
  402. $where[$field] = $name;
  403. }
  404. }
  405. if ($status) {
  406. $where['status'] = $status - 1;
  407. }
  408. if ($hide) {
  409. $where['hide'] = $hide;
  410. }
  411. $where_1 = $where;
  412. $where_1['pid'] = 0;
  413. $where_2 = $where;
  414. $list = M('menu')->where($where_1)->order('sort asc')->select();
  415. foreach ($list as $k => $v) {
  416. $where_2['pid'] = $v['id'];
  417. $list[$k]['voo'] = M('menu')->where($where_2)->order('sort asc')->select();
  418. }
  419. $this->assign('list', $list);
  420. $this->display();
  421. }
  422. public function dhadminEdit($id = NULL)
  423. {
  424. if (empty($_POST)) {
  425. $liste = '';
  426. if ($id) {
  427. $this->data = M('menu')->where(array('id' => trim($id)))->find();
  428. } else {
  429. $this->data = null;
  430. }
  431. $liste = M('menu')->where('pid = 0')->order('sort asc')->select();
  432. $this->assign('liste', $liste);
  433. $this->display();
  434. } else {
  435. if (APP_DEMO) {
  436. $this->error('测试站暂时不能修改!');
  437. }
  438. if (empty($_POST['title'])) {
  439. $this->error('标题错误');
  440. }
  441. if ($_POST['id']) {
  442. $rs = M('menu')->save($_POST);
  443. } else {
  444. $_POST['addtime'] = time();
  445. $rs = M('menu')->add($_POST);
  446. }
  447. if ($rs) {
  448. $this->success('编辑成功!',U('Config/dhadmin'));
  449. } else {
  450. $this->error('编辑失败!');
  451. }
  452. }
  453. }
  454. public function dhadminStatus($id = NULL, $type = NULL, $mobile = 'menu')
  455. {
  456. if (APP_DEMO) {
  457. $this->error('测试站暂时不能修改!');
  458. }
  459. if (empty($id)) {
  460. $this->error('参数错误!');
  461. }
  462. if (empty($type)) {
  463. $this->error('参数错误1!');
  464. }
  465. if (strpos(',', $id)) {
  466. $id = implode(',', $id);
  467. }
  468. $where['id'] = array('in', $id);
  469. switch (strtolower($type)) {
  470. case 'forbid':
  471. $data = array('hide' => 1);
  472. break;
  473. case 'resume':
  474. $data = array('hide' => 0);
  475. break;
  476. case 'repeal':
  477. $data = array('hide' => 2);
  478. break;
  479. case 'delete':
  480. $data = array('status' => -1);
  481. break;
  482. case 'del':
  483. if (M($mobile)->where($where)->delete()) {
  484. $this->success('操作成功!');
  485. } else {
  486. $this->error('操作失败!');
  487. }
  488. break;
  489. default:
  490. $this->error('操作失败!');
  491. }
  492. if (M($mobile)->where($where)->save($data)) {
  493. $this->success('操作成功!');
  494. } else {
  495. $this->error('操作失败!');
  496. }
  497. }
  498. ////市场配置OK
  499. public function ctmarket(){
  500. $count = M('ctmarket')->count();
  501. $Page = new \Think\Page($count, 100);
  502. $show = $Page->show();
  503. $list = M('ctmarket')->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  504. $this->assign('list', $list);
  505. $this->assign('page', $show);
  506. $this->display();
  507. }
  508. /////OK
  509. public function marketo($field = NULL, $name = NULL)
  510. {
  511. $where = array();
  512. if ($field && $name) {
  513. if ($field == 'username') {
  514. $where['userid'] = M('User')->where(array('username' => $name))->getField('id');
  515. } else {
  516. $where[$field] = $name;
  517. }
  518. }
  519. $count = M('Market')->where($where)->count();
  520. $Page = new \Think\Page($count, 100);
  521. $show = $Page->show();
  522. $list = M('Market')->where($where)->order('sort asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  523. $this->assign('list', $list);
  524. $this->assign('page', $show);
  525. $this->display();
  526. }
  527. ///链上币种市场配置修改
  528. public function ctmarketEdit($id = NULL){
  529. if(empty($_POST)){
  530. $id = $_GET['id'];
  531. $this->data = M('ctmarket')->where(array('id' => $id))->find();
  532. $this->display();
  533. }else{
  534. $coinname = $_POST['coinname'];
  535. $status = $_POST['status'];
  536. $state = $_POST['state'];
  537. $sort = $_POST['sort'];
  538. $id = $_POST['id'];
  539. $data['coinname'] = strtolower($coinname);
  540. $data['name'] = strtolower($coinname)."_usdt";
  541. $data['symbol'] = strtolower($coinname)."usdt";
  542. $data['title'] = strtoupper($coinname)."/USDT";
  543. $data['status'] = $status;
  544. $data['state'] = $state;
  545. $data['sort'] = $sort;
  546. $data['addtime'] = date("Y-m-d H:i:s",time());
  547. //编辑
  548. if($id > 0){
  549. $re = M("ctmarket")->where(array('id'=>$id))->save($data);
  550. if($re){
  551. $this->success('操作成功!',U('Config/ctmarket'));
  552. }else{
  553. $this->error('操作失败!');
  554. }
  555. }else{//新增
  556. $re =M("ctmarket")->add($data);
  557. if($re){
  558. $this->success('操作成功!',U('Config/ctmarket'));
  559. }else{
  560. $this->error('操作失败!');
  561. }
  562. }
  563. }
  564. }
  565. // 平台币市场配置修改
  566. public function marketoEdit($id = NULL)
  567. {
  568. $getCoreConfig = getCoreConfig();
  569. if(!$getCoreConfig){
  570. $this->error('核心配置有误');
  571. }
  572. if (empty($_POST)) {
  573. if (empty($id)) {
  574. $this->data = array();
  575. } else {
  576. $this->data = M('Market')->where(array('id' => $id))->find();
  577. }
  578. $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');
  579. $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');
  580. $this->assign('time_arr', $time_arr);
  581. $this->assign('time_minute', $time_minute);
  582. $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
  583. $this->display();
  584. } else {
  585. if (APP_DEMO) {
  586. $this->error('测试站暂时不能修改!');
  587. }
  588. $round = array(0, 1, 2, 3, 4, 5, 6);
  589. if (!in_array($_POST['round'], $round)) {
  590. $this->error('小数位数格式错误!');
  591. }
  592. if(!$_POST['hou_price']){
  593. $_POST['hou_price'] = '0.00000000';
  594. }
  595. if ($_POST['id']) {
  596. $rs = M('Market')->save($_POST);
  597. } else {
  598. $buyname = $_POST['buyname'];
  599. $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
  600. unset($_POST['buyname']);
  601. unset($_POST['sellname']);
  602. if (M('Market')->where(array('name' => $_POST['name']))->find()) {
  603. $this->error('市场存在!');
  604. }
  605. $jiaoyiqu = strtolower($getCoreConfig['indexcat'][$_POST['jiaoyiqu']]);
  606. if ($buyname != $jiaoyiqu) {
  607. $this->error('所属交易区和买方币种不一致!'.$buyname);
  608. }
  609. $rs = M('Market')->add($_POST);
  610. }
  611. if ($rs) {
  612. $this->success('操作成功!',U('Config/marketo'));
  613. } else {
  614. $this->error('操作失败!');
  615. }
  616. }
  617. }
  618. // 市场配置2修改
  619. public function marketoEdit2($id = NULL)
  620. {
  621. $getCoreConfig = getCoreConfig();
  622. if(!$getCoreConfig){
  623. $this->error('核心配置有误');
  624. }
  625. if (empty($_POST)) {
  626. if (empty($id)) {
  627. $this->data = array();
  628. } else {
  629. $this->data = M('Market')->where(array('id' => $id))->find();
  630. }
  631. $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');
  632. $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');
  633. $this->assign('time_arr', $time_arr);
  634. $this->assign('time_minute', $time_minute);
  635. $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
  636. $this->display();
  637. } else {
  638. if (APP_DEMO) {
  639. $this->error('测试站暂时不能修改!');
  640. }
  641. $round = array(0, 1, 2, 3, 4, 5, 6);
  642. if (!in_array($_POST['round'], $round)) {
  643. $this->error('小数位数格式错误!');
  644. }
  645. if ($_POST['id']) {
  646. $rs = M('Market')->save($_POST);
  647. } else {
  648. $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
  649. unset($_POST['buyname']);
  650. unset($_POST['sellname']);
  651. if (M('Market')->where(array('name' => $_POST['name']))->find()) {
  652. $this->error('市场存在!');
  653. }
  654. $rs = M('Market')->add($_POST);
  655. }
  656. if ($rs) {
  657. $this->success('操作成功!',U('Config/marketo'));
  658. } else {
  659. $this->error('操作失败!');
  660. }
  661. }
  662. }
  663. // 市场配置3修改
  664. public function marketoEdit3($id = NULL)
  665. {
  666. $getCoreConfig = getCoreConfig();
  667. if(!$getCoreConfig){
  668. $this->error('核心配置有误');
  669. }
  670. if (empty($_POST)) {
  671. if (empty($id)) {
  672. $this->data = array();
  673. } else {
  674. $this->data = M('Market')->where(array('id' => $id))->find();
  675. }
  676. $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');
  677. $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');
  678. $this->assign('time_arr', $time_arr);
  679. $this->assign('time_minute', $time_minute);
  680. $this->assign('getCoreConfig',$getCoreConfig['indexcat']);
  681. $round = number_format("0",$this->data['round']-1).'1';
  682. $this->assign('round', $round);
  683. $this->display();
  684. } else {
  685. if (APP_DEMO) {
  686. $this->error('测试站暂时不能修改!');
  687. }
  688. $round = array(0, 1, 2, 3, 4, 5, 6);
  689. if (!in_array($_POST['round'], $round)) {
  690. $this->error('小数位数格式错误!');
  691. }
  692. if ($_POST['id']) {
  693. $rs = M('Market')->save($_POST);
  694. } else {
  695. $_POST['name'] = $_POST['sellname'] . '_' . $_POST['buyname'];
  696. unset($_POST['buyname']);
  697. unset($_POST['sellname']);
  698. if (M('Market')->where(array('name' => $_POST['name']))->find()) {
  699. $this->error('市场存在!');
  700. }
  701. $rs = M('Market')->add($_POST);
  702. }
  703. if ($rs) {
  704. $this->success('操作成功!',U('Config/marketo'));
  705. } else {
  706. $this->error('操作失败!');
  707. }
  708. }
  709. }
  710. public function marketoStatus($id = NULL, $type = NULL, $mobile = 'Market')
  711. {
  712. if (APP_DEMO) {
  713. $this->error('测试站暂时不能修改!');
  714. }
  715. if (empty($id)) {
  716. $this->error('参数错误!');
  717. }
  718. if (empty($type)) {
  719. $this->error('参数错误1!');
  720. }
  721. if (strpos(',', $id)) {
  722. $id = implode(',', $id);
  723. }
  724. $where['id'] = array('in', $id);
  725. switch (strtolower($type)) {
  726. case 'forbid':
  727. $data = array('status' => 0);
  728. break;
  729. case 'resume':
  730. $data = array('status' => 1);
  731. break;
  732. case 'repeal':
  733. $data = array('status' => 2, 'endtime' => time());
  734. break;
  735. case 'delete':
  736. $data = array('status' => -1);
  737. break;
  738. case 'del':
  739. if (M($mobile)->where($where)->delete()) {
  740. $this->success('操作成功!');
  741. } else {
  742. $this->error('操作失败!');
  743. }
  744. break;
  745. default:
  746. $this->error('操作失败!');
  747. }
  748. if (M($mobile)->where($where)->save($data)) {
  749. $this->success('操作成功!');
  750. } else {
  751. $this->error('操作失败!');
  752. }
  753. }
  754. ////修改市场配置状态
  755. public function ctmarketoStatus($id = NULL, $type = NULL, $mobile = 'ctmarket'){
  756. if (empty($id)) {
  757. $this->error('参数错误!');
  758. }
  759. if (empty($type)) {
  760. $this->error('参数错误1!');
  761. }
  762. if (strpos(',', $id)) {
  763. $id = implode(',', $id);
  764. }
  765. $where['id'] = array('in', $id);
  766. switch (strtolower($type)) {
  767. case 'forbid':
  768. $data = array('status' => 2);
  769. break;
  770. case 'resume':
  771. $data = array('status' => 1);
  772. break;
  773. case 'del':
  774. if (M($mobile)->where($where)->delete()) {
  775. $this->success('操作成功!');
  776. } else {
  777. $this->error('操作失败!');
  778. }
  779. break;
  780. default:
  781. $this->error('操作失败!');
  782. }
  783. if (M($mobile)->where($where)->save($data)) {
  784. $this->success('操作成功!');
  785. } else {
  786. $this->error('操作失败!');
  787. }
  788. }
  789. }
  790. ?>