users.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace WY\app\controller\agent;
  3. use WY\app\libs\Controller;
  4. use WY\app\model\Pushorder;
  5. if (!defined('WY_ROOT')) {
  6. exit;
  7. }
  8. class users extends CheckUser
  9. {
  10. public function index()
  11. {
  12. $uname = $this->req->get('uname');
  13. $cons = 'superid=?';
  14. $consArr = array($_SESSION['login_agentid']);
  15. if ($uname) {
  16. $cons .= $cons ? ' and ' : '';
  17. $cons .= '(id=? or username like ?)';
  18. $consArr[] = $uname;
  19. $consArr[] = '%' . $uname . '%';
  20. }
  21. $where = array('fields' => $cons, 'values' => $consArr);
  22. $lists = $this->model()->select()->from('users')->where($where)->fetchAll();
  23. $data = array('title' => '下级用户', 'lists' => $lists, 'search' => array('uname' => $uname));
  24. $this->put('users.php', $data);
  25. }
  26. public function setuserrate()
  27. {
  28. $userid = isset($this->action[3]) ? intval($this->action[3]) : 0;
  29. $saveset = $this->req->post('saveset');
  30. if (!$userid) {
  31. $data = array('msg' => '商户不存在');
  32. $this->put('woodyapp.php', $data);
  33. exit;
  34. }
  35. $where = array('fields' => 'id=? and superid=?', 'values' => array($userid, $_SESSION['login_agentid']));
  36. if ($this->model()->select()->from('users')->where($where)->count()) {
  37. if (!($userprice = $this->model()->select()->from('userprice')->where(array('fields' => 'userid=?', 'values' => array($userid)))->fetchAll())) {
  38. $userprice = $this->model()->select('*,id as channelid')->from('acc')->where(array('fields' => 'is_display=?', 'values' => array(0)))->fetchAll();
  39. }
  40. $agentprice = $this->model()->select()->from('userprice')->where(array('fields' => 'userid=?', 'values' => array($_SESSION['login_agentid'])))->fetchAll();
  41. if ($userprice && $agentprice) {
  42. if ($saveset == '1') {
  43. $newPrice = array();
  44. $price = isset($_POST['uprice']) ? $_POST['uprice'] : false;
  45. $accid = isset($_POST['accid']) ? $_POST['accid'] : false;
  46. if ($price && $accid) {
  47. foreach ($price as $key => $val) {
  48. $uprice = $val > $agentprice[$key]['gprice'] ? $agentprice[$key]['gprice'] : $val;
  49. $channelid = $accid[$key];
  50. $this->model()->from('userprice')->updateSet(array('uprice' => $uprice))->where(array('fields' => 'userid=? and channelid=?', 'values' => array($userid, $channelid)))->update();
  51. }
  52. $data = array('msg' => '设置保存成功');
  53. $this->put('woodyapp.php', $data);
  54. exit;
  55. }
  56. } else {
  57. $data = array('userid' => $userid, 'userprice' => $userprice, 'agentprice' => $agentprice);
  58. $this->put('userprice.php', $data);
  59. exit;
  60. }
  61. }
  62. }
  63. $data = array('msg' => '没有找到相关信息');
  64. $this->put('woodyapp.php', $data);
  65. exit;
  66. }
  67. }