order_search.php 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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($condition)) {
  36. $condition['refill_order.inner_status'] = 0;
  37. $start_unixtime = intval(strtotime($_GET['query_start_time']));
  38. $end_unixtime = intval(strtotime($_GET['query_end_time']));
  39. if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
  40. $condition['refill_order.order_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
  41. } elseif ($start_unixtime > 0) {
  42. $condition['refill_order.order_time'] = ['egt', $start_unixtime];
  43. } elseif ($end_unixtime > 0) {
  44. $condition['refill_order.order_time'] = ['lt', $end_unixtime];
  45. } else {
  46. $start = strtotime(date('Y-m-d', time()));
  47. $condition['refill_order.order_time'] = ['egt', $start];
  48. }
  49. $order_list = $model_refill_order->getMerchantOrderList($condition, 200, 'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
  50. $merchant_list = Model('')->table('merchant')->limit(1000)->select();
  51. foreach ($merchant_list as $value) {
  52. $merchants[$value['mchid']] = $value;
  53. }
  54. foreach ($order_list as $order_id => $order_info) {
  55. $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
  56. $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];
  57. if ($order_info['notify_time'] > 0) {
  58. $diff_time = $order_info['notify_time'] - $order_info['order_time'];
  59. } else {
  60. $diff_time = time() - $order_info['order_time'];
  61. }
  62. $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
  63. $order_list[$order_id]['diff_time'] = $diff_time;
  64. $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality'],$order_info['card_type']);
  65. }
  66. }
  67. $merchant_list = $this->merchants();
  68. $provider_list = $this->providers();
  69. Tpl::output('provider_list', $provider_list);
  70. Tpl::output('merchant_list', $merchant_list);
  71. Tpl::output('order_list', $order_list);
  72. Tpl::output('show_page', $model_refill_order->showpage());
  73. Tpl::showpage('refill.order.search');
  74. }
  75. }