MemberController.class.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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. use Admin\Model\MemberModel;
  16. class MemberController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='用户管理';
  20. $this->breadcrumb2='前台用户';
  21. }
  22. public function index(){
  23. $model=new MemberModel();
  24. $filter=I('get.');
  25. $search=array();
  26. if(isset($filter['name'])){
  27. $search['name']=$filter['name'];
  28. }
  29. if(isset($filter['share_id'])){
  30. $search['share_id']=$filter['share_id'];
  31. }
  32. if(isset($filter['level_id']) && $filter['level_id'] != -1){
  33. $search['level_id']=$filter['level_id'];
  34. }
  35. $data=$model->show_member_page($search);
  36. foreach($data['list'] as $key => $val)
  37. {
  38. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  39. if(!empty($address_info)) {
  40. $val['telephone'] = $address_info['telephone'];
  41. }
  42. $data['list'][$key] = $val;
  43. }
  44. $level_list = array();
  45. $level_list = M('member_level')->order('id asc')->select();
  46. $this->level_id = I('get.level_id',0);
  47. $this->level_list = $level_list;
  48. $this->assign('empty',$data['empty']);// 赋值数据集
  49. $this->assign('list',$data['list']);// 赋值数据集
  50. $this->assign('page',$data['page']);// 赋值分页输出
  51. $this->display();
  52. }
  53. public function zhenquery()
  54. {
  55. $keyword = I('request.keyword');
  56. $params = array();
  57. $condition =" 1=1 ";
  58. $this->keyword = $keyword;
  59. if (!empty($keyword)) {
  60. $condition .= ' AND ( `username` LIKE '.'"%' . $keyword . '%"'.' or `telephone` like '.'"%' . $keyword . '%"'.' )';
  61. }
  62. $ds = M('lionfish_comshop_member')->where( $condition )->order('member_id asc')->select();
  63. foreach ($ds as &$value) {
  64. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  65. $value['id'] = $value['member_id'];
  66. }
  67. unset($value);
  68. $suggest = I('request.suggest');
  69. if ( !empty($suggest)) {
  70. exit(json_encode(array('value' => $ds)));
  71. }
  72. $this->ds = $ds;
  73. $this->display('Member/query');
  74. }
  75. public function query()
  76. {
  77. $condition =" 1=1 ";
  78. $keyword = trim($_GPC['keyword']);
  79. $params = array();
  80. $this->keyword = $keyword;
  81. if (!empty($keyword)) {
  82. $condition .= ' AND ( `username` LIKE '.'"%' . $keyword . '%"'.' )';
  83. }
  84. $ds = M('lionfish_comshop_member')->where( $condition )->order('member_id asc')->select();
  85. foreach ($ds as &$value) {
  86. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  87. $value['avatar'] = ($value['avatar']);
  88. }
  89. unset($value);
  90. $suggest = I('request.suggest');
  91. if ( !empty($suggest)) {
  92. exit(json_encode(array('value' => $ds)));
  93. }
  94. $this->ds = $ds;
  95. $this->display('Member/query');
  96. }
  97. /**
  98. 资金流水
  99. **/
  100. public function charge_flow()
  101. {
  102. //id/26
  103. $member_id = I('get.id');
  104. $state=I('get.state',0);
  105. $model=new MemberModel();
  106. $search=array('member_id' => $member_id);
  107. if(isset($state) && $state > 0){
  108. $search['state']=$state;
  109. }
  110. //member_charge_flow
  111. $data=$model->show_member_charge_page($search);
  112. $this->member_id = $member_id;
  113. $this->assign('state',$state);
  114. $this->assign('empty',$data['empty']);// 赋值数据集
  115. $this->assign('list',$data['list']);// 赋值数据集
  116. $this->assign('page',$data['page']);// 赋值分页输出
  117. $this->display();
  118. }
  119. public function dellevel()
  120. {
  121. //id/4
  122. $id = I('get.id');
  123. // $level_info = M('member_level')->where( array('id' => $id) )->find();
  124. M('member')->where( array('level_id' => $id) )->save( array('level_id' => 0) );
  125. M('member_level')->where( array('id' => $id) )->delete();
  126. $return = array();
  127. $return['status'] = 'success';
  128. $return['message'] = '操作成功';
  129. $return['jump'] = U('Member/level');
  130. $this->osc_alert($return);
  131. }
  132. public function level()
  133. {
  134. $this->breadcrumb2='会员等级';
  135. $model=new MemberModel();
  136. $data=$model->show_member_level();
  137. $member_default_levelname_info = M('config')->where( array('name' => 'member_default_levelname') )->find();
  138. $member_defualt_discount_info = M('config')->where( array('name' => 'member_defualt_discount') )->find();
  139. $default = array('id'=>'default', 'level' => 0,'levelname' => $member_default_levelname_info['value'],'discount' => $member_defualt_discount_info['value']);
  140. array_unshift($data['list'], $default );
  141. $this->assign('empty',$data['empty']);// 赋值数据集
  142. $this->assign('list',$data['list']);// 赋值数据集
  143. $this->assign('page',$data['page']);// 赋值分页输出
  144. $this->display();
  145. }
  146. public function editlevel()
  147. {
  148. $this->breadcrumb2='会员等级';
  149. $model=new MemberModel();
  150. $id = I('get.id');
  151. $member_default_levelname_info = M('config')->where( array('name' => 'member_default_levelname') )->find();
  152. $member_defualt_discount_info = M('config')->where( array('name' => 'member_defualt_discount') )->find();
  153. $default = array('id'=>'default', 'level' => 0,'levelname' => $member_default_levelname_info['value'],'discount' => $member_defualt_discount_info['value']);
  154. if( $id == 'default' )
  155. {
  156. $level = $default;
  157. }else{
  158. $level = M('member_level')->where( array('id' => $id) )->find();
  159. }
  160. if(IS_POST){
  161. $data=I('post.');
  162. $return=$model->addlevel($data);
  163. $this->osc_alert($return);
  164. }
  165. $this->level = $level;
  166. $this->display('addlevel');
  167. }
  168. public function levelconfig()
  169. {
  170. $this->breadcrumb2='会员等级';
  171. $model=new MemberModel();
  172. $member_level_is_open_info = M('config')->where( array('name' => 'member_level_is_open') )->find();
  173. if(IS_POST){
  174. $data=I('post.');
  175. $return=$model->levelconfig($data);
  176. $this->osc_alert($return);
  177. }
  178. $this->member_level_is_open_info = $member_level_is_open_info;
  179. $this->display();
  180. }
  181. public function addlevel()
  182. {
  183. $this->breadcrumb2='会员等级';
  184. $model=new MemberModel();
  185. if(IS_POST){
  186. $data=I('post.');
  187. $return=$model->addlevel($data);
  188. $this->osc_alert($return);
  189. }
  190. $this->display();
  191. }
  192. public function jiaindex(){
  193. $model=new MemberModel();
  194. $filter=I('get.');
  195. $search=array();
  196. if(isset($filter['name'])){
  197. $search['name']=$filter['name'];
  198. }
  199. $data=$model->show_jiamember_page($search);
  200. foreach($data['list'] as $key => $val)
  201. {
  202. $data['list'][$key] = $val;
  203. }
  204. $this->breadcrumb2='机器人管理';
  205. $this->assign('empty',$data['empty']);// 赋值数据集
  206. $this->assign('list',$data['list']);// 赋值数据集
  207. $this->assign('page',$data['page']);// 赋值分页输出
  208. $this->display();
  209. }
  210. public function down()
  211. {
  212. //id/1964
  213. $id = I('get.id');
  214. $type = I('get.type',1);
  215. $search = array();
  216. $search['member_id'] = $id;
  217. $search['type'] = $type;
  218. $model=new MemberModel();
  219. $data=$model->show_member_down_page($search);
  220. foreach($data['list'] as $key => $val)
  221. {
  222. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  223. if(!empty($address_info)) {
  224. $val['telephone'] = $address_info['telephone'];
  225. }
  226. $data['list'][$key] = $val;
  227. }
  228. $level = C('commiss_level_num');
  229. $this->id = $id;
  230. $this->level = $level;
  231. $this->type = $type;
  232. $this->assign('empty',$data['empty']);// 赋值数据集
  233. $this->assign('list',$data['list']);// 赋值数据集
  234. $this->assign('page',$data['page']);// 赋值分页输出
  235. $this->display();
  236. }
  237. public function jiadel()
  238. {
  239. //id/1867
  240. $id = I('get.id');
  241. M('jiauser')->where( array('id' => $id) )->delete();
  242. $return = array();
  243. $return['status'] = 'success';
  244. $return['message'] = '操作成功';
  245. $return['jump'] = U('Member/jiaindex');
  246. $this->osc_alert($return);
  247. }
  248. public function jiaadd()
  249. {
  250. if(IS_POST){
  251. $data = I('post.');
  252. $data['avatar'] = C('SITE_URL').'Uploads/image/'.$data['image'];
  253. M('jiauser')->add($data);
  254. $return = array();
  255. $return['status'] = 'success';
  256. $return['message'] = '操作成功';
  257. $return['jump'] = U('Member/jiaindex');
  258. $this->osc_alert($return);
  259. }
  260. $this->breadcrumb2='机器人管理';
  261. $this->action = U('Member/jiaadd');
  262. $this->display('jiaedit');
  263. }
  264. public function jiaedit()
  265. {
  266. if(IS_POST){
  267. $data = I('post.');
  268. $jia_info = M('jiauser')->where( array('id' => $data['id']) )->find();
  269. if( $jia_info['avatar'] == $data['image'])
  270. {
  271. }else{
  272. $data['avatar'] = C('SITE_URL').'Uploads/image/'.$data['image'];
  273. }
  274. M('jiauser')->save($data);
  275. $return = array();
  276. $return['status'] = 'success';
  277. $return['message'] = '操作成功';
  278. $return['jump'] = U('Member/jiaindex');
  279. $this->osc_alert($return);
  280. }
  281. $id = I('get.id');
  282. $jiauser = M('jiauser')->where( array('id' => $id) )->find();
  283. $this->breadcrumb2='机器人管理';
  284. $this->jiauser = $jiauser;
  285. $this->action = U('Member/jiaedit');
  286. $this->display('jiaedit');
  287. }
  288. /**
  289. 分销提现申请
  290. **/
  291. public function commissapply()
  292. {
  293. $this->breadcrumb2='分销提现申请';
  294. $model=new MemberModel();
  295. $filter=I('get.');
  296. $search=array();
  297. if(isset($filter['name'])){
  298. $search['name']=$filter['name'];
  299. }
  300. $data=$model->show_applymembercomiss_page($search);
  301. foreach($data['list'] as $key => $val)
  302. {
  303. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  304. if(!empty($address_info)) {
  305. $val['telephone'] = $address_info['telephone'];
  306. }
  307. $data['list'][$key] = $val;
  308. }
  309. $this->assign('empty',$data['empty']);// 赋值数据集
  310. $this->assign('list',$data['list']);// 赋值数据集
  311. $this->assign('page',$data['page']);// 赋值分页输出
  312. $this->display();
  313. }
  314. /**
  315. 会员积分列表
  316. **/
  317. public function integra_list()
  318. {
  319. $id = I('get.id');
  320. $member_info = M('member')->where( array('member_id' => $id) )->find();
  321. $search = array();
  322. $search['member_id'] = $id;
  323. $model= D('Seller/Integral');
  324. $data=$model->show_integra_list_page($search);
  325. $this->member_info = $member_info;
  326. $this->assign('empty',$data['empty']);// 赋值数据集
  327. $this->assign('list',$data['list']);// 赋值数据集
  328. $this->assign('page',$data['page']);// 赋值分页输出
  329. $this->display();
  330. }
  331. /**
  332. 充值积分
  333. **/
  334. public function charge_score()
  335. {
  336. $score = I('post.score');
  337. $score = intval($score);
  338. $member_id = I('post.member_id');
  339. $integral_model = D('Seller/Integral');
  340. $member_info = M('member')->field('score')->where(array('member_id'=>$member_id))->find();
  341. if($score < 0)
  342. {
  343. //系统扣除 system_add system_del
  344. //
  345. $integral_model->charge_member_score($member_id, -$score,'out', 'system_del');
  346. }else{
  347. //系统奖励
  348. //$integral_model->charge_member_score( $member_id, $score,$in_out, $type, $order_id=0)
  349. $integral_model->charge_member_score($member_id, $score,'in', 'system_add');
  350. }
  351. echo json_encode( array('code' => 0) );
  352. die();
  353. }
  354. /**
  355. 分销申请
  356. **/
  357. public function apply()
  358. {
  359. $this->breadcrumb2='分销商申请';
  360. $model=new MemberModel();
  361. $filter=I('get.');
  362. $search=array();
  363. if(isset($filter['name'])){
  364. $search['name']=$filter['name'];
  365. }
  366. $data=$model->show_applymember_page($search);
  367. foreach($data['list'] as $key => $val)
  368. {
  369. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  370. if(!empty($address_info)) {
  371. $val['telephone'] = $address_info['telephone'];
  372. }
  373. $data['list'][$key] = $val;
  374. }
  375. $this->assign('empty',$data['empty']);// 赋值数据集
  376. $this->assign('list',$data['list']);// 赋值数据集
  377. $this->assign('page',$data['page']);// 赋值分页输出
  378. $this->display();
  379. }
  380. /**
  381. * 导出会员名单
  382. */
  383. function export()
  384. {
  385. $filter=I('get.');
  386. $search=array();
  387. if(isset($filter['name'])){
  388. $search['name']=$filter['name'];
  389. }
  390. if(isset($filter['tel'])){
  391. $search['tel']=$filter['tel'];
  392. }
  393. $sql="select * from ".C('DB_PREFIX')."member where 1 ";
  394. if(isset($search['name'])){
  395. $sql.=" and uname like '%".$search['name']."%'";
  396. }
  397. if(isset($search['tel'])){
  398. $sql.=" and telephone='".$search['tel']."'";
  399. }
  400. $sql.=' order by member_id desc LIMIT 100000 ';
  401. $list = M()->query($sql);
  402. $need_data = array();
  403. foreach($list as $val)
  404. {
  405. $tmp_data = array();
  406. $tmp_data['member_id'] = $val['member_id'];
  407. $tmp_data['openid'] = $val['openid'];
  408. $tmp_data['name'] = $val['name'];
  409. $tmp_data['telephone'] = ' ';
  410. $tmp_data['address_name'] = '未填写';
  411. $tmp_data['province'] = '未填写';
  412. $tmp_data['city'] = '未填写';
  413. $tmp_data['country'] = '未填写';
  414. $tmp_data['address'] = '未填写';
  415. $address_info = M('address')->where( array('member_id' => $val['member_id']) )->order('is_default desc')->find();
  416. if(!empty($address_info)) {
  417. $province_info = M('area')->where( array('area_id' => $address_info['province_id']) )->find();
  418. if(!empty($province_info)) {
  419. $tmp_data['province'] = $province_info['area_name'];
  420. }
  421. $city_info = M('area')->where( array('area_id' => $address_info['city_id']) )->find();
  422. if(!empty($city_info)) {
  423. $tmp_data['city'] = $city_info['area_name'];
  424. }
  425. $country_info = M('area')->where( array('area_id' => $address_info['country_id']) )->find();
  426. if(!empty($country_info)) {
  427. $tmp_data['country'] = $country_info['area_name'];
  428. }
  429. $tmp_data['telephone'] = ' '.$address_info['telephone'];
  430. $tmp_data['address_name'] = $address_info['name'];
  431. $tmp_data['address'] = $address_info['address'];
  432. }
  433. $need_data[] = $tmp_data;
  434. }
  435. $xlsCell = array(
  436. array('member_id','会员ID'),
  437. array('openid','OPENID'),
  438. array('name','昵称'),
  439. array('address_name','收件人姓名'),
  440. array('telephone','联系电话'),
  441. array('province','省份'),
  442. array('city','城市'),
  443. array('country','区 '),
  444. array('address','详细地址 ')
  445. );
  446. $expTitle = '会员信息_'.date('Y-m-d H:i:s');
  447. export_excel($expTitle,$xlsCell,$need_data);
  448. }
  449. /**
  450. 升级成为分销商
  451. **/
  452. function fencommiss()
  453. {
  454. $id = I('get.id');
  455. M('member')->where( array('member_id' => $id) )->save( array('comsiss_flag' => 1) );
  456. $member_commiss = M('member_commiss')->where( array('member_id' => $id) )->find();
  457. if(empty($member_commiss))
  458. {
  459. $data = array();
  460. $data['member_id'] = $id;
  461. $data['money'] = 0;
  462. $data['dongmoney'] = 0;
  463. $data['getmoney'] = 0;
  464. M('member_commiss')->add($data);
  465. }
  466. $return = array();
  467. $return['status'] = 'success';
  468. $return['message'] = '操作成功';
  469. $return['jump'] = U('Member/apply');
  470. $this->osc_alert($return);
  471. }
  472. //'{:U("Member/commissmoneyapply",array("id"=>$m["member_id"],"aid" => $m["id"], "state" => 1))}' >
  473. /**
  474. 分佣提现申请
  475. **/
  476. function commissmoneyapply()
  477. {
  478. $aid = I('get.aid',0);
  479. $id = I('get.id',0);
  480. $state = I('get.state',0,'intval');
  481. $member_commiss = M('member_commiss')->where( array('member_id' => $id) )->find();
  482. $tixian_order = M('tixian_order')->where( array('id' => $aid) )->find();
  483. if($state == 1)
  484. {
  485. //money dongmoney getmoney
  486. $data = array();
  487. $data['getmoney'] = $member_commiss['getmoney'] + $tixian_order['money'];
  488. $data['dongmoney'] = $member_commiss['dongmoney'] - $tixian_order['money'];
  489. M('member_commiss')->where( array('member_id' => $id) )->save($data);
  490. M('tixian_order')->where( array('id' => $aid) )->save( array('state' => 1,'shentime' => time()) );
  491. } else if($state == 2){
  492. $data = array();
  493. $data['money'] = $member_commiss['money'] + $tixian_order['money'];
  494. $data['dongmoney'] = $member_commiss['dongmoney'] - $tixian_order['money'];
  495. M('member_commiss')->where( array('member_id' => $id) )->save($data);
  496. M('tixian_order')->where( array('id' => $aid) )->save( array('state' => 2,'shentime' => time()) );
  497. }
  498. $return = array();
  499. $return['status'] = 'success';
  500. $return['message'] = '操作成功';
  501. $return['jump'] = U('Member/commissapply');
  502. $this->osc_alert($return);
  503. }
  504. function fencommissapply()
  505. {
  506. $aid = I('get.aid',0);
  507. $id = I('get.id',0);
  508. M('member_commiss_apply')->where( array('id' => $aid) )->save( array('state' => 1) );
  509. M('member')->where( array('member_id' => $id) )->save( array('comsiss_flag' => 1) );
  510. $member_commiss = M('member_commiss')->where( array('member_id' => $id) )->find();
  511. if(empty($member_commiss))
  512. {
  513. $data = array();
  514. $data['member_id'] = $id;
  515. $data['money'] = 0;
  516. $data['dongmoney'] = 0;
  517. $data['getmoney'] = 0;
  518. M('member_commiss')->add($data);
  519. }
  520. $return = array();
  521. $return['status'] = 'success';
  522. $return['message'] = '操作成功';
  523. $return['jump'] = U('Member/apply');
  524. $this->osc_alert($return);
  525. }
  526. function add(){
  527. $model=new MemberModel();
  528. if(IS_POST){
  529. $data=I('post.');
  530. $return=$model->add_member($data);
  531. $this->osc_alert($return);
  532. }
  533. $this->crumbs='新增';
  534. $this->display();
  535. }
  536. function info(){
  537. $model=new MemberModel();
  538. if(IS_POST){
  539. $data=I('post.');
  540. $return=$model->edit_info($data);
  541. $this->osc_alert($return);
  542. }
  543. $this->crumbs='编辑';
  544. $this->action=U('Member/info');
  545. $this->data=$model->info(I('id'));
  546. $level_list=$model->show_member_level();
  547. $member_default_levelname_info = M('config')->where( array('name' => 'member_default_levelname') )->find();
  548. $member_defualt_discount_info = M('config')->where( array('name' => 'member_defualt_discount') )->find();
  549. $default = array('id'=>'0', 'level' => 0,'levelname' => $member_default_levelname_info['value'],'discount' => $member_defualt_discount_info['value']);
  550. array_unshift($level_list['list'], $default );
  551. $this->level_list_data = $level_list['list'];
  552. $this->display();
  553. }
  554. }
  555. ?>