orders.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 orders extends CheckUser
  9. {
  10. public function index()
  11. {
  12. $cons = 'agentid=? and is_state<>?';
  13. $consArr = array($_SESSION['login_agentid'], 2);
  14. $is_state = $this->req->get('is_state');
  15. $is_state = isset($_GET['is_state']) ? $is_state : -1;
  16. $sdpayno = $this->req->get('sdpayno');
  17. $sdorderno = $this->req->get('sdorderno');
  18. $fdate = $this->req->get('fdate');
  19. $tdate = $this->req->get('tdate');
  20. $fdate = isset($_GET['fdate']) ? $fdate : date('Y-m-d');
  21. $tdate = isset($_GET['tdate']) ? $tdate : date('Y-m-d');
  22. if ($is_state >= 0) {
  23. $cons .= $cons ? ' and ' : '';
  24. $cons .= 'is_state=?';
  25. $consArr[] = $is_state;
  26. }
  27. if ($sdpayno) {
  28. $cons .= $cons ? ' and ' : '';
  29. $cons .= 'orderid=?';
  30. $consArr[] = $sdpayno;
  31. }
  32. if ($sdorderno) {
  33. $cons .= $cons ? ' and ' : '';
  34. $cons .= 'sdorderno=?';
  35. $consArr[] = $sdorderno;
  36. }
  37. if ($fdate) {
  38. $cons .= $cons ? ' and ' : '';
  39. $cons .= 'addtime>=?';
  40. $consArr[] = strtotime($fdate);
  41. }
  42. if ($tdate) {
  43. $cons .= $cons ? ' and ' : '';
  44. $cons .= 'addtime<=?';
  45. $consArr[] = strtotime($tdate . ' 23:59:59');
  46. }
  47. $where = $cons ? array('fields' => $cons, 'values' => $consArr) : array();
  48. $page = $this->req->get('p');
  49. $page = $page ? intval($page) : 1;
  50. $pagesize = 20;
  51. $lists = array();
  52. if ($totalsize = $this->model()->select()->from('orders')->where($where)->count()) {
  53. $totalpage = ceil($totalsize / $pagesize);
  54. $page = $page > $totalpage ? $totalpage : $page;
  55. $offset = ($page - 1) * $pagesize;
  56. $lists = $this->model()->select()->from('orders')->limit($pagesize)->offset($offset)->orderby('id desc')->where($where)->fetchAll();
  57. }
  58. $pagelist = $this->page->put(array('page' => $page, 'pagesize' => $pagesize, 'totalsize' => $totalsize, 'url' => '?is_state=' . $is_state . '&sdpayno=' . $sdpayno . '&sdorderno=' . $sdorderno . '&fdate=' . $fdate . '&tdate=' . $tdate . '&p='));
  59. $data = array('title' => '交易订单', 'lists' => $lists, 'pagelist' => $pagelist, 'search' => array('is_state' => $is_state, 'sdpayno' => $sdpayno, 'sdorderno' => $sdorderno, 'fdate' => $fdate, 'tdate' => $tdate));
  60. $this->put('orders.php', $data);
  61. }
  62. public function refresh()
  63. {
  64. $orderid = $this->req->post('sdpayno');
  65. $push = new Pushorder($orderid);
  66. $push->notify();
  67. $orders = $this->model()->select('id')->from('orders')->where(array('fields' => 'orderid=?', 'values' => array($orderid)))->fetchRow();
  68. $ordernotify = $this->model()->select('retmsg')->from('ordernotify')->where(array('fields' => 'orid=?', 'values' => array($orders['id'])))->fetchRow();
  69. echo $ordernotify['retmsg'];
  70. }
  71. }