PermController.class.php 22 KB

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