agentpay.php 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace WY\app\controller\derpay;
  3. use WY\app\libs\Controller;
  4. if (!defined('WY_ROOT')) {
  5. exit;
  6. }
  7. class agentpay extends CheckAdmin
  8. {
  9. public function index()
  10. {
  11. $kw = $this->req->get('kw');
  12. $fdate = $this->req->get('fdate');
  13. $tdate = $this->req->get('tdate');
  14. $is_state = $this->req->get('is_state');
  15. $is_state = isset($_GET['is_state']) ? $is_state : -1;
  16. $cons = 'is_agent=?';
  17. $consOR = '';
  18. $consArr = array(1);
  19. if ($kw) {
  20. $users = $this->model()->select('id')->from('users')->where(array('fields' => 'username like ?', 'values' => array('%' . $kw . '%')))->fetchRow();
  21. if ($users) {
  22. $consOR .= $consOR ? ' or ' : '';
  23. $consOR .= 'userid = ?';
  24. $consArr[] = $users['id'];
  25. }
  26. }
  27. if ($is_state >= 0) {
  28. $cons .= $cons ? ' and ' : '';
  29. $cons .= 'is_state=?';
  30. $consArr[] = $is_state;
  31. }
  32. if ($kw) {
  33. $consOR .= $consOR ? ' or ' : '';
  34. $consOR .= 'userid = ?';
  35. $consArr[] = $kw;
  36. }
  37. if ($kw) {
  38. $consOR .= $consOR ? ' or ' : '';
  39. $consOR .= 'sn = ?';
  40. $consArr[] = $kw;
  41. }
  42. if ($fdate) {
  43. $cons .= $cons ? ' and ' : '';
  44. $cons .= 'addtime>=?';
  45. $consArr[] = strtotime($fdate);
  46. }
  47. if ($tdate) {
  48. $cons .= $cons ? ' and ' : '';
  49. $cons .= 'addtime<=?';
  50. $consArr[] = strtotime($tdate . ' 23:59:59');
  51. }
  52. if ($consOR) {
  53. $cons .= $cons ? ' and ' : '';
  54. $cons .= '(' . $consOR . ')';
  55. }
  56. $orderby = 'id desc';
  57. $sort = $this->req->get('sort');
  58. $sort = isset($_GET['sort']) ? $sort : 0;
  59. $by = $this->req->get('by');
  60. if ($by) {
  61. $sort2 = $sort ? ' desc' : ' asc';
  62. $orderby = $by . $sort2;
  63. }
  64. $page = $this->req->get('p');
  65. $page = $page ? $page : 1;
  66. $pagesize = 20;
  67. $totalsize = $this->model()->select()->from('payments')->where(array('fields' => $cons, 'values' => $consArr))->count();
  68. $lists = array();
  69. if ($totalsize) {
  70. $totalpage = ceil($totalsize / $pagesize);
  71. $page = $page > $totalpage ? $totalpage : $page;
  72. $offset = ($page - 1) * $pagesize;
  73. $lists = $this->model()->select()->from('payments')->offset($offset)->limit($pagesize)->orderby($orderby)->where(array('fields' => $cons, 'values' => $consArr))->fetchAll();
  74. }
  75. $pagelist = $this->page->put(array('page' => $page, 'pagesize' => $pagesize, 'totalsize' => $totalsize, 'url' => '?is_state=' . $is_state . '&kw=' . $kw . '&fdate=' . $fdate . '&tdate=' . $tdate . '&sort=' . $sort . '&by=' . $by . '&p='));
  76. $data = array('title' => '付款记录', 'lists' => $lists, 'pagelist' => $pagelist, 'search' => array('kw' => $kw, 'fdate' => $fdate, 'tdate' => $fdate, 'is_state' => $is_state), 'sort' => $sort, 'by' => $by);
  77. $this->put('payments2.php', $data);
  78. }
  79. public function pay()
  80. {
  81. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  82. $data = $this->model()->select()->from('payments')->where(array('fields' => 'id=?', 'values' => array($id)))->fetchRow();
  83. $this->put('paymentsinfo.php', $data);
  84. }
  85. public function savepay()
  86. {
  87. $id = isset($this->action[3]) ? intval($this->action[3]) : 0;
  88. $data = isset($_POST) ? $_POST : false;
  89. if ($id && $data) {
  90. $data += array('lastime' => time());
  91. if ($this->model()->from('payments')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($id)))->update()) {
  92. $this->put('woodyapp.php', array('msg' => '账单信息已保存成功', 'url' => $this->dir . 'userpay'));
  93. }
  94. }
  95. $this->put('woodyapp.php', array('msg' => '账单信息已保存失败', 'url' => $this->dir . 'userpay'));
  96. }
  97. }