VipcardController.class.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?php
  2. /**
  3. * 播播资源
  4. *
  5. * ==========================================================================
  6. * @link https://www.ttbobo.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.ttbobo.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. //username telephone
  43. $keyword = 'username like "%'. $_GPC['keyword'] .'%" or telephone like "%'. $_GPC['keyword'] .'%"';
  44. $keyword1 = M('lionfish_comshop_member')->where( $keyword )->order('member_id desc')->find();
  45. if(!empty($keyword1)){
  46. $condition .=' and member_id = '.$keyword1['member_id'].'';
  47. }else{
  48. $condition .= ' and order_sn like "%'. $_GPC['keyword'] .'%"';
  49. }
  50. }
  51. $list = M('lionfish_comshop_member_card_order')->where( $condition )->order('id desc')->limit( (($pindex - 1) * $psize) , $psize )->select();
  52. if( !empty($list) )
  53. {
  54. foreach( $list as $key => $val )
  55. {
  56. //member_id
  57. $mb_info = M('lionfish_comshop_member')->where( array('member_id' => $val['member_id']) )->find();
  58. $val['username'] = $mb_info['username'];
  59. $list[$key] = $val;
  60. }
  61. }
  62. $total = M('lionfish_comshop_member_card_order')->where( $condition )->count();
  63. $pager = pagination2($total, $pindex, $psize);
  64. $this->_GPC = $_GPC;
  65. $this->list = $list;
  66. $this->pager = $pager;
  67. $this->display();
  68. }
  69. public function equity ()
  70. {
  71. $_GPC = I('request.');
  72. $pindex = max(1, intval($_GPC['page']));
  73. $psize = 20;
  74. $condition = " 1 ";
  75. if (!empty($_GPC['keyword'])) {
  76. $_GPC['keyword'] = trim($_GPC['keyword']);
  77. $condition .= ' and equity_name like "%'. $_GPC['keyword'] .'%"';
  78. }
  79. $list = M('lionfish_comshop_member_card_equity')->where( $condition )->order('id desc')->limit( (($pindex - 1) * $psize) , $psize )->select();
  80. $total = M('lionfish_comshop_member_card_equity')->where( $condition )->count();
  81. $pager = pagination2($total, $pindex, $psize);
  82. $this->_GPC = $_GPC;
  83. $this->list = $list;
  84. $this->pager = $pager;
  85. $this->display();
  86. }
  87. /**
  88. * 编辑添加
  89. */
  90. public function add_equity()
  91. {
  92. $_GPC = I('request.') ;
  93. $id = intval($_GPC['id']);
  94. if (!empty($id)) {
  95. $item = M('lionfish_comshop_member_card_equity')->where( array('id' => $id ) )->find();
  96. $this->item = $item;
  97. }
  98. if (IS_POST) {
  99. $data = $_GPC['data'];
  100. D('Home/Vipcard')->updateequity($data);
  101. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  102. }
  103. $this->display('Vipcard/add_equity');
  104. }
  105. public function deleteequity()
  106. {
  107. $_GPC = I('request.');
  108. $id = intval($_GPC['id']);
  109. if (empty($id)) {
  110. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  111. }
  112. $items = M('lionfish_comshop_member_card_equity')->field('id')->where('id in( ' . $id . ' )')->select();
  113. if (empty($item)) {
  114. $item = array();
  115. }
  116. foreach ($items as $item) {
  117. M('lionfish_comshop_member_card_equity')->where( array('id' => $item['id']) )->delete();
  118. }
  119. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  120. }
  121. /**
  122. * 编辑添加
  123. */
  124. public function add()
  125. {
  126. $_GPC = I('request.');
  127. $id = intval($_GPC['id']);
  128. if (!empty($id)) {
  129. $item = M('lionfish_comshop_member_card')->where( array('id' => $id ) )->find();
  130. $this->item = $item;
  131. }
  132. if ( IS_POST ) {
  133. $data = $_GPC['data'];
  134. D('Home/Vipcard')->update($data);
  135. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  136. }
  137. $this->display('Vipcard/post');
  138. }
  139. public function delete()
  140. {
  141. $_GPC = I('request.');
  142. $id = intval($_GPC['id']);
  143. if (empty($id)) {
  144. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  145. }
  146. $items = M('lionfish_comshop_member_card')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  147. if (empty($item)) {
  148. $item = array();
  149. }
  150. foreach ($items as $item) {
  151. M('lionfish_comshop_member_card')->where( array('id' => $item['id']) )->delete();
  152. }
  153. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  154. }
  155. public function config()
  156. {
  157. $_GPC = I('request.');
  158. if ( IS_POST ) {
  159. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  160. D('Seller/Config')->update($data);
  161. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  162. }
  163. $data = D('Seller/Config')->get_all_config();
  164. $this->data = $data;
  165. include $this->display();
  166. }
  167. }
  168. ?>