PermController.class.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author fish
  7. *
  8. */
  9. namespace Seller\Controller;
  10. class PermController extends CommonController{
  11. protected function _initialize(){
  12. parent::_initialize();
  13. }
  14. public function index()
  15. {
  16. $_GPC = I('request.');
  17. $this->gpc = $_GPC;
  18. $pindex = max(1, intval($_GPC['page']));
  19. $psize = 20;
  20. $status = $_GPC['status'];
  21. $condition = ' and deleted=0';
  22. if (!empty($_GPC['keyword'])) {
  23. $_GPC['keyword'] = trim($_GPC['keyword']);
  24. $condition .= ' and rolename like "%'.$_GPC['keyword'].'%" ';
  25. }
  26. if ($_GPC['status'] != '') {
  27. $condition .= ' and status=' . intval($_GPC['status']);
  28. }
  29. $list = M()->query('SELECT * FROM ' . C('DB_PREFIX') . 'lionfish_comshop_perm_role WHERE 1 ' . $condition .
  30. ' ORDER BY id desc LIMIT ' . (($pindex - 1) * $psize) . ',' . $psize);
  31. foreach ($list as &$row) {
  32. $row['usercount'] = M('seller')->where( array('s_role_id' => $row['id'] ) )->count();
  33. }
  34. unset($row);
  35. $total = M('lionfish_comshop_perm_role')->where("1 ". $condition )->count();
  36. $pager = pagination2($total, $pindex, $psize);
  37. $this->pager = $pager;
  38. $this->list = $list;
  39. $this->display();
  40. }
  41. public function rolestatus()
  42. {
  43. $_GPC = I('request.');
  44. $id = intval($_GPC['id']);
  45. if (empty($id)) {
  46. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  47. }
  48. $status = intval($_GPC['status']);
  49. $items = M('lionfish_comshop_perm_role')->field('id,rolename')->where( 'id in( ' . $id . ' )' )->select();
  50. foreach ($items as $item) {
  51. M('lionfish_comshop_perm_role')->where( array('id' => $item['id']) )->save( array('status' => $status) );
  52. }
  53. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  54. }
  55. protected function perm_shop()
  56. {
  57. return array(
  58. 'text' => '商城概况',
  59. 'index' => array(
  60. 'analys' => '统计'
  61. )
  62. );
  63. }
  64. protected function perm_goods()
  65. {
  66. return array(
  67. 'text' => '商品管理',
  68. 'goods' => array(
  69. 'index' => '商品列表',
  70. 'goodscategory' => '商品分类',
  71. 'goodsspec' => '商品规格',
  72. 'goodstag' => '商品标签',
  73. 'config' => '商品设置',
  74. 'settime' => '统一时间',
  75. 'industrial' => '工商资质',
  76. )
  77. );
  78. }
  79. protected function perm_order()
  80. {
  81. return array(
  82. 'text' => '订单管理',
  83. 'order' => array(
  84. 'index' => '订单列表',
  85. 'ordersendall' => '批量发货',
  86. 'orderaftersales' => '售后管理',
  87. 'ordercomment' => '评价列表',
  88. 'ordercomment_config' => '评价设置',
  89. 'config' => '订单设置',
  90. ),
  91. 'orderdistribution' => array(
  92. 'index' => '配送员管理',
  93. 'distributionconfig' => '配送设置',
  94. 'withdrawallist' => '提现列表',
  95. 'withdrawalconfig' => '提现设置',
  96. )
  97. );
  98. }
  99. protected function perm_user()
  100. {
  101. return array(
  102. 'text' => '会员管理',
  103. 'user' => array(
  104. 'index' => '会员列表',
  105. 'userjia' => '虚拟会员管理',
  106. 'config' => '会员设置',
  107. 'usergroup' => '会员分组',
  108. 'userlevel' => '会员等级',
  109. )
  110. );
  111. }
  112. protected function perm_distribution()
  113. {
  114. return array(
  115. 'text' => '会员分销',
  116. 'distribution' => array(
  117. 'distribution' => '分销列表',
  118. 'distributionorder' => '订单管理',
  119. 'config' => '分销设置',
  120. 'qrcodeconfig' => '海报设置',
  121. 'withdrawallist' => '提现列表',
  122. 'withdraw_config' => '提现设置',
  123. )
  124. );
  125. }
  126. protected function perm_communityhead()
  127. {
  128. return array(
  129. 'text' => '团长管理',
  130. 'communityhead' => array(
  131. 'index' => '团长列表',
  132. 'usergroup' => '团长分组',
  133. 'headlevel' => '团长等级',
  134. 'config' => '团长设置',
  135. 'distribulist' => '提现列表',
  136. 'distributionpostal' => '提现设置',
  137. )
  138. );
  139. }
  140. protected function perm_salesroom()
  141. {
  142. return array(
  143. 'text' => '门店管理',
  144. 'salesroom' => array(
  145. 'index' => '门店列表',
  146. ),
  147. 'salesroom_member' => array(
  148. 'index' => '核销人员',
  149. ),
  150. 'salesroom_order' => array(
  151. 'index' => '核销订单记录',
  152. )
  153. );
  154. }
  155. protected function perm_supply()
  156. {
  157. return array(
  158. 'text' => '供应商管理',
  159. 'supply' => array(
  160. 'index' => '供应商列表',
  161. 'admintixianlist' => '提现申请',
  162. 'distributionpostal' => '提现设置',
  163. 'baseconfig' => '基本设置',
  164. 'config' => '申请页面内容',
  165. )
  166. );
  167. }
  168. protected function perm_article()
  169. {
  170. return array(
  171. 'text' => '文章列表',
  172. 'article' => array(
  173. 'index' => '文章列表',
  174. )
  175. );
  176. }
  177. //拼团
  178. protected function perm_group()
  179. {
  180. return array(
  181. 'text' => '拼团管理',
  182. 'group' => array(
  183. 'goods' => '商品管理',
  184. 'goodscategory' => '商品分类',
  185. 'goodsspec' => '商品规格',
  186. 'goodstag' => '商品标签',
  187. 'goodsvircomment' => '虚拟评价',
  188. 'pintuan' => '拼团管理',
  189. 'orderlist' => '订单管理',
  190. 'ordersendall' => '批量发货',
  191. 'orderaftersales' => '售后管理',
  192. 'slider' => '幻灯片',
  193. 'config' => '拼团设置',
  194. 'pincommiss' => '拼团佣金',
  195. 'withdrawallist' => '提现列表',
  196. 'withdraw_config' => '提现设置',
  197. )
  198. );
  199. }
  200. //应用
  201. protected function application_group()
  202. {
  203. return array(
  204. 'text' => '应用',
  205. 'application' => array(
  206. 'index' => '应用管理',
  207. )
  208. );
  209. }
  210. //小程序交易组件
  211. protected function mptrade_group()
  212. {
  213. return array(
  214. 'text' => '小程序交易组件',
  215. 'application' => array(
  216. 'index' => '应用管理',
  217. ),
  218. 'mptradecomponts' => array(
  219. 'index' => '商品列表',
  220. 'config' => '设置',
  221. )
  222. );
  223. }
  224. //小程序货到付款
  225. protected function cashon_delivery()
  226. {
  227. return array(
  228. 'text' => '小程序货到付款',
  229. 'application' => array(
  230. 'index' => '应用管理',
  231. ),
  232. 'mptradecomponts' => array(
  233. 'config' => '设置',
  234. )
  235. );
  236. }
  237. //小程序货到付款
  238. protected function platformmobile_config()
  239. {
  240. return array(
  241. 'text' => '平台手机端',
  242. 'application' => array(
  243. 'index' => '应用管理',
  244. ),
  245. 'platformmobile' => array(
  246. 'config' => '设置',
  247. )
  248. );
  249. }
  250. //小程序万能表单
  251. protected function allform_config()
  252. {
  253. return array(
  254. 'text' => '小程序万能表单',
  255. 'application' => array(
  256. 'index' => '应用管理',
  257. ),
  258. 'mptradecomponts' => array(
  259. 'index' => '表单列表',
  260. 'config' => '表单设置',
  261. )
  262. );
  263. }
  264. protected function perm_delivery()
  265. {
  266. return array(
  267. 'text' => '配送单管理',
  268. 'delivery' => array(
  269. 'index' => '配送单管理',
  270. 'get_list' => '生成配送单',
  271. 'line' => '配送路线',
  272. 'clerk' => '配送人员',
  273. 'config' => '设置',
  274. )
  275. );
  276. }
  277. protected function perm_data_static()
  278. {
  279. return array(
  280. 'text' => '数据',
  281. 'reports' => array(
  282. 'index' => '营业数据',
  283. 'datastatics' => '数据统计',
  284. 'goodstatics' => '毛利统计',
  285. 'communitystatics' => '团长统计',
  286. )
  287. );
  288. }
  289. protected function perm_perm()
  290. {
  291. return array(
  292. 'text' => '角色管理',
  293. 'perm' => array(
  294. 'index' => '角色管理',
  295. 'user' => '后台用户管理',
  296. )
  297. );
  298. }
  299. protected function perm_attachment()
  300. {
  301. return array(
  302. 'text' => '附件管理',
  303. 'attachment' => array(
  304. 'index' => '附件设置',
  305. )
  306. );
  307. }
  308. protected function perm_config()
  309. {
  310. return array(
  311. 'text' => '设置',
  312. 'config' => array(
  313. 'index' => '基本设置',
  314. 'picture' => '图片设置',
  315. ),
  316. 'weprogram' => array(
  317. 'index' => '参数设置',
  318. 'templateconfig' => '模板消息设置',
  319. 'tabbar' => '底部菜单设置',
  320. ),
  321. 'configpay' => array(
  322. 'index' => '支付设置',
  323. ),
  324. 'configindex' => array(
  325. 'slider' => '幻灯片',
  326. 'category' => '分类广告',
  327. 'notice' => '公告',
  328. 'navigat' => '导航图标',
  329. 'noticesetting' => '公告设置',
  330. 'qgtab' => '抢购切换',
  331. 'cube' => '图片魔方',
  332. 'video' => '视频',
  333. ),
  334. 'shipping' => array(
  335. 'templates' => '运费模板',
  336. ),
  337. 'logistics' => array(
  338. 'index' => '电子面单列表',
  339. 'inface' => '电子面单设置',
  340. ),
  341. 'express' => array(
  342. 'config' => '快递方式',
  343. 'deconfig' => '配送方式设置',
  344. 'localtownconfig' => '同城配送',
  345. ),
  346. 'copyright' => array(
  347. 'index' => '版权说明',
  348. 'about' => '关于我们',
  349. 'account' => '后台账户',
  350. ),
  351. 'wxlive' => array(
  352. 'index' => '直播间管理',
  353. 'setting' => '设置',
  354. ),
  355. );
  356. }
  357. protected function perm_generalmall()
  358. {
  359. return array(
  360. 'text' => '商城管理',
  361. 'generalmall' => array(
  362. 'slider' => '幻灯片',
  363. 'navigat' => '导航图标',
  364. )
  365. );
  366. }
  367. protected function perm_marketing()
  368. {
  369. return array(
  370. 'text' => '营销活动',
  371. 'marketing' => array(
  372. 'coupon' => '优惠券管理',
  373. 'category' => '优惠券分类',
  374. 'send' => '手动发送',
  375. 'fullreduction' => '满减',
  376. 'signinreward' => '积分签到',
  377. 'points' => '积分设置',
  378. 'recharge_config' => '充值设置',
  379. 'explain' => '充值说明',
  380. 'recharge_diary' => '充值流水',
  381. 'special' => '主题活动',
  382. 'seckill' => '整点秒杀',
  383. ),
  384. 'points' => array(
  385. 'goods' => '积分商品',
  386. 'order' => '兑换订单',
  387. ),
  388. 'solitaire' => array(
  389. 'index' => '群接龙管理',
  390. 'config' => '群接龙设置',
  391. ),
  392. 'recipe' => array(
  393. 'index' => '菜谱',
  394. 'category' => '菜谱分类',
  395. 'slider' => '幻灯片',
  396. 'config' => '菜谱设置',
  397. ),
  398. 'vipcard' => array(
  399. 'index' => '会员卡',
  400. 'equity' => '会员权益',
  401. 'order' => '购买会员订单',
  402. 'config' => '会员卡设置',
  403. ),
  404. 'popadv' => array(
  405. 'index' => '广告弹窗',
  406. ),
  407. 'advimg' => array(
  408. 'add' => '广告图片',
  409. ),
  410. 'presale' => array(
  411. 'index' => '预售商品管理',
  412. 'slider' => '幻灯片',
  413. 'order' => '预售订单',
  414. 'statistics' => '预售统计',
  415. 'config' => '活动设置',
  416. ),
  417. 'shopdiy' => array(
  418. 'index' => '首页装修',
  419. ),
  420. 'invitegift' => array(
  421. 'config' => '邀新有礼',
  422. 'record' => '邀新记录',
  423. 'poster_background' => '邀新海报',
  424. ),
  425. 'virtualcard' => array(
  426. 'index' => '礼品卡管理',
  427. 'exchange_code' => '兑换码管理',
  428. 'exchange_offline' => '线下兑换码',
  429. 'orderlist' => '订单管理',
  430. 'exchangerecord' => '兑换记录',
  431. 'config' => '活动设置',
  432. ),
  433. );
  434. }
  435. protected function perm_update()
  436. {
  437. return array(
  438. 'text' => '检测更新',
  439. );
  440. }
  441. public function allPerms()
  442. {
  443. $perms = array(
  444. 'index' => $this->perm_shop(),
  445. 'goods' => $this->perm_goods(),
  446. 'order' => $this->perm_order(),
  447. 'user' => $this->perm_user(),
  448. 'distribution' => $this->perm_distribution(),
  449. 'communityhead' => $this->perm_communityhead(),
  450. 'salesroom' => $this->perm_salesroom(),
  451. 'supply' => $this->perm_supply(),
  452. 'marketing' => $this->perm_marketing(),
  453. 'article' => $this->perm_article(),
  454. //'application' => $this->application_group(),
  455. 'mptradecomponts' => $this->mptrade_group(),
  456. 'cashondelivery' => $this->cashon_delivery(),
  457. 'platformmobile_config' => $this->platformmobile_config(),
  458. 'allform' => $this->allform_config(),
  459. 'delivery' => $this->perm_delivery(),
  460. 'reports' => $this->perm_data_static(),
  461. 'group' => $this->perm_group(),
  462. 'perm' => $this->perm_perm(),
  463. 'attachment' => $this->perm_attachment(),
  464. 'config' => $this->perm_config(),
  465. 'system' => $this->perm_update(),
  466. );
  467. return $perms;
  468. }
  469. public function formatPerms()
  470. {
  471. $perms = $this->allPerms();
  472. $array = array();
  473. foreach ($perms as $key => $value) {
  474. if (is_array($value)) {
  475. foreach ($value as $ke => $val) {
  476. if (!is_array($val)) {
  477. $array['parent'][$key][$ke] = $val;
  478. }
  479. if (is_array($val) && ($ke != 'xxx')) {
  480. foreach ($val as $k => $v) {
  481. if (!is_array($v)) {
  482. $array['son'][$key][$ke][$k] = $v;
  483. }
  484. if (is_array($v) && ($k != 'xxx')) {
  485. foreach ($v as $kk => $vv) {
  486. if (!is_array($vv)) {
  487. $array['grandson'][$key][$ke][$k][$kk] = $vv;
  488. }
  489. }
  490. }
  491. }
  492. }
  493. }
  494. }
  495. }
  496. return $array;
  497. }
  498. public function addrole()
  499. {
  500. $_GPC = I('request.');
  501. $id = intval($_GPC['id']);
  502. $item = M('lionfish_comshop_perm_role')->where( array('deleted' => 0 , 'id' => $id) )->find();
  503. $perms = $this->formatPerms();
  504. $role_perms = array();
  505. $user_perms = array();
  506. if (!empty($item)) {
  507. $role_perms = explode(',', $item['perms2']);
  508. }
  509. $user_perms = explode(',', $item['perms2']);
  510. $this->item = $item;
  511. $this->perms = $perms;
  512. $this->user_perms = $user_perms;
  513. if (IS_POST) {
  514. $data = array( 'rolename' => trim($_GPC['rolename']), 'status' => intval($_GPC['status']), 'perms2' => is_array($_GPC['perms']) ? implode(',', $_GPC['perms']) : '');
  515. if (!empty($id)) {
  516. M('lionfish_comshop_perm_role')->where( array('id' => $id) )->save( $data );
  517. }
  518. else {
  519. M('lionfish_comshop_perm_role')->add( $data );
  520. }
  521. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  522. }
  523. $this->display();
  524. }
  525. public function roledelete()
  526. {
  527. $_GPC = I('request.');
  528. $id = intval($_GPC['id']);
  529. if (empty($id)) {
  530. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  531. }
  532. $items = M('lionfish_comshop_perm_role')->field('id,rolename')->where('id in( ' . $id . ' )')->select();
  533. foreach ($items as $item) {
  534. M('lionfish_comshop_perm_role')->where( array('id' => $item['id']) )->delete();
  535. }
  536. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  537. }
  538. public function userstatus()
  539. {
  540. $_GPC = I('request.');
  541. $id = intval($_GPC['id']);
  542. if (empty($id)) {
  543. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  544. }
  545. $status = intval($_GPC['s_status']);
  546. //$items = M()->query('SELECT s_id FROM ' . C('DB_PREFIX'). 'seller WHERE s_id in( ' . $id . ' ) ');
  547. $items = M('seller')->field('s_id')->where( 's_id in( ' . $id . ' )' )->select();
  548. foreach ($items as $item) {
  549. M('seller')->where( array('s_id' => $item['s_id']) )->save( array('s_status' => $status) );
  550. }
  551. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  552. }
  553. public function user()
  554. {
  555. $_GPC = I('request.');
  556. $pindex = max(1, intval($_GPC['page']));
  557. $psize = 20;
  558. $status = $_GPC['status'];
  559. $condition = ' and u.deleted=0 ';
  560. $this->gpc = $_GPC;
  561. if (!empty($_GPC['keyword'])) {
  562. $_GPC['keyword'] = trim($_GPC['keyword']);
  563. $condition .= ' and ( u.s_uname like "%'.$_GPC['keyword'].'%" )';
  564. //or u.s_true_name like "%'.$_GPC['keyword'].'%" or u.s_mobile like "%'.$_GPC['keyword'].'%"
  565. }
  566. if ($_GPC['roleid'] != '') {
  567. $condition .= ' and u.s_role_id=' . intval($_GPC['roleid']);
  568. }
  569. if ($_GPC['status'] != '') {
  570. $condition .= ' and u.s_status=' . intval($_GPC['status']);
  571. }
  572. $list = M()->query('SELECT u.*,r.rolename FROM ' . C('DB_PREFIX') . 'seller as u ' .
  573. ' left join ' . C('DB_PREFIX'). 'lionfish_comshop_perm_role as r on u.s_role_id =r.id ' .
  574. ' WHERE 1 ' . $condition . ' ORDER BY s_id desc LIMIT ' . (($pindex - 1) * $psize) . ',' . $psize);
  575. $total_arr = M()->query('SELECT count(*) as count FROM ' . C('DB_PREFIX'). 'seller as u ' .
  576. ' left join ' . C('DB_PREFIX'). 'lionfish_comshop_perm_role as r on u.s_role_id =r.id '
  577. . ' WHERE 1 ' . $condition . ' ', $params);
  578. $total = $total_arr[0]['count'];
  579. $pager = pagination2($total, $pindex, $psize);
  580. $roles = M()->query('select id,rolename from ' . C('DB_PREFIX'). 'lionfish_comshop_perm_role where deleted=0' );
  581. $this->list = $list;
  582. $this->roles = $roles;
  583. $this->pager = $pager;
  584. $this->display();
  585. }
  586. public function rolequery()
  587. {
  588. $_GPC = I('request.');
  589. $this->gpc = $_GPC;
  590. $kwd = trim($_GPC['keyword']);
  591. $this->kwd = $kwd;
  592. $params = array();
  593. $condition = ' and deleted=0';
  594. if (!empty($kwd)) {
  595. $condition .= ' AND `rolename` LIKE "%'.$kwd.'%" ';
  596. }
  597. $ds = M()->query('SELECT id,rolename,perms2 FROM ' . C('DB_PREFIX') . 'lionfish_comshop_perm_role WHERE status=1 ' . $condition . ' order by id asc' );
  598. $this->ds = $ds;
  599. $this->display();
  600. }
  601. /**
  602. * 改变状态
  603. */
  604. public function change()
  605. {
  606. $id = I('request.id');
  607. //ids
  608. if (empty($id)) {
  609. $ids = I('request.ids');
  610. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  611. }
  612. if (empty($id)) {
  613. show_json(0, array('message' => '参数错误'));
  614. }
  615. $type = I('request.type');
  616. $value = I('request.value');
  617. if (!(in_array($type, array('enabled', 'displayorder')))) {
  618. show_json(0, array('message' => '参数错误'));
  619. }
  620. $items = M('lionfish_comshop_article')->where( array('id' => array('in', $id) ) )->select();
  621. foreach ($items as $item) {
  622. M('lionfish_comshop_article')->where( array('id' => $item['id']) )->save( array($type => $value) );
  623. }
  624. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  625. }
  626. public function adduser()
  627. {
  628. $_GPC = I('request.');
  629. $this->gpc = $_GPC;
  630. $id = intval($_GPC['id']);
  631. $item = array();
  632. if( $id >0 )
  633. {
  634. $item = M('seller')->where( array('s_id' => $id ,'deleted' => 0) )->find();
  635. }
  636. $perms = $this->formatPerms();
  637. $this->item = $item;
  638. $this->perms = $perms;
  639. $user_perms = array();
  640. $role_perms = array();
  641. if (!empty($item)) {
  642. $role = M('lionfish_comshop_perm_role')->where( array('id' => $item['s_role_id'],'deleted' => 0 ) )->find();
  643. if (!empty($role)) {
  644. $role_perms = explode(',', $role['perms2']);
  645. }
  646. $user_perms = explode(',', $item['perms2']);
  647. }
  648. $this->user_perms = $user_perms;
  649. $this->role_perms = $role_perms;
  650. $this->role = $role;
  651. //
  652. $_GPC = I('request.');
  653. $this->gpc = $_GPC;
  654. $kwd = trim($_GPC['keyword']);
  655. $this->kwd = $kwd;
  656. $params = array();
  657. $condition = ' and deleted=0';
  658. if (!empty($kwd)) {
  659. $condition .= ' AND `rolename` LIKE "%'.$kwd.'%" ';
  660. }
  661. $ds = M()->query('SELECT id,rolename,perms2 FROM ' . C('DB_PREFIX') . 'lionfish_comshop_perm_role WHERE status=1 ' . $condition . ' order by id asc' );
  662. $this->ds = $ds;
  663. if (IS_POST) {
  664. $data = array(
  665. 's_uname' => trim($_GPC['s_uname']),
  666. 's_true_name' => trim($_GPC['s_true_name']),
  667. 's_mobile' => trim($_GPC['s_mobile']),
  668. 's_passwd' => ($_GPC['s_passwd']),
  669. 's_role_id' => ($_GPC['roleid']),
  670. 's_login_count' => '',
  671. 's_last_login_ip' => '',
  672. 's_last_ip_region' => '',
  673. 's_create_time' => time(),
  674. 's_last_login_time' => '',
  675. 's_status' => intval($_GPC['s_status']),
  676. 'perms' => '',
  677. 'deleted' => 0,
  678. );
  679. if (!empty($item['s_id'])) {
  680. unset($data['s_create_time']);
  681. $user = M('seller')->where( array('s_uname' => $data['s_uname']) )->find();
  682. if (!empty($_GPC['s_passwd'])) {
  683. $data['s_passwd'] = think_ucenter_encrypt($data['s_passwd'],C('SELLER_PWD_KEY'));
  684. }else{
  685. unset($data['s_passwd']);
  686. }
  687. M('seller')->where( array('s_id' => $id) )->save($data);
  688. }
  689. else {
  690. $user = M('seller')->where( array('s_uname' => $data['s_uname']) )->find();
  691. $data['s_passwd'] = think_ucenter_encrypt($data['s_passwd'],C('SELLER_PWD_KEY'));
  692. if( !empty($user) )
  693. {
  694. show_json(0, array('msg' => '此用户为系统存在用户,无法添加') );
  695. }
  696. M('seller')->add( $data );
  697. }
  698. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  699. }
  700. $this->display();
  701. }
  702. /**
  703. * 删除公告
  704. */
  705. public function userdelete()
  706. {
  707. $id = I('request.id');
  708. if (empty($id)) {
  709. $ids = I('request.ids');
  710. $id = (is_array($ids) ? implode(',', $ids) : 0);
  711. }
  712. $items = M('seller')->field('s_id')->where( array('s_id' => array('in', $id) ) )->select();
  713. //if (empty($item)) {
  714. // $item = array();
  715. // }
  716. foreach ($items as $item) {
  717. M('seller')->where( array('s_id' => $item['s_id']) )->delete();
  718. }
  719. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  720. }
  721. }
  722. ?>