UserController.class.php 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  1. <?php
  2. /**
  3. * 本破解程序由三岁半资源网提供
  4. * 三岁半资源网www.sansuib.com
  5. * QQ:89171639 承接网站建设、公众号搭建、小程序建设、企业网站
  6. */
  7. namespace Seller\Controller;
  8. class UserController extends CommonController{
  9. public function index()
  10. {
  11. $condition = '';
  12. $gpc = I('request.');
  13. $this->gpc = $gpc;
  14. $pindex = I('request.page', 1);
  15. $psize = 20;
  16. $keyword = I('request.keyword');
  17. $this->keyword = $keyword;
  18. if (!empty($keyword)) {
  19. $condition .= ' and username like '.'"%' . $keyword . '%"';
  20. }
  21. $level_id = I('request.level_id',0);
  22. if( isset($level_id) && !empty($level_id) )
  23. {
  24. if($level_id == 'default')
  25. {
  26. $level_id = 0;
  27. }
  28. $condition .= ' and level_id = '.$level_id;
  29. }
  30. $this->level_id = $level_id;
  31. $groupid = I('request.groupid');
  32. $this->groupid = $groupid;
  33. //groupid/default
  34. if( isset($groupid) && !empty($groupid) && $groupid != 'default' )
  35. {
  36. $condition .= ' and groupid = '.$groupid;
  37. }
  38. $list = M()->query('SELECT * FROM ' .C('DB_PREFIX') . "lionfish_comshop_member \r\n
  39. WHERE 1=1 " . $condition . ' order by member_id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  40. $total = M('lionfish_comshop_member')->where("1=1 ". $condition )->count();
  41. $level_list = M('lionfish_comshop_member_level')->order('level asc')->select();
  42. $keys_level = array();
  43. foreach($level_list as $vv)
  44. {
  45. $keys_level[$vv['id']] = $vv['levelname'];
  46. }
  47. $this->level_list = $level_list;
  48. $group_list = M('lionfish_comshop_member_group')->order('id asc')->select();
  49. $keys_group = array();
  50. if( !empty($group_list) )
  51. {
  52. foreach($group_list as $vv)
  53. {
  54. $keys_group[$vv['id']] = $vv['groupname'];
  55. }
  56. }
  57. $this->group_list = $group_list;
  58. foreach( $list as $key => $val )
  59. {
  60. //ims_ lionfish_comshop_order 1 2 4 6 11
  61. $ordercount = M('lionfish_comshop_order')->where( array('order_status_id' => array('in','1,2,4,6,11,14,12,13'),'member_id' => $val['member_id'] ) )->count();
  62. $ordermoney = M('lionfish_comshop_order')->where( array('order_status_id' => array('in','1,2,4,6,11,14,12,13'),'member_id' => $val['member_id']) )->sum('total');
  63. if(empty($val['share_id'] )){
  64. $share_name['username'] = 0 ;
  65. }else{
  66. $share_name = M('lionfish_comshop_member')->where( array('member_id' => $val['share_id'] ) )->find();
  67. }
  68. // lionfish_community_history
  69. $community_history = M('lionfish_community_history')->field('head_id')->where( array('member_id' => $val['member_id'] ) )->order('addtime desc')->find();
  70. if( !empty($community_history) )
  71. {
  72. $cur_community_info = M('lionfish_community_head')->where( array('id' => $community_history['head_id'] ) )->find();
  73. $val['cur_communityname'] = $cur_community_info['community_name'];
  74. } else{
  75. $val['cur_communityname'] = '无';
  76. }
  77. $val['levelname'] = empty($val['level_id']) ? '普通会员':$keys_level[$val['level_id']];
  78. $val['groupname'] = empty($val['groupid']) ? '默认分组':$keys_group[$val['groupid']];
  79. $has_shopinfo = M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $val['member_id']) )->find();
  80. if( !empty($has_shopinfo) )
  81. {
  82. $val['has_shopinfo'] = $has_shopinfo;
  83. }else{
  84. $val['has_shopinfo'] = array();
  85. }
  86. $val['ordercount'] = $ordercount;
  87. $val['ordermoney'] = $ordermoney;
  88. $val['share_name'] = $share_name['username'];
  89. $list[$key] = $val;
  90. }
  91. $is_get_formdata = D('Home/Front')->get_config_by_name('is_get_formdata');
  92. $this->is_get_formdata = $is_get_formdata;
  93. $pager = pagination2($total, $pindex, $psize);
  94. $this->pager = $pager;
  95. $this->list = $list;
  96. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  97. if( empty($commiss_level) )
  98. {
  99. $commiss_level = 0;
  100. }
  101. $this->commiss_level = $commiss_level;
  102. $this->display();
  103. }
  104. public function shopinfo()
  105. {
  106. $member_id = I('get.id');
  107. $shop_info = M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $member_id ) )->find();
  108. $level_list = M('lionfish_comshop_member_level')->order('level asc ')->select();
  109. if( !empty($shop_info['imggroup']) )
  110. {
  111. $shop_info['imggroup'] = explode(',' , $shop_info['imggroup']);
  112. }
  113. if( !empty($shop_info['otherimggroup']) )
  114. {
  115. $shop_info['otherimggroup'] = explode(',' , $shop_info['otherimggroup']);
  116. }
  117. $this->shop_info = $shop_info;
  118. $this->member_id = $member_id;
  119. $list = array(
  120. array('id' => 'default', 'level_money'=>'0','discount'=>'100' ,'level'=>0,'levelname' => '普通会员',
  121. 'membercount' => $membercount ) );
  122. if( empty($level_list) )
  123. {
  124. $level_list = array();
  125. }
  126. //$level_list = array_merge($list, $level_list);
  127. $this->level_list = $level_list;
  128. $this->display();
  129. }
  130. public function chose_community()
  131. {
  132. $_GPC = I('request.');
  133. $member_id = $_GPC['s_member_id'];
  134. $head_id = $_GPC['head_id'];
  135. D('Seller/community')->in_community_history($member_id, $head_id);
  136. //load_model_class('community')->in_community_history($member_id, $head_id);
  137. echo json_encode( array('code' => 0) );
  138. die();
  139. }
  140. public function lvconfig ()
  141. {
  142. $_GPC = I('request.');
  143. if (IS_POST) {
  144. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  145. D('Seller/Config')->update($data);
  146. show_json(1);
  147. }
  148. $data = D('Seller/Config')->get_all_config();
  149. $this->display();
  150. }
  151. public function recharge_flow ()
  152. {
  153. $_GPC = I('request.');
  154. $member_id = $_GPC['id'];
  155. $condition = ' and member_id='.$member_id.' and state >0 ';
  156. $pindex = max(1, intval($_GPC['page']));
  157. $psize = 20;
  158. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_member_charge_flow \r\n
  159. WHERE 1 " . $condition . ' order by id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize );
  160. $total_arr = M()->query('SELECT count(id) as count FROM ' . C('DB_PREFIX') . 'lionfish_comshop_member_charge_flow WHERE 1 ' . $condition );
  161. $total = $total_arr[0]['count'];
  162. foreach( $list as $key => $val )
  163. {
  164. $val['add_time'] = date('Y-m-d H:i:s',$val['add_time'] );
  165. if($val['state'] == 3 || $val['state'] == 4)
  166. {
  167. $od_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $val['trans_id'] ) )->find();
  168. if( !empty($od_info) )
  169. {
  170. $val['trans_id'] = $od_info['order_num_alias'];
  171. }
  172. }
  173. $list[$key] = $val;
  174. }
  175. $pager = pagination2($total, $pindex, $psize);
  176. $this->list = $list;
  177. $this->pager = $pager;
  178. $this->display();
  179. }
  180. public function integral_flow ()
  181. {
  182. $_GPC = I('request.');
  183. $member_id = $_GPC['id'];
  184. $condition = ' and member_id='.$member_id.' and type >0 ';
  185. $pindex = max(1, intval($_GPC['page']));
  186. $psize = 20;
  187. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_member_integral_flow
  188. WHERE 1 " . $condition . ' order by id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize );
  189. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member_integral_flow WHERE 1 ' . $condition );
  190. $total = $total_arr[0]['count'];
  191. foreach( $list as $key => $val )
  192. {
  193. $val['add_time'] = date('Y-m-d H:i:s',$val['add_time'] );
  194. if($val['type'] == 'goodsbuy' || $val['type'] == 'refundorder' || $val['type'] == 'orderbuy')
  195. {
  196. $od_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $val['order_id'] ) )->find();
  197. if( !empty($od_info) )
  198. {
  199. $val['order_id'] = $od_info['order_num_alias'];
  200. }
  201. }
  202. $list[$key] = $val;
  203. }
  204. $pager = pagination2($total, $pindex, $psize);
  205. $this->list = $list;
  206. $this->pager = $pager;
  207. $this->display();
  208. }
  209. public function editshopinfo()
  210. {
  211. $post_data = I('post.');
  212. $up_data = array();
  213. $up_data['shop_name'] = $post_data['shop_name'];
  214. $up_data['shop_mobile'] = $post_data['shop_mobile'];
  215. $up_data['state'] = $post_data['state'];
  216. M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $post_data['member_id'] ) )->save($up_data);
  217. //oscshop_ lionfish_comshop_member_shopinfo
  218. if($post_data['state'] == 1)
  219. {
  220. M('lionfish_comshop_member')->where( array('member_id' =>$post_data['member_id'] ) )->save( array('level_id' => $post_data['level_id'] ) );
  221. }
  222. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  223. }
  224. //user.changelevel
  225. public function changelevel()
  226. {
  227. $_GPC = I('request.');
  228. $level = $_GPC['level'];
  229. $ids_arr = $_GPC['ids'];
  230. $toggle = $_GPC['toggle'];
  231. $ids = implode(',', $ids_arr);
  232. if($toggle == 'group')
  233. {
  234. M('lionfish_comshop_member')->where( "member_id in ({$ids})" )->save( array('groupid' => $level ) );
  235. }else if($toggle == 'level'){
  236. M('lionfish_comshop_member')->where( "member_id in ({$ids})" )->save( array('level_id' =>$level ) );
  237. }
  238. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  239. }
  240. public function config()
  241. {
  242. if (IS_POST) {
  243. $data = I('request.data');
  244. D('Seller/Config')->update($data);
  245. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  246. }
  247. $data = D('Seller/Config')->get_all_config();
  248. $this->data = $data;
  249. $this->display();
  250. }
  251. public function usergroup()
  252. {
  253. $_GPC = I('request.');
  254. $membercount = M('lionfish_comshop_member')->where( array('groupid' => 0) )->count();
  255. $list = array(
  256. array('id' => 'default', 'groupname' => '默认分组',
  257. 'membercount' => $membercount )
  258. );
  259. $condition = ' ';
  260. $params = array(':uniacid' => $_W['uniacid']);
  261. $keyword= '';
  262. if (!(empty($_GPC['keyword']))) {
  263. $_GPC['keyword'] = trim($_GPC['keyword']);
  264. $condition .= ' and ( groupname like "%'.$_GPC['keyword'].'%")';
  265. $keyword = $_GPC['keyword'];
  266. }
  267. $alllist = M('lionfish_comshop_member_group')->where( '1'. $condition )->order('id asc')->select();
  268. foreach ($alllist as &$row ) {
  269. $membercount_arr = M()->query('select count(*) as count from ' . C('DB_PREFIX') .
  270. 'lionfish_comshop_member where groupid='.$row['id'].' ');
  271. $row['membercount'] = $membercount_arr[0]['count'];
  272. }
  273. unset($row);
  274. if (empty($_GPC['keyword'])) {
  275. $list = array_merge($list, $alllist);
  276. }
  277. else {
  278. $list = $alllist;
  279. }
  280. $this->keyword = $keyword;
  281. $this->list = $list;
  282. $this->display();
  283. }
  284. public function user()
  285. {
  286. }
  287. public function userjia()
  288. {
  289. $_GPC = I('request.');
  290. $condition = '1';
  291. $pindex = max(1, intval($_GPC['page']));
  292. $psize = 20;
  293. if (!empty($_GPC['keyword'])) {
  294. $_GPC['keyword'] = trim($_GPC['keyword']);
  295. $condition .= ' and username like "%' . $_GPC['keyword'] . '%"';
  296. }
  297. $list = M('lionfish_comshop_jiauser')->where( $condition )->order('id desc ')->limit( (($pindex - 1) * $psize) . ',' . $psize )->select();
  298. $total = M('lionfish_comshop_jiauser')->where($condition)->count();
  299. $pager = pagination2($total, $pindex, $psize);
  300. $this->list = $list;
  301. $this->pager = $pager;
  302. $this->gpc = $_GPC;
  303. $this->display();
  304. }
  305. public function userlevel()
  306. {
  307. $_GPC = I('request.');
  308. $membercount = M('lionfish_comshop_member')->where( array('level_id' => 0) )->count();
  309. $list = array(
  310. array('id' => 'default', 'level_money'=>'0','discount'=>'100' ,'level'=>0,'levelname' => '普通会员',
  311. 'membercount' => $membercount ) );
  312. $condition = ' 1 ';
  313. if (!(empty($_GPC['keyword']))) {
  314. $_GPC['keyword'] = trim($_GPC['keyword']);
  315. $condition .= ' and ( levelname like "%'.$_GPC['keyword'].'%" )';
  316. }
  317. $alllist = M('lionfish_comshop_member_level')->where( $condition )->order('id asc')->select();
  318. foreach ($alllist as &$row ) {
  319. $row['membercount'] = M('lionfish_comshop_member')->where( "find_in_set(".$row['id'].",level_id)" )->count();
  320. }
  321. unset($row);
  322. if (empty($_GPC['keyword'])) {
  323. if( empty($alllist) )
  324. {
  325. $alllist = array();
  326. }
  327. $list = array_merge($list, $alllist);
  328. }
  329. else {
  330. $list = $alllist;
  331. }
  332. $this->gpc = $_GPC;
  333. $this->list = $list;
  334. $this->display();
  335. }
  336. public function adduserlevel()
  337. {
  338. $_GPC = I('request.');
  339. //ims_
  340. $id = intval($_GPC['id']);
  341. $group = M('lionfish_comshop_member_level')->where( array('id' => $id ) )->find();
  342. if (IS_POST) {
  343. $data = array('logo' => trim($_GPC['logo']),'discount' => trim($_GPC['discount']),'level_money' => trim($_GPC['level_money']),'levelname' => trim($_GPC['levelname']),
  344. 'level' => trim($_GPC['level']), 'is_auto_grade' => $_GPC['is_auto_grade'] );
  345. if (!(empty($id))) {
  346. M('lionfish_comshop_member_level')->where(array('id' => $id))->save( $data );
  347. }
  348. else {
  349. $id = M('lionfish_comshop_member_level')->add( $data );
  350. }
  351. show_json(1, array('url' => U('user/userlevel', array('op' => 'display'))));
  352. }
  353. $this->id = $id;
  354. $this->gpc = $_GPC;
  355. $this->group = $group;
  356. $this->display();
  357. }
  358. public function adduserjia()
  359. {
  360. $_GPC = I('request.');
  361. $id = intval($_GPC['id']);
  362. $group = array();
  363. if( $id > 0 )
  364. {
  365. $group = M('lionfish_comshop_jiauser')->where( array('id' => $id) )->find();
  366. }
  367. if (IS_POST) {
  368. $data = array('avatar' => trim($_GPC['avatar']),
  369. 'username' => trim($_GPC['username']),'mobile' => trim($_GPC['mobile']) );
  370. if (!(empty($id))) {
  371. M('lionfish_comshop_jiauser')->where( array('id' => $id) )->save( $data );
  372. }
  373. else {
  374. $id = M('lionfish_comshop_jiauser')->add($data);
  375. }
  376. show_json(1, array('url' => U('user/userjia', array('op' => 'display'))));
  377. }
  378. $this->group = $group;
  379. $this->display();
  380. }
  381. //--begin
  382. public function zhenquery_commission()
  383. {
  384. $_GPC = I('request.');
  385. $kwd = trim($_GPC['keyword']);
  386. $is_not_hexiao = isset($_GPC['is_not_hexiao']) ? intval($_GPC['is_not_hexiao']):0;
  387. $is_ajax = isset($_GPC['is_ajax']) ? intval($_GPC['is_ajax']) : 0;
  388. $this->kwd = $kwd;
  389. $this->is_not_hexiao = $is_not_hexiao;
  390. $this->is_ajax = $is_ajax;
  391. $condition = ' and comsiss_flag=1 and comsiss_state=1 ';
  392. if (!empty($kwd)) {
  393. $condition .= ' AND ( `username` LIKE "%'.$kwd.'%" or `telephone` like "%'.$kwd.'%" )';
  394. }
  395. if( $is_not_hexiao == 1 )
  396. {
  397. $condition .= " and pickup_id= 0 ";
  398. }
  399. /**
  400. 分页开始
  401. **/
  402. $page = isset($_GPC['page']) ? intval($_GPC['page']) : 1;
  403. $page = max(1, $page);
  404. $page_size = 10;
  405. /**
  406. 分页结束
  407. **/
  408. $ds = M()->query('SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member WHERE 1 ' . $condition .
  409. ' order by member_id asc' .' limit ' . (($page - 1) * $page_size) . ',' . $page_size );
  410. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX') .
  411. 'lionfish_comshop_member WHERE 1 ' . $condition );
  412. $total = $total_arr[0]['count'];
  413. foreach ($ds as &$value) {
  414. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  415. $value['id'] = $value['member_id'];
  416. if($is_ajax == 1)
  417. {
  418. $ret_html .= '<tr>';
  419. $ret_html .= ' <td><img src="'.$value['avatar'].'" style="width:30px;height:30px;padding1px;border:1px solid #ccc" />'. $value['nickname'].'</td>';
  420. $ret_html .= ' <td>'.$value['mobile'].'</td>';
  421. $ret_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td>';
  422. $ret_html .= '</tr>';
  423. }
  424. }
  425. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  426. if( $is_ajax == 1 )
  427. {
  428. echo json_encode( array('code' => 0, 'html' => $ret_html,'pager' => $pager) );
  429. die();
  430. }
  431. unset($value);
  432. if ($_GPC['suggest']) {
  433. exit(json_encode(array('value' => $ds)));
  434. }
  435. $this->pager = $pager;
  436. $this->ds = $ds;
  437. $this->display('User/query_commission');
  438. }
  439. public function zhenquery()
  440. {
  441. $_GPC = I('request.');
  442. $kwd = trim($_GPC['keyword']);
  443. $is_not_hexiao = isset($_GPC['is_not_hexiao']) ? intval($_GPC['is_not_hexiao']):0;
  444. $is_ajax = isset($_GPC['is_ajax']) ? intval($_GPC['is_ajax']) : 0;
  445. $limit = isset($_GPC['limit']) ? intval($_GPC['limit']) : 0;
  446. $condition = ' ';
  447. if (!empty($kwd)) {
  448. $condition .= ' AND ( `username` LIKE "%'.$kwd.'%" or `telephone` like "%'.$kwd.'%" )';
  449. }
  450. if( $is_not_hexiao == 1 )
  451. {
  452. $condition .= " and pickup_id= 0 ";
  453. }
  454. /**
  455. 分页开始
  456. **/
  457. $page = isset($_GPC['page']) ? intval($_GPC['page']) : 1;
  458. $page = max(1, $page);
  459. $page_size = 10;
  460. /**
  461. 分页结束
  462. **/
  463. $sql ='SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member WHERE 1 ' . $condition .' order by member_id asc' .' limit ' . (($page - 1) * $page_size) . ',' . $page_size ;
  464. $ds = M()->query($sql);
  465. $total = M('lionfish_comshop_member')->where( '1 ' . $condition )->count();
  466. foreach ($ds as &$value) {
  467. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  468. $value['id'] = $value['member_id'];
  469. //判断该会员是否已经是团长
  470. if($limit == 1)
  471. {
  472. $value['exist'] = M('lionfish_community_head')->where( array('member_id' => $value['id'] ) )->count();
  473. }else{
  474. $value['exist'] = 0;
  475. }
  476. if($is_ajax == 1)
  477. {
  478. $ret_html .= '<tr>';
  479. $ret_html .= ' <td><img src="'.$value['avatar'].'" style="width:30px;height:30px;padding1px;border:1px solid #ccc" />'. $value['nickname'].'</td>';
  480. $ret_html .= ' <td>'.$value['mobile'].'</td>';
  481. if(!empty($value['exist'])){
  482. $ret_html .= '<td style="width:80px;border:#ccc">选择</td>';
  483. }else{
  484. $ret_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td>';
  485. }
  486. $ret_html .= '</tr>';
  487. }
  488. }
  489. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  490. if( $is_ajax == 1 )
  491. {
  492. echo json_encode( array('code' => 0, 'html' => $ret_html,'pager' => $pager) );
  493. die();
  494. }
  495. unset($value);
  496. if ($_GPC['suggest']) {
  497. exit(json_encode(array('value' => $ds)));
  498. }
  499. $this->ds = $ds;
  500. $this->pager = $pager;
  501. $this->display('User/query');
  502. }
  503. //--end
  504. public function zhenquery_many()
  505. {
  506. $_GPC = I('request.');
  507. $kwd = trim($_GPC['keyword']);
  508. $is_not_hexiao = isset($_GPC['is_not_hexiao']) ? intval($_GPC['is_not_hexiao']):0;
  509. $is_ajax = isset($_GPC['is_ajax']) ? intval($_GPC['is_ajax']) : 0;
  510. $this->_GPC = $_GPC;
  511. $this->kwd = $kwd;
  512. $condition = ' ';
  513. if (!empty($kwd)) {
  514. $condition .= ' AND ( `username` LIKE "%'.$kwd.'%" or `telephone` like "%'.$kwd.'%" )';
  515. }
  516. if( $is_not_hexiao == 1 )
  517. {
  518. $condition .= " and pickup_id= 0 ";
  519. }
  520. /**
  521. 分页开始
  522. **/
  523. $page = isset($_GPC['page']) ? intval($_GPC['page']) : 1;
  524. $page = max(1, $page);
  525. $page_size = 10;
  526. /**
  527. 分页结束
  528. **/
  529. $ds = M()->query('SELECT * FROM ' . C('DB_PREFIX') . 'lionfish_comshop_member WHERE 1 ' . $condition .
  530. ' order by member_id asc' .' limit ' . (($page - 1) * $page_size) . ',' . $page_size );
  531. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX').'lionfish_comshop_member WHERE 1 ' . $condition );
  532. $total = $total_arr[0]['count'];
  533. foreach ($ds as &$value) {
  534. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  535. $value['id'] = $value['member_id'];
  536. if($is_ajax == 1)
  537. {
  538. $ret_html .= '<tr>';
  539. $ret_html .= ' <td><img src="'.$value['avatar'].'" style="width:30px;height:30px;padding1px;border:1px solid #ccc" />'. $value['nickname'].'</td>';
  540. $ret_html .= ' <td>'.$value['mobile'].'</td>';
  541. $ret_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td>';
  542. $ret_html .= '</tr>';
  543. }
  544. }
  545. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  546. if( $is_ajax == 1 )
  547. {
  548. echo json_encode( array('code' => 0, 'html' => $ret_html,'pager' => $pager) );
  549. die();
  550. }
  551. unset($value);
  552. if ($_GPC['suggest']) {
  553. exit(json_encode(array('value' => $ds)));
  554. }
  555. $this->ds = $ds;
  556. $this->pager;
  557. $this->display();
  558. }
  559. public function query()
  560. {
  561. $kwd = I('request.keyword','');
  562. $condition = ' 1 ';
  563. if (!empty($kwd)) {
  564. $condition .= ' AND ( `username` LIKE '.'"%' . $kwd . '%"'.' )';
  565. }
  566. $ds = M('lionfish_comshop_jiauser')->where( $condition )->select();
  567. $s_html = "";
  568. foreach ($ds as &$value) {
  569. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  570. $value['avatar'] = tomedia($value['avatar']);
  571. $value['member_id'] = ($value['id']);
  572. $s_html .= "<tr><td><img src='".$value['avatar']."' style='width:30px;height:30px;padding1px;border:1px solid #ccc' /> {$value[nickname]}</td>";
  573. $s_html .= "<td>{$value['mobile']}</td>";
  574. $s_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td></tr>';
  575. }
  576. unset($value);
  577. if( isset($_GPC['is_ajax']) )
  578. {
  579. echo json_encode( array('code' =>0, 'html' => $s_html) );
  580. die();
  581. }
  582. $url = 'user/query';
  583. $this->url = $url;
  584. $this->ds = $ds;
  585. $this->display();
  586. }
  587. public function addusergroup()
  588. {
  589. $_GPC = I('request.');
  590. $id = intval($_GPC['id']);
  591. if( $id >0 )
  592. {
  593. $group = M('lionfish_comshop_member_group')->where( array('id' => $id ) )->find();
  594. $this->group = $group;
  595. }
  596. if (IS_POST) {
  597. $data = array( 'groupname' => trim($_GPC['groupname']) );
  598. if (!(empty($id))) {
  599. M('lionfish_comshop_member_group')->where( array('id' => $id) )->save($data);
  600. }
  601. else {
  602. $id = M('lionfish_comshop_member_group')->add( $data );
  603. }
  604. show_json(1, array('url' => U('user/usergroup', array('op' => 'display'))));
  605. }
  606. include $this->display();
  607. }
  608. public function recharge()
  609. {
  610. $_GPC = I('request.');
  611. $type = trim($_GPC['type']);
  612. if( empty($type) )
  613. {
  614. $type = 'score';
  615. }
  616. $id = intval($_GPC['id']);
  617. $profile = M('lionfish_comshop_member')->where( array('member_id' => $id) )->find();
  618. if (IS_POST) {
  619. $typestr = ($type == 'score' ? '积分' : '余额');
  620. $num = floatval($_GPC['num']);
  621. $remark = trim($_GPC['remark']);
  622. if ($num <= 0) {
  623. show_json(0, array('message' => '请填写大于0的数字!'));
  624. }
  625. $changetype = intval($_GPC['changetype']);
  626. if ($type == 'score') {
  627. //0 增加 1 减少 2 最终积分
  628. $ch_type = 'system_add';
  629. if($changetype == 1 )
  630. {
  631. $ch_type = 'system_del';
  632. }
  633. D('Seller/User')->sendMemberPointChange($profile['member_id'], $num, $changetype, $remark, $ch_type);
  634. //D('Seller/User')->sendMemberPointChange($profile['member_id'], $num, $changetype, $remark);
  635. }
  636. if ($type == 'account_money') {
  637. D('Seller/User')->sendMemberMoneyChange($profile['member_id'], $num, $changetype, $remark);
  638. }
  639. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  640. }
  641. $this->profile = $profile;
  642. $this->id = $id;
  643. $this->type = $type;
  644. $this->gpc = $_GPC;
  645. $this->display();
  646. }
  647. public function detail()
  648. {
  649. $id = I('request.id');
  650. $_GPC = I('request.');
  651. $is_showform = I('request.is_showform',0);
  652. $member = M('lionfish_comshop_member')->where( array('member_id' => $id) )->find();
  653. $ordercount = M('lionfish_comshop_order')->where( 'order_status_id in(1,2,4,6,11,14,12,13) and member_id='.$id )->count();
  654. $ordermoney = M('lionfish_comshop_order')->where( 'order_status_id in(1,2,4,6,11,14,12,13) and member_id='.$id )->sum('total');
  655. $member['self_ordercount'] = $ordercount;
  656. $member['self_ordermoney'] = $ordermoney;
  657. //commiss_formcontent is_writecommiss_form
  658. if( $member['is_writecommiss_form'] == 1 )
  659. {
  660. $member['commiss_formcontent'] = unserialize($member['commiss_formcontent']);
  661. }
  662. if (IS_POST) {
  663. $data = I('request.data');
  664. if($member['is_writecommiss_form'] == 1)
  665. {
  666. $commiss_formcontent_data = array();
  667. foreach( $member['commiss_formcontent'] as $val )
  668. {
  669. $key = $val['name'].'_'.$val['type'];
  670. if( isset($_GPC[$key]) )
  671. {
  672. $commiss_formcontent_data[] = array('type' => 'text','name' => $val['name'], 'value' => $_GPC[$key] );
  673. }
  674. $data['commiss_formcontent'] = serialize($commiss_formcontent_data);
  675. }
  676. }
  677. if( $commiss_level > 0 )
  678. {
  679. if( $id == $data['agentid'] )
  680. {
  681. show_json(0, array('message' => '不能选择自己为上级分销商'));
  682. }
  683. }
  684. M('lionfish_comshop_member')->where( array('member_id' => $id) )->save($data);
  685. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  686. }
  687. $this->member = $member;
  688. $level_list = M('lionfish_comshop_member_level')->order('level asc')->select();
  689. $keys_level = array();
  690. foreach($level_list as $vv)
  691. {
  692. $keys_level[$vv['id']] = $vv['levelname'];
  693. }
  694. $this->level_list = $level_list;
  695. $group_list = M('lionfish_comshop_member_group')->order('id asc')->select();
  696. $keys_group = array();
  697. if( !empty($group_list) )
  698. {
  699. foreach($group_list as $vv)
  700. {
  701. $keys_group[$vv['id']] = $vv['groupname'];
  702. }
  703. }
  704. $this->group_list = $group_list;
  705. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  706. if( empty($commiss_level) )
  707. {
  708. $commiss_level = 0;
  709. }
  710. $this->commiss_level = $commiss_level;
  711. foreach( $list as $key => $val )
  712. {
  713. //ims_ lionfish_comshop_order 1 2 4 6 11
  714. $ordercount = M('lionfish_comshop_order')->where( array('member_id' => $val['member_id'] ) )->count();
  715. $ordermoney = M('lionfish_comshop_order')->where( array('order_status_id' => array('in','1,2,4,6,11,14,12,13'),'member_id' => $val['member_id']) )->sum('total');
  716. $val['levelname'] = empty($val['level_id']) ? '普通会员':$keys_level[$val['level_id']];
  717. $val['groupname'] = empty($val['groupid']) ? '默认分组':$keys_group[$val['groupid']];
  718. $has_shopinfo = M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $val['member_id']) )->find();
  719. if( !empty($has_shopinfo) )
  720. {
  721. $val['has_shopinfo'] = $has_shopinfo;
  722. }else{
  723. $val['has_shopinfo'] = array();
  724. }
  725. $val['ordercount'] = $ordercount;
  726. $val['ordermoney'] = $ordermoney;
  727. $list[$key] = $val;
  728. }
  729. $saler = array();
  730. //saler
  731. if( $member['agentid'] > 0 )
  732. {
  733. $saler = M('lionfish_comshop_member')->field('avatar,username as nickname,member_id')->where( array('member_id' => $member['agentid'] ) )->find();
  734. }
  735. $this->saler = $saler;
  736. $this->display();
  737. }
  738. public function deleteuserlevel()
  739. {
  740. $_GPC = I('request.');
  741. $id = intval($_GPC['id']);
  742. if (empty($id)) {
  743. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  744. }
  745. $items = M('lionfish_comshop_member_level')->field('id')->where( ' id in( ' . $id . ' ) ' )->select();
  746. foreach ($items as $item ) {
  747. M('lionfish_comshop_member')->where( array('level_id' => $item['id']) )->save( array('level_id' => 0) );
  748. M('lionfish_comshop_member_level')->where( array('id' => $item['id']) )->delete();
  749. }
  750. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  751. }
  752. public function deleteuser()
  753. {
  754. $id = I('request.id');
  755. if (empty($id)) {
  756. $ids = I('request.ids');
  757. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  758. }
  759. $items = M('lionfish_comshop_member')->field('member_id')->where( array('member_id' => array('in', $id)) )->select();
  760. foreach ($items as $item ) {
  761. M('lionfish_comshop_member')->where( array('member_id' => $item['member_id']) )->delete();
  762. }
  763. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  764. }
  765. public function deleteuserjia()
  766. {
  767. $_GPC = I('request.');
  768. $id = intval($_GPC['id']);
  769. if (empty($id)) {
  770. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  771. }
  772. $items = M('lionfish_comshop_jiauser')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  773. foreach ($items as $item ) {
  774. M('lionfish_comshop_jiauser')->where( array('id' => $item['id']) )->delete();
  775. }
  776. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  777. }
  778. public function deleteusergroup()
  779. {
  780. $_GPC = I('request.');
  781. $id = intval($_GPC['id']);
  782. if (empty($id)) {
  783. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  784. }
  785. $items = M('lionfish_comshop_member_group')->where( "id in (".$id.")" )->select();
  786. foreach ($items as $item ) {
  787. M('lionfish_comshop_member')->where( array('groupid' => $item['id'] ) )->save( array('groupid' => 0) );
  788. M('lionfish_comshop_member_group')->where( array('id' => $item['id']) )->delete();
  789. }
  790. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  791. }
  792. }
  793. ?>