order_search.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. class order_searchControl extends SystemControl
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. }
  8. public function indexOp()
  9. {
  10. $model_refill_order = Model('refill_order');
  11. $order_list = [];
  12. $_GET['query_start_time'] = $_GET['query_start_time'] ?? date("Y-m-d 00:00:00");
  13. if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
  14. {
  15. $condition['vr_order.order_state'] = $_GET['order_state'];
  16. }
  17. if (!empty($_GET['mchid'])) {
  18. $condition['refill_order.mchid'] = $_GET['mchid'];
  19. }
  20. if (!empty($_GET['store_id'])) {
  21. $condition['vr_order.store_id'] = $_GET['store_id'];
  22. }
  23. //批量查询,二者都有,以卡号为主
  24. if(!empty($_GET['card_nos'])) {
  25. $card_nos = trim($_GET['card_nos'], ',');
  26. $condition['refill_order.card_no'] = ['in', $card_nos];
  27. } elseif (!empty($_GET['mch_orders'])) {
  28. $mch_orders = rtrim($_GET['mch_orders'], ',');
  29. $condition['refill_order.mch_order'] = ['in', $mch_orders];
  30. }
  31. if(!empty($_GET['order_sns'])) {
  32. $order_sns = trim($_GET['order_sns'], ',');
  33. $condition['refill_order.order_sn'] = ['in', $order_sns];
  34. }
  35. if (!empty($_GET['card_type'])) {
  36. if (in_array($_GET['card_type'], ['1', '2', '4', '5', '6', '7'])) {
  37. $condition['refill_order.card_type'] = intval($_GET['card_type']);
  38. }
  39. }
  40. if (!empty($_GET['refill_amount'])) {
  41. $condition['refill_order.refill_amount'] = $_GET['refill_amount'];
  42. }
  43. if(!empty($condition)) {
  44. $condition['refill_order.inner_status'] = 0;
  45. $start_unixtime = intval(strtotime($_GET['query_start_time']));
  46. $end_unixtime = intval(strtotime($_GET['query_end_time']));
  47. if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
  48. $condition['refill_order.order_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
  49. } elseif ($start_unixtime > 0) {
  50. $condition['refill_order.order_time'] = ['egt', $start_unixtime];
  51. } elseif ($end_unixtime > 0) {
  52. $condition['refill_order.order_time'] = ['lt', $end_unixtime];
  53. } else {
  54. $start = strtotime(date('Y-m-d', time()));
  55. $condition['refill_order.order_time'] = ['egt', $start];
  56. }
  57. $order_list = $model_refill_order->getMerchantOrderList($condition, 200, 0,'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
  58. $merchant_list = Model('')->table('merchant')->limit(1000)->select();
  59. foreach ($merchant_list as $value) {
  60. $merchants[$value['mchid']] = $value;
  61. }
  62. foreach ($order_list as $order_id => $order_info) {
  63. $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
  64. $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];
  65. if ($order_info['notify_time'] > 0) {
  66. $diff_time = $order_info['notify_time'] - $order_info['order_time'];
  67. } else {
  68. $diff_time = time() - $order_info['order_time'];
  69. }
  70. $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
  71. $order_list[$order_id]['diff_time'] = $diff_time;
  72. $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality'],$order_info['card_type']);
  73. }
  74. }
  75. $merchant_list = $this->merchants();
  76. $provider_list = $this->providers();
  77. Tpl::output('provider_list', $provider_list);
  78. Tpl::output('merchant_list', $merchant_list);
  79. Tpl::output('order_list', $order_list);
  80. Tpl::output('show_page', $model_refill_order->showpage());
  81. Tpl::showpage('refill.order.search');
  82. }
  83. }