Member.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Db;
  5. use think\facade\Lang;
  6. /**
  7. * ============================================================================
  8. * DSMall多用户商城
  9. * ============================================================================
  10. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  11. * 网站地址: http://www.csdeshang.com
  12. * ----------------------------------------------------------------------------
  13. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  14. * 不允许对程序代码以任何形式任何目的的再发布。
  15. * ============================================================================
  16. * 控制器
  17. */
  18. class Member extends AdminControl {
  19. public function initialize() {
  20. parent::initialize();
  21. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/member.lang.php');
  22. }
  23. public function member() {
  24. $member_model = model('member');
  25. //会员级别
  26. $member_grade = $member_model->getMemberGradeArr();
  27. $search_field_value = input('search_field_value');
  28. $search_field_name = input('search_field_name');
  29. $condition = array();
  30. if ($search_field_value != '') {
  31. switch ($search_field_name) {
  32. case 'member_name':
  33. $condition[]=array('member_name','like', '%' . trim($search_field_value) . '%');
  34. break;
  35. case 'member_email':
  36. $condition[]=array('member_email','like', '%' . trim($search_field_value) . '%');
  37. break;
  38. case 'member_mobile':
  39. $condition[]=array('member_mobile','like', '%' . trim($search_field_value) . '%');
  40. break;
  41. case 'member_truename':
  42. $condition[]=array('member_truename','like', '%' . trim($search_field_value) . '%');
  43. break;
  44. }
  45. }
  46. $search_state = input('search_state');
  47. switch ($search_state) {
  48. case 'no_informallow':
  49. $condition[]=array('inform_allow','=','2');
  50. break;
  51. case 'no_isbuy':
  52. $condition[]=array('is_buylimit','=','0');
  53. break;
  54. case 'no_isallowtalk':
  55. $condition[]=array('is_allowtalk','=','0');
  56. break;
  57. case 'no_memberstate':
  58. $condition[]=array('member_state','=','0');
  59. break;
  60. }
  61. //会员等级
  62. $search_grade = intval(input('get.search_grade'));
  63. if ($search_grade>0 && $member_grade) {
  64. if (isset($member_grade[$search_grade + 1]['exppoints'])) {
  65. $condition[] = array('member_exppoints','between',array($member_grade[$search_grade]['exppoints'],$member_grade[$search_grade + 1]['exppoints']));
  66. }else{
  67. $condition[]=array('member_exppoints','>=', $member_grade[$search_grade]['exppoints']);
  68. }
  69. }
  70. //排序
  71. $order = trim(input('get.search_sort'));
  72. if (!in_array($order,array('member_logintime desc','member_loginnum desc'))) {
  73. $order = 'member_id desc';
  74. }
  75. $member_list = $member_model->getMemberList($condition, '*', 10, $order);
  76. //整理会员信息
  77. if (is_array($member_list) && !empty($member_list)) {
  78. foreach ($member_list as $k => $v) {
  79. $member_list[$k]['member_addtime'] = $v['member_addtime'] ? date('Y-m-d H:i:s', $v['member_addtime']) : '';
  80. $member_list[$k]['member_logintime'] = $v['member_logintime'] ? date('Y-m-d H:i:s', $v['member_logintime']) : '';
  81. $member_list[$k]['member_grade'] = ($t = $member_model->getOneMemberGrade($v['member_exppoints'], false, $member_grade)) ? $t['level_name'] : '';
  82. }
  83. }
  84. View::assign('member_grade', $member_grade);
  85. View::assign('search_sort', $order);
  86. View::assign('search_field_name', trim($search_field_name));
  87. View::assign('search_field_value', trim($search_field_value));
  88. View::assign('member_list', $member_list);
  89. View::assign('show_page', $member_model->page_info->render());
  90. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  91. $this->setAdminCurItem('member');
  92. return View::fetch();
  93. }
  94. public function add() {
  95. if (!request()->isPost()) {
  96. return View::fetch();
  97. } else {
  98. //需要完善地方 1.对录入数据进行判断 2.对判断用户名是否存在
  99. $member_model = model('member');
  100. $data = array(
  101. 'member_name' => trim(input('post.member_name')),
  102. 'member_password' => input('post.member_password'),
  103. 'member_email' => input('post.member_email'),
  104. 'member_truename' => input('post.member_truename'),
  105. 'member_sex' => input('post.member_sex'),
  106. 'member_qq' => input('post.member_qq'),
  107. 'member_ww' => input('post.member_ww'),
  108. 'member_addtime' => TIMESTAMP,
  109. 'member_loginnum' => 0,
  110. 'inform_allow' => 1, //默认允许举报商品
  111. );
  112. $member_validate = ds_validate('member');
  113. if (!$member_validate->scene('add')->check($data)){
  114. $this->error($member_validate->getError());
  115. }
  116. $result = $member_model->addMember($data);
  117. if ($result) {
  118. dsLayerOpenSuccess(lang('ds_common_op_succ'));
  119. } else {
  120. $this->error(lang('member_add_fail'));
  121. }
  122. }
  123. }
  124. public function edit() {
  125. //注:pathinfo地址参数不能通过get方法获取,查看“获取PARAM变量”
  126. $member_id = intval(input('param.member_id'));
  127. if (empty($member_id)) {
  128. $this->error(lang('param_error'));
  129. }
  130. $member_model = model('member');
  131. $condition = array();
  132. $condition[] = array('member_id','=',$member_id);
  133. $member_array = $member_model->getMemberInfo($condition);
  134. if (!request()->isPost()) {
  135. View::assign('member_array', $member_array);
  136. return View::fetch();
  137. } else {
  138. $member_mobile=input('post.member_mobile');
  139. if($member_mobile==encrypt_show($member_array['member_mobile'],4,4)){
  140. $member_mobile=$member_array['member_mobile'];
  141. }
  142. $data = array(
  143. 'member_email' => input('post.member_email'),
  144. 'member_truename' => input('post.member_truename'),
  145. 'member_sex' => input('post.member_sex'),
  146. 'member_qq' => input('post.member_qq'),
  147. 'member_ww' => input('post.member_ww'),
  148. 'inform_allow' => input('post.inform_allow'),
  149. 'is_buylimit' => input('post.isbuy'),
  150. 'is_allowtalk' => input('post.allowtalk'),
  151. 'member_state' => input('post.member_state'),
  152. 'member_cityid' => input('post.city_id'),
  153. 'member_provinceid' => input('post.province_id'),
  154. 'member_areainfo' => input('post.region'),
  155. 'member_areaid' => input('post.area_id'),
  156. 'member_mobile' => $member_mobile,
  157. 'member_emailbind' => input('post.member_emailbind'),
  158. 'member_mobilebind' => input('post.member_mobilebind'),
  159. 'member_auth_state' => input('post.member_auth_state'),
  160. );
  161. if (input('post.member_password')) {
  162. $data['member_password'] = md5(input('post.member_password'));
  163. }
  164. if (input('post.member_paypwd')) {
  165. $data['member_paypwd'] = md5(input('post.member_paypwd'));
  166. }
  167. $member_validate = ds_validate('member');
  168. if (!$member_validate->scene('edit')->check($data)){
  169. $this->error($member_validate->getError());
  170. }
  171. $result = $member_model->editMember(array('member_id'=>$member_id),$data,$member_id);
  172. if ($result>=0) {
  173. dsLayerOpenSuccess(lang('ds_common_op_succ'));
  174. } else {
  175. $this->error(lang('ds_common_op_fail'));
  176. }
  177. }
  178. }
  179. /**
  180. * ajax操作
  181. */
  182. public function ajax() {
  183. $branch = input('param.branch');
  184. $condition=array();
  185. switch ($branch) {
  186. /**
  187. * 验证会员是否重复
  188. */
  189. case 'check_user_name':
  190. $member_model = model('member');
  191. $condition[]=array('member_name','=',input('param.member_name'));
  192. $condition[]=array('member_id','<>', intval(input('get.member_id')));
  193. $list = $member_model->getMemberInfo($condition);
  194. if (empty($list)) {
  195. echo 'true';
  196. exit;
  197. } else {
  198. echo 'false';
  199. exit;
  200. }
  201. break;
  202. /**
  203. * 验证邮件是否重复
  204. */
  205. case 'check_email':
  206. $member_model = model('member');
  207. $condition[]=array('member_email','=',input('param.member_email'));
  208. $condition[]=array('member_id','<>', intval(input('param.member_id')));
  209. $list = $member_model->getMemberInfo($condition);
  210. if (empty($list)) {
  211. echo 'true';
  212. exit;
  213. } else {
  214. echo 'false';
  215. exit;
  216. }
  217. break;
  218. }
  219. }
  220. /**
  221. * 设置会员状态
  222. */
  223. public function memberstate() {
  224. $member_id = input('param.member_id');
  225. $member_id_array = ds_delete_param($member_id);
  226. if ($member_id_array == FALSE) {
  227. ds_json_encode('10001', lang('param_error'));
  228. }
  229. $data['member_state'] = input('param.member_state') ? input('param.member_state') : 0;
  230. $condition = array();
  231. $condition[]=array('member_id','in', $member_id_array);
  232. $result = Db::name('member')->where($condition)->update($data);
  233. if ($result>=0) {
  234. foreach ($member_id_array as $key => $member_id) {
  235. dcache($member_id, 'member');
  236. }
  237. $this->log(lang('ds_edit') . '[ID:' . implode(',', $member_id_array) . ']', 1);
  238. ds_json_encode('10000', lang('ds_common_op_succ'));
  239. }else{
  240. ds_json_encode('10001', lang('ds_common_op_fail'));
  241. }
  242. }
  243. /**
  244. * 获取卖家栏目列表,针对控制器下的栏目
  245. */
  246. protected function getAdminItemList() {
  247. $menu_array = array(
  248. array(
  249. 'name' => 'member',
  250. 'text' => lang('ds_manage'),
  251. 'url' => (string)url('Member/member')
  252. ),
  253. );
  254. if (request()->action() == 'add' || request()->action() == 'member') {
  255. $menu_array[] = array(
  256. 'name' => 'add',
  257. 'text' => lang('ds_add'),
  258. 'url' => "javascript:dsLayerOpen('".(string)url('Member/add')."','".lang('ds_add')."')"
  259. );
  260. }
  261. return $menu_array;
  262. }
  263. }
  264. ?>