MemberAuth.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. use PHPExcel;
  6. /**
  7. *
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * 控制器
  12. */
  13. class MemberAuth extends AdminControl
  14. {
  15. const EXPORT_SIZE = 1000;
  16. public function initialize()
  17. {
  18. parent::initialize();
  19. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/member.lang.php');
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/member_auth.lang.php');
  21. }
  22. public function index()
  23. {
  24. $member_model = model('member');
  25. $search_field_value = input('search_field_value');
  26. $search_field_name = input('search_field_name');
  27. $condition = '1=1';
  28. $filtered = 0;
  29. $default_condition = array();
  30. if ($search_field_value != '') {
  31. switch ($search_field_name) {
  32. case 'member_name':
  33. $condition .= ' AND member_name LIKE "%' . trim($search_field_value) . '%"';
  34. $filtered = 1;
  35. break;
  36. case 'member_email':
  37. $condition .= ' AND member_email LIKE "%' . trim($search_field_value) . '%"';
  38. $filtered = 1;
  39. break;
  40. case 'member_mobile':
  41. $condition .= ' AND member_mobile LIKE "%' . trim($search_field_value) . '%"';
  42. $filtered = 1;
  43. break;
  44. case 'member_truename':
  45. $condition .= ' AND member_truename LIKE "%' . trim($search_field_value) . '%"';
  46. $filtered = 1;
  47. break;
  48. }
  49. }
  50. $search_state = input('search_state');
  51. switch ($search_state) {
  52. case 'check':
  53. $condition .= ' AND member_auth_state=1';
  54. $filtered = 1;
  55. break;
  56. case 'pass':
  57. $condition .= ' AND member_auth_state=3';
  58. $filtered = 1;
  59. break;
  60. case 'fail':
  61. $condition .= ' AND member_auth_state=2';
  62. $filtered = 1;
  63. break;
  64. default:
  65. $condition .= ' AND member_auth_state IN (1,2,3)';
  66. }
  67. $member_list = $member_model->getMemberList($condition, '*', 10, 'member_id desc');
  68. //整理会员信息
  69. if (is_array($member_list) && !empty($member_list)) {
  70. foreach ($member_list as $k => $v) {
  71. $member_list[$k]['member_addtime'] = $v['member_addtime'] ? date('Y-m-d H:i:s', $v['member_addtime']) : '';
  72. }
  73. }
  74. View::assign('search_field_name', trim($search_field_name));
  75. View::assign('search_field_value', trim($search_field_value));
  76. View::assign('member_list', $member_list);
  77. View::assign('show_page', $member_model->page_info->render());
  78. View::assign('filtered', $filtered); //是否有查询条件
  79. $this->setAdminCurItem('index');
  80. return View::fetch();
  81. }
  82. public function verify()
  83. {
  84. $member_id = input('param.member_id');
  85. $state = input('param.state');
  86. $message = input('param.message');
  87. $member_id_array = ds_delete_param($member_id);
  88. if ($member_id_array == FALSE || !in_array($state, array(1, 2))) {
  89. ds_json_encode(10001, lang('param_error'));
  90. }
  91. if ($state == 1) {
  92. $update = array('member_auth_state' => 3);
  93. } else {
  94. $update = array('member_auth_state' => 2);
  95. }
  96. if (!model('member')->editMember(array(array('member_auth_state', '=', 1), array('member_id', 'in', $member_id_array)), $update)) {
  97. ds_json_encode(10001, lang('ds_common_op_fail'));
  98. }
  99. if ($message) {
  100. //添加短消息
  101. $message_model = model('message');
  102. $insert_arr = array();
  103. $insert_arr['from_member_id'] = 0;
  104. $insert_arr['member_id'] = "," . implode(',', $member_id_array) . ",";
  105. $insert_arr['msg_content'] = lang('member_auth_fail') . ':' . $message;
  106. $insert_arr['message_type'] = 1;
  107. $insert_arr['message_ismore'] = 1;
  108. $message_model->addMessage($insert_arr);
  109. }
  110. ds_json_encode(10000, lang('ds_common_op_succ'));
  111. }
  112. /**
  113. * 获取卖家栏目列表,针对控制器下的栏目
  114. */
  115. protected function getAdminItemList()
  116. {
  117. $menu_array = array(
  118. array(
  119. 'name' => 'index',
  120. 'text' => lang('ds_list'),
  121. 'url' => (string)url('MemberAuth/index')
  122. ),
  123. );
  124. return $menu_array;
  125. }
  126. }