VipcardController.class.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 VipcardController extends CommonController{
  16. public function index()
  17. {
  18. $_GPC = I('request.');
  19. $pindex = max(1, intval($_GPC['page']));
  20. $psize = 20;
  21. $condition = " 1 ";
  22. if (!empty($_GPC['keyword'])) {
  23. $_GPC['keyword'] = trim($_GPC['keyword']);
  24. $condition .= ' and cardname like "%'.$_GPC['keyword'].'%"';
  25. }
  26. $list = M('lionfish_comshop_member_card')->where($condition)->order('id desc')->limit( (($pindex - 1) * $psize) , $psize )->select();
  27. $total = M('lionfish_comshop_member_card')->where( $condition )->count();
  28. $pager = pagination2($total, $pindex, $psize);
  29. $this->list = $list;
  30. $this->pager = $pager;
  31. $this->_GPC = $_GPC;
  32. $this->display();
  33. }
  34. public function order ()
  35. {
  36. $_GPC = I('request.');
  37. $pindex = max(1, intval($_GPC['page']));
  38. $psize = 20;
  39. $condition = " state= 1 ";
  40. if (!empty($_GPC['keyword'])) {
  41. $_GPC['keyword'] = trim($_GPC['keyword']);
  42. $condition .= ' and order_sn like "%'. $_GPC['keyword'] .'%"';
  43. }
  44. $list = M('lionfish_comshop_member_card_order')->where( $condition )->order('id desc')->limit( (($pindex - 1) * $psize) , $psize )->select();
  45. if( !empty($list) )
  46. {
  47. foreach( $list as $key => $val )
  48. {
  49. //member_id
  50. $mb_info = M('lionfish_comshop_member')->where( array('member_id' => $val['member_id']) )->find();
  51. $val['username'] = $mb_info['username'];
  52. $list[$key] = $val;
  53. }
  54. }
  55. $total = M('lionfish_comshop_member_card_order')->where( $condition )->count();
  56. $pager = pagination2($total, $pindex, $psize);
  57. $this->_GPC = $_GPC;
  58. $this->list = $list;
  59. $this->pager = $pager;
  60. $this->display();
  61. }
  62. public function equity ()
  63. {
  64. $_GPC = I('request.');
  65. $pindex = max(1, intval($_GPC['page']));
  66. $psize = 20;
  67. $condition = " 1 ";
  68. if (!empty($_GPC['keyword'])) {
  69. $_GPC['keyword'] = trim($_GPC['keyword']);
  70. $condition .= ' and equity_name like "%'. $_GPC['keyword'] .'%"';
  71. }
  72. $list = M('lionfish_comshop_member_card_equity')->where( $condition )->order('id desc')->limit( (($pindex - 1) * $psize) , $psize )->select();
  73. $total = M('lionfish_comshop_member_card_equity')->where( $condition )->count();
  74. $pager = pagination2($total, $pindex, $psize);
  75. $this->_GPC = $_GPC;
  76. $this->list = $list;
  77. $this->pager = $pager;
  78. $this->display();
  79. }
  80. /**
  81. * 编辑添加
  82. */
  83. public function add_equity()
  84. {
  85. $_GPC = I('request.') ;
  86. $id = intval($_GPC['id']);
  87. if (!empty($id)) {
  88. $item = M('lionfish_comshop_member_card_equity')->where( array('id' => $id ) )->find();
  89. $this->item = $item;
  90. }
  91. if (IS_POST) {
  92. $data = $_GPC['data'];
  93. D('Home/Vipcard')->updateequity($data);
  94. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  95. }
  96. $this->display('Vipcard/add_equity');
  97. }
  98. public function deleteequity()
  99. {
  100. $_GPC = I('request.');
  101. $id = intval($_GPC['id']);
  102. if (empty($id)) {
  103. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  104. }
  105. $items = M('lionfish_comshop_member_card_equity')->field('id')->where('id in( ' . $id . ' )')->select();
  106. if (empty($item)) {
  107. $item = array();
  108. }
  109. foreach ($items as $item) {
  110. M('lionfish_comshop_member_card_equity')->where( array('id' => $item['id']) )->delete();
  111. }
  112. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  113. }
  114. /**
  115. * 编辑添加
  116. */
  117. public function add()
  118. {
  119. $_GPC = I('request.');
  120. $id = intval($_GPC['id']);
  121. if (!empty($id)) {
  122. $item = M('lionfish_comshop_member_card')->where( array('id' => $id ) )->find();
  123. $this->item = $item;
  124. }
  125. if ( IS_POST ) {
  126. $data = $_GPC['data'];
  127. D('Home/Vipcard')->update($data);
  128. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  129. }
  130. $this->display('Vipcard/post');
  131. }
  132. public function delete()
  133. {
  134. $_GPC = I('request.');
  135. $id = intval($_GPC['id']);
  136. if (empty($id)) {
  137. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  138. }
  139. $items = M('lionfish_comshop_member_card')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  140. if (empty($item)) {
  141. $item = array();
  142. }
  143. foreach ($items as $item) {
  144. M('lionfish_comshop_member_card')->where( array('id' => $item['id']) )->delete();
  145. }
  146. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  147. }
  148. public function config()
  149. {
  150. $_GPC = I('request.');
  151. if ( IS_POST ) {
  152. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  153. D('Seller/Config')->update($data);
  154. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  155. }
  156. $data = D('Seller/Config')->get_all_config();
  157. $this->data = $data;
  158. include $this->display();
  159. }
  160. }
  161. ?>