GeneralmallController.class.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 GeneralmallController extends CommonController
  16. {
  17. protected function _initialize()
  18. {
  19. parent::_initialize();
  20. }
  21. public function slider()
  22. {
  23. $condition = ' type="slider" ';
  24. $pindex = I('request.page', 1);
  25. $psize = 20;
  26. $keyword = I('request.keyword');
  27. $this->keyword = $keyword;
  28. if (!empty($keyword)) {
  29. $condition .= ' and advname like ' . '"%' . $keyword . '%"';
  30. }
  31. $enabled = I('request.enabled');
  32. if (!empty($enabled) && $enabled >= 0) {
  33. $condition .= ' and enabled = ' . $enabled;
  34. } else {
  35. $enabled = -1;
  36. }
  37. $this->enabled = $enabled;
  38. $list = M()->query('SELECT id,advname,thumb,link,type,displayorder,enabled FROM ' .
  39. C('DB_PREFIX') . "lionfish_comshop_generalmall_adv \r\n
  40. WHERE " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  41. $total = M('lionfish_comshop_generalmall_adv')->where($condition)->count();
  42. $pager = pagination2($total, $pindex, $psize);
  43. $this->list = $list;
  44. $this->pager = $pager;
  45. $this->display();
  46. }
  47. public function addslider()
  48. {
  49. $id = I('request.id');
  50. if (!empty($id)) {
  51. $item = M('lionfish_comshop_generalmall_adv')->where(array('id' => $id))->find();
  52. $this->item = $item;
  53. }
  54. if (IS_POST) {
  55. $data = I('request.data');
  56. D('Seller/Generalmall')->update($data);
  57. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  58. }
  59. $this->display();
  60. }
  61. public function changeslider()
  62. {
  63. $id = I('request.id');
  64. //ids
  65. if (empty($id)) {
  66. $ids = I('request.ids');
  67. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  68. }
  69. if (empty($id)) {
  70. show_json(0, array('message' => '参数错误'));
  71. }
  72. $type = I('request.type');
  73. $value = I('request.value');
  74. if (!(in_array($type, array('enabled', 'displayorder')))) {
  75. show_json(0, array('message' => '参数错误'));
  76. }
  77. $items = M('lionfish_comshop_generalmall_adv')->where(array('id' => array('in', $id)))->select();
  78. foreach ($items as $item) {
  79. M('lionfish_comshop_generalmall_adv')->where(array('id' => $item['id']))->save(array($type => $value));
  80. }
  81. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  82. }
  83. public function delete()
  84. {
  85. $id = I('request.id');
  86. //ids
  87. if (empty($id)) {
  88. $ids = I('request.ids');
  89. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  90. }
  91. if (empty($id)) {
  92. show_json(0, array('message' => '参数错误'));
  93. }
  94. $items = M('lionfish_comshop_generalmall_adv')->where(array('id' => array('in', $id)))->select();
  95. foreach ($items as $item) {
  96. M('lionfish_comshop_generalmall_adv')->where(array('id' => $item['id']))->delete();
  97. }
  98. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  99. }
  100. public function navigat()
  101. {
  102. $_GPC = I('request.');
  103. $pindex = max(1, intval($_GPC['page']));
  104. $psize = 20;
  105. $condition = "";
  106. if (!empty($_GPC['keyword'])) {
  107. $condition .= ' and navname like "%' . trim($_GPC['keyword']) . '%"';
  108. }
  109. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  110. $condition .= ' and enabled = ' . $_GPC['enabled'];
  111. } else {
  112. $_GPC['enabled'] = -1;
  113. }
  114. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX') . "lionfish_comshop_generalmall_navigat
  115. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  116. $total = M('lionfish_comshop_generalmall_navigat')->where('1 ' . $condition)->count();
  117. $pager = pagination2($total, $pindex, $psize);
  118. $this->gpc = $_GPC;
  119. $this->list = $list;
  120. $this->display();
  121. }
  122. public function addnavigat()
  123. {
  124. $_GPC = I('request.');
  125. $id = intval($_GPC['id']);
  126. $category = D('Seller/GoodsCategory')->getFullCategory(false, true);
  127. $this->category = $category;
  128. if (!empty($id)) {
  129. $item = M('lionfish_comshop_generalmall_navigat')->where(array('id' => $id))->find();
  130. $this->item = $item;
  131. }
  132. if (IS_POST) {
  133. $data = $_GPC['data'];
  134. if ($data['type'] == 3 || $data['type'] == 4) {
  135. $data['link'] = $data['cid'];
  136. }
  137. D('Seller/Generalmall')->navigat_update($data);
  138. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  139. }
  140. $this->display();
  141. }
  142. public function changenavigat()
  143. {
  144. $_GPC = I('request.');
  145. $id = intval($_GPC['id']);
  146. //ids
  147. if (empty($id)) {
  148. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  149. }
  150. if (empty($id)) {
  151. show_json(0, array('message' => '参数错误'));
  152. }
  153. $type = trim($_GPC['type']);
  154. $value = trim($_GPC['value']);
  155. if (!(in_array($type, array('enabled', 'displayorder')))) {
  156. show_json(0, array('message' => '参数错误'));
  157. }
  158. $items = M('lionfish_comshop_generalmall_navigat')->field('id')->where('id in( ' . $id . ' ) ')->select();
  159. foreach ($items as $item) {
  160. M('lionfish_comshop_generalmall_navigat')->where(array('id' => $item['id']))->save(array($type => $value));
  161. }
  162. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  163. }
  164. public function deletenavigat()
  165. {
  166. $_GPC = I('request.');
  167. $id = intval($_GPC['id']);
  168. //ids
  169. if (empty($id)) {
  170. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  171. }
  172. if (empty($id)) {
  173. show_json(0, array('message' => '参数错误'));
  174. }
  175. $items = M('lionfish_comshop_generalmall_navigat')->field('id')->where('id in( ' . $id . ' )')->select();
  176. foreach ($items as $item) {
  177. M('lionfish_comshop_generalmall_navigat')->where(array('id' => $item['id']))->delete();
  178. }
  179. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  180. }
  181. }