refill_error.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. class refill_errorControl extends SystemControl
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. }
  8. public function indexOp()
  9. {
  10. $mod = Model('refill_error');
  11. $condition = [];
  12. $_GET['query_start_time'] = $_GET['query_start_time'] ?? date("Y-m-d 00:00:00");
  13. $start_unixtime = intval(strtotime($_GET['query_start_time']));
  14. $end_unixtime = intval(strtotime($_GET['query_end_time']));
  15. if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) {
  16. $condition['add_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
  17. } elseif ($start_unixtime > 0) {
  18. $condition['add_time'] = ['egt', $start_unixtime];
  19. } elseif ($end_unixtime > 0) {
  20. $condition['add_time'] = ['lt', $end_unixtime];
  21. } else {
  22. $start = strtotime(date('Y-m-d', time()));
  23. $condition['add_time'] = ['egt', $start];
  24. }
  25. if(!empty($_GET['mchid'])) {
  26. $condition['mchid'] = $_GET['mchid'];
  27. }
  28. if(in_array($_GET['handled'], ['0', '1'])) {
  29. $condition['handled'] = $_GET['handled'];
  30. }
  31. if (!empty($_GET['mch_orders'])) {
  32. $mch_orders = rtrim($_GET['mch_orders'],',');
  33. $condition['mch_order'] = ['in', $mch_orders];
  34. }
  35. $list = $mod->getRefillErrorlList($condition, 200, 1000);
  36. $merchants = [];
  37. $merchant_list = $this->merchants();
  38. foreach ($merchant_list as $value) {
  39. $merchants[$value['mchid']] = $value;
  40. }
  41. $list = $this->DataFormat($list, $merchants);
  42. Tpl::output('merchant_list', $merchant_list);
  43. Tpl::output('list', $list);
  44. Tpl::output('show_page', $mod->showpage());
  45. Tpl::showpage('refill.error');
  46. }
  47. private function DataFormat($list,$merchants)
  48. {
  49. foreach ($list as $key => $value) {
  50. $list[$key]['company_name'] = $merchants[$value['mchid']]['company_name'];
  51. if($value['handled'] == 0) {
  52. $list[$key]['handled_text'] = '未处理';
  53. } else {
  54. $list[$key]['handled_text'] = '已处理';
  55. }
  56. }
  57. return $list;
  58. }
  59. public function handledOp()
  60. {
  61. $mod = Model('refill_error');
  62. $id = $_GET['error_id'];
  63. $condition['error_id'] = ['in',$id];
  64. $condition['handled'] = 0;
  65. $resp = $mod->where($condition)->update(['handled' => 1]);
  66. if(!$resp) {
  67. showMessage('操作失败', 'index.php?act=refill_error&op=index');
  68. }
  69. showMessage('操作成功', 'index.php?act=refill_error&op=index');
  70. }
  71. }