ConfigindexController.class.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class ConfigindexController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. //'pinjie' => '拼团介绍',
  19. }
  20. public function navigat()
  21. {
  22. $_GPC = I('request.');
  23. $pindex = max(1, intval($_GPC['page']));
  24. $psize = 20;
  25. $condition = "";
  26. if (!empty($_GPC['keyword'])) {
  27. $condition .= ' and navname like "%'.trim($_GPC['keyword']).'%"';
  28. }
  29. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  30. $condition .= ' and enabled = ' . $_GPC['enabled'];
  31. } else {
  32. $_GPC['enabled'] = -1;
  33. }
  34. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_navigat
  35. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  36. $total = M('lionfish_comshop_navigat')->where('1 '. $condition )->count();
  37. $pager = pagination2($total, $pindex, $psize);
  38. $this->gpc = $_GPC;
  39. $this->list = $list;
  40. $this->display();
  41. }
  42. public function slider()
  43. {
  44. $condition = ' type="slider" ';
  45. $pindex = I('request.page', 1);
  46. $psize = 20;
  47. $keyword = I('request.keyword');
  48. $this->keyword = $keyword;
  49. if (!empty($keyword)) {
  50. $condition .= ' and advname like '.'"%' . $keyword . '%"';
  51. }
  52. $enabled = I('request.enabled');
  53. if (!empty($enabled) && $enabled >= 0) {
  54. $condition .= ' and enabled = ' . $enabled;
  55. } else {
  56. $enabled = -1;
  57. }
  58. $this->enabled = $enabled;
  59. $list = M()->query('SELECT id,advname,thumb,link,type,displayorder,enabled FROM ' .
  60. C('DB_PREFIX'). "lionfish_comshop_adv \r\n
  61. WHERE " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  62. $total = M('lionfish_comshop_adv')->where($condition)->count();
  63. $pager = pagination2($total, $pindex, $psize);
  64. $this->list = $list;
  65. $this->pager = $pager;
  66. $this->display();
  67. }
  68. //
  69. public function addnavigat()
  70. {
  71. $_GPC = I('request.');
  72. $id = intval($_GPC['id']);
  73. $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  74. $this->category = $category;
  75. if (!empty($id)) {
  76. // $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  77. // $this->category = $category;
  78. $item = M('lionfish_comshop_navigat')->where( array('id' => $id) )->find();
  79. $this->item = $item;
  80. }
  81. if (IS_POST) {
  82. $data = $_GPC['data'];
  83. if($data['type']==3 || $data['type']==4){
  84. $data['link'] = $data['cid'];
  85. }
  86. D('Seller/Adv')->navigat_update($data);
  87. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  88. }
  89. $this->display();
  90. }
  91. public function changenavigat()
  92. {
  93. $_GPC = I('request.');
  94. $id = intval($_GPC['id']);
  95. //ids
  96. if (empty($id)) {
  97. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  98. }
  99. if (empty($id)) {
  100. show_json(0, array('message' => '参数错误'));
  101. }
  102. $type = trim($_GPC['type']);
  103. $value = trim($_GPC['value']);
  104. if (!(in_array($type, array('enabled', 'displayorder')))) {
  105. show_json(0, array('message' => '参数错误'));
  106. }
  107. $items = M('lionfish_comshop_navigat')->field('id')->where('id in( ' . $id . ' ) ')->select();
  108. foreach ($items as $item) {
  109. M('lionfish_comshop_navigat')->where( array('id' => $item['id']) )->save( array($type => $value) );
  110. }
  111. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  112. }
  113. public function deletenavigat()
  114. {
  115. $_GPC = I('request.');
  116. $id = intval($_GPC['id']);
  117. //ids
  118. if (empty($id)) {
  119. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  120. }
  121. if (empty($id)) {
  122. show_json(0, array('message' => '参数错误'));
  123. }
  124. $items = M('lionfish_comshop_navigat')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  125. foreach ($items as $item) {
  126. M('lionfish_comshop_navigat')->where( array('id' => $item['id']) )->delete();
  127. }
  128. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  129. }
  130. //
  131. public function addslider()
  132. {
  133. $id = I('request.id');
  134. if (!empty($id)) {
  135. $item = M('lionfish_comshop_adv')->where( array('id' => $id) )->find();
  136. $this->item = $item;
  137. }
  138. if (IS_POST) {
  139. $data = I('request.data');
  140. D('Seller/Adv')->update($data);
  141. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  142. }
  143. $this->display();
  144. }
  145. public function changeslider()
  146. {
  147. $id = I('request.id');
  148. //ids
  149. if (empty($id)) {
  150. $ids = I('request.ids');
  151. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  152. }
  153. if (empty($id)) {
  154. show_json(0, array('message' => '参数错误'));
  155. }
  156. $type = I('request.type');
  157. $value = I('request.value');
  158. if (!(in_array($type, array('enabled', 'displayorder')))) {
  159. show_json(0, array('message' => '参数错误'));
  160. }
  161. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  162. foreach ($items as $item) {
  163. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->save( array($type => $value) );
  164. }
  165. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  166. }
  167. public function delete()
  168. {
  169. $id = I('request.id');
  170. //ids
  171. if (empty($id)) {
  172. $ids = I('request.ids');
  173. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  174. }
  175. if (empty($id)) {
  176. show_json(0, array('message' => '参数错误'));
  177. }
  178. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  179. foreach ($items as $item) {
  180. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->delete();
  181. }
  182. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  183. }
  184. /**
  185. * 公告管理
  186. */
  187. public function notice()
  188. {
  189. $pindex = I('request.page',1);
  190. $psize = 20;
  191. $keyword = I('request.keyword','','trim');
  192. $this->keyword = $keyword;
  193. if (!empty($keyword)) {
  194. $condition .= ' and content like "%'.$keyword.'%" ';
  195. }
  196. $enabled = I('request.enabled',-1);
  197. if (isset($enabled) && $enabled >= 0) {
  198. $condition .= ' and enabled = ' . $enabled;
  199. } else {
  200. $enabled = -1;
  201. }
  202. $this->enabled = $enabled;
  203. $list = M()->query('SELECT id,content,displayorder,enabled FROM ' .
  204. C('DB_PREFIX')."lionfish_comshop_notice
  205. WHERE 1=1 " . $condition . ' order by displayorder desc, id desc
  206. limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  207. $total = M('lionfish_comshop_notice')->where( "1=1 ".$condition )->count();
  208. $pager = pagination2($total, $pindex, $psize);
  209. $this->list = $list;
  210. $this->pager = $pager;
  211. $this->display();
  212. }
  213. /**
  214. * 添加公告
  215. */
  216. public function addnotice()
  217. {
  218. $id = I('request.id');
  219. if (!empty($id)) {
  220. $item = M('lionfish_comshop_notice')->where( array('id' => $id) )->find();
  221. $this->item = $item;
  222. }
  223. if (IS_POST) {
  224. $data = I('request.data');
  225. D('Seller/Notice')->update($data);
  226. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  227. }
  228. $this->display();
  229. }
  230. /**
  231. * 改变公告状态
  232. */
  233. public function changenotice()
  234. {
  235. $id = I('request.id');
  236. //ids
  237. if (empty($id)) {
  238. $ids = I('request.ids');
  239. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  240. }
  241. if (empty($id)) {
  242. show_json(0, array('message' => '参数错误'));
  243. }
  244. $type = I('request.type');
  245. $value = I('request.value');
  246. if (!(in_array($type, array('enabled', 'displayorder')))) {
  247. show_json(0, array('message' => '参数错误'));
  248. }
  249. $items = M('lionfish_comshop_notice')->where( array('id' => array('in', $id)) )->select();
  250. foreach ($items as $item) {
  251. M('lionfish_comshop_notice')->where( array('id' => $item['id']) )->save( array($type => $value) );
  252. }
  253. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  254. }
  255. /**
  256. * 删除公告
  257. */
  258. public function deletenotice()
  259. {
  260. $id = I('request.id');
  261. if (empty($id)) {
  262. $ids = I('request.ids');
  263. $id = (is_array($ids) ? implode(',', $ids) : 0);
  264. }
  265. $items = M('lionfish_comshop_notice')->field('id,content')->where( array('id' => array('in',$id)) )->select();
  266. if (empty($item)) {
  267. $item = array();
  268. }
  269. foreach ($items as $item) {
  270. M('lionfish_comshop_notice')->where( array('id' => $item['id']) )->delete();
  271. }
  272. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  273. }
  274. public function index()
  275. {
  276. if (IS_POST) {
  277. $data = I('request.parameter');
  278. $param = array();
  279. if(trim($data['wechat_apiclient_cert_pem'])) $param['wechat_apiclient_cert_pem'] = trim($data['wechat_apiclient_cert_pem']);
  280. if(trim($data['wechat_apiclient_key_pem'])) $param['wechat_apiclient_key_pem'] = trim($data['wechat_apiclient_key_pem']);
  281. if(trim($data['wechat_rootca_pem'])) $param['wechat_rootca_pem'] = trim($data['wechat_rootca_pem']);
  282. if(trim($data['weapp_apiclient_cert_pem'])) $param['weapp_apiclient_cert_pem'] = trim($data['weapp_apiclient_cert_pem']);
  283. if(trim($data['weapp_apiclient_key_pem'])) $param['weapp_apiclient_key_pem'] = trim($data['weapp_apiclient_key_pem']);
  284. if(trim($data['weapp_rootca_pem'])) $param['weapp_rootca_pem'] = trim($data['weapp_rootca_pem']);
  285. if(trim($data['app_apiclient_cert_pem'])) $param['app_apiclient_cert_pem'] = trim($data['app_apiclient_cert_pem']);
  286. if(trim($data['app_apiclient_key_pem'])) $param['app_apiclient_key_pem'] = trim($data['app_apiclient_key_pem']);
  287. if(trim($data['app_rootca_pem'])) $param['app_rootca_pem'] = trim($data['app_rootca_pem']);
  288. D('Seller/Config')->update($param);
  289. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  290. }
  291. $data = D('Seller/Config')->get_all_config();
  292. $this->data = $data;
  293. $this->display();
  294. }
  295. public function noticesetting()
  296. {
  297. if (IS_POST) {
  298. $data = I('request.parameter');
  299. $data['index_notice_horn_image'] = save_media($data['index_notice_horn_image']);
  300. D('Seller/Config')->update($data);
  301. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  302. }
  303. $data = D('Seller/Config')->get_all_config();
  304. $this->data = $data;
  305. $this->display();
  306. }
  307. public function qgtab()
  308. {
  309. if (IS_POST) {
  310. $data = I('request.parameter');
  311. $data['index_qgtab_one_select'] = save_media($data['index_qgtab_one_select']);
  312. $data['index_qgtab_one_selected'] = save_media($data['index_qgtab_one_selected']);
  313. $data['index_qgtab_two_select'] = save_media($data['index_qgtab_two_select']);
  314. $data['index_qgtab_two_selected'] = save_media($data['index_qgtab_two_selected']);
  315. D('Seller/Config')->update($data);
  316. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  317. }
  318. $data = D('Seller/Config')->get_all_config();
  319. $this->data = $data;
  320. $this->display();
  321. }
  322. /**
  323. * 图片魔方
  324. */
  325. public function cube()
  326. {
  327. $_GPC = I('request.');
  328. $condition = '';
  329. $pindex = max(1, intval($_GPC['page']));
  330. $psize = 20;
  331. if (!empty($_GPC['keyword'])) {
  332. $_GPC['keyword'] = trim($_GPC['keyword']);
  333. $condition .= ' and name like "%'.$_GPC['keyword'].'%"';
  334. }
  335. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  336. $_GPC['enabled'] = trim($_GPC['enabled']);
  337. $condition .= ' and enabled = ' . $_GPC['enabled'];
  338. } else {
  339. $_GPC['enabled'] = -1;
  340. }
  341. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_cube
  342. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize );
  343. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_cube WHERE 1 ' . $condition );
  344. $total = $total_arr['0']['count'];
  345. $pager = pagination2($total, $pindex, $psize);
  346. $this->list = $list;
  347. $this->pager = $pager;
  348. $this->_GPC =$_GPC;
  349. $this->display();
  350. }
  351. /**
  352. * 添加魔方图片
  353. */
  354. public function addcube()
  355. {
  356. $_GPC = I('request.');
  357. $id = intval($_GPC['id']);
  358. if (!empty($id)) {
  359. $item = M('lionfish_comshop_cube')->where( array('id' => $id ) )->find();
  360. $item['thumb'] = unserialize($item['thumb']);
  361. $this->item = $item;
  362. }
  363. if ( IS_POST ) {
  364. $data = $_GPC['data'];
  365. $thumb = $cover = $link = array();
  366. $cover[] = $data["thumb_0"];
  367. $cover[] = $data["thumb_1"];
  368. $cover[] = $data["thumb_2"];
  369. $cover[] = $data["thumb_3"];
  370. $link[] = $data["link_0"];
  371. $link[] = $data["link_1"];
  372. $link[] = $data["link_2"];
  373. $link[] = $data["link_3"];
  374. $linktype[] = $data["linktype_0"];
  375. $linktype[] = $data["linktype_1"];
  376. $linktype[] = $data["linktype_2"];
  377. $linktype[] = $data["linktype_3"];
  378. $webview[] = $data["webview_0"];
  379. $webview[] = $data["webview_1"];
  380. $webview[] = $data["webview_2"];
  381. $webview[] = $data["webview_3"];
  382. $num = $data['num'];
  383. if($num==4){
  384. $thumb['cover'] = $cover;
  385. $thumb['link'] = $link;
  386. $thumb['linktype'] = $linktype;
  387. $thumb['webview'] = $webview;
  388. } else {
  389. $coverArr = array_chunk($cover, $num);
  390. $linkArr = array_chunk($link, $num);
  391. $linktypeArr = array_chunk($linktype, $num);
  392. $webviewArr = array_chunk($webview, $num);
  393. $thumb['cover'] = $coverArr[0];
  394. $thumb['link'] = $linkArr[0];
  395. $thumb['linktype'] = $linktypeArr[0];
  396. $thumb['webview'] = $webviewArr[0];
  397. }
  398. $params = array();
  399. $params['name'] = $data['name'];
  400. $params['displayorder'] = $data['displayorder'];
  401. $params['enabled'] = $data['enabled'];
  402. $params['name'] = $data['name'];
  403. $params['type'] = $data['type'];
  404. $params['thumb'] = serialize($thumb);
  405. $params['num'] = $data['num'];
  406. $params['linktype'] = 1;
  407. $params['addtime'] = time();
  408. if( !empty($id) && $id > 0 )
  409. {
  410. unset($params['addtime']);
  411. M('lionfish_comshop_cube')->where( array('id' => $id) )->save( $params );
  412. $id = $data['id'];
  413. }else{
  414. $id = M('lionfish_comshop_cube')->add( $params );
  415. }
  416. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  417. }
  418. $this->display();
  419. }
  420. /**
  421. * 切换魔方图显示隐藏 排序
  422. */
  423. public function changeCube()
  424. {
  425. $_GPC = I('request.');
  426. $id = intval($_GPC['id']);
  427. //ids
  428. if (empty($id)) {
  429. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  430. }
  431. if (empty($id)) {
  432. show_json(0, array('message' => '参数错误'));
  433. }
  434. $type = trim($_GPC['type']);
  435. $value = trim($_GPC['value']);
  436. if (!(in_array($type, array('enabled', 'displayorder')))) {
  437. show_json(0, array('message' => '参数错误'));
  438. }
  439. $items = M('lionfish_comshop_cube')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  440. foreach ($items as $item) {
  441. M('lionfish_comshop_cube')->where( array('id' => $item['id']) )->save( array($type => $value) );
  442. }
  443. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  444. }
  445. /**
  446. * 删除魔方图
  447. * @return [json] [description]
  448. */
  449. public function deleteCube()
  450. {
  451. $_GPC = I('request.');
  452. $id = intval($_GPC['id']);
  453. //ids
  454. if (empty($id)) {
  455. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  456. }
  457. if (empty($id)) {
  458. show_json(0, array('message' => '参数错误'));
  459. }
  460. $items = M('lionfish_comshop_cube')->field('id')->where( 'id in( ' . $id . ' ) ' )->select();
  461. foreach ($items as $item) {
  462. M('lionfish_comshop_cube')->where( array('id' => $item['id'] ) )->delete();
  463. }
  464. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  465. }
  466. /**
  467. * 首页视频
  468. * @return [Json] [description]
  469. */
  470. public function video()
  471. {
  472. $_GPC = I('request.');
  473. if ( IS_POST ) {
  474. $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
  475. $data['index_video_poster'] = save_media($data['index_video_poster']);
  476. $data['index_video_url'] = save_media($data['index_video_url']);
  477. D('Seller/Config')->update($data);
  478. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  479. }
  480. $data = D('Seller/Config')->get_all_config();
  481. $this->data = $data;
  482. $this->display();
  483. }
  484. }
  485. ?>