refill_order_manual.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. require_once(BASE_HELPER_PATH . '/refill/util.php');
  3. use refill\util;
  4. class refill_order_manualControl extends SystemControl
  5. {
  6. public function __construct()
  7. {
  8. parent::__construct();
  9. }
  10. public function indexOp()
  11. {
  12. $model_refill_order = Model('refill_order');
  13. $condition['inner_status'] = 0;
  14. $order_list = [];
  15. if (!empty($_GET['order_sn'])) {
  16. $condition['refill_order.order_sn'] = $_GET['order_sn'];
  17. $merchants = [];
  18. $merchant_list = Model('')->table('merchant')->limit(1000)->select();
  19. foreach ($merchant_list as $key => $value) {
  20. $merchants[$value['mchid']] = $value;
  21. }
  22. $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc','',true);
  23. foreach ($order_list as $order_id => $order_info) {
  24. $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
  25. $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];
  26. if ($order_info['notify_time'] > 0) {
  27. $diff_time = $order_info['notify_time'] - $order_info['order_time'];
  28. } else {
  29. $diff_time = time() - $order_info['order_time'];
  30. }
  31. $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
  32. $order_list[$order_id]['diff_time'] = $diff_time;
  33. $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality'],$order_info['card_type']);
  34. $order_list[$order_id]['org_quality_text'] = $this->quality_format($order_info['org_quality'],$order_info['card_type']);
  35. }
  36. }
  37. Tpl::output('order_list', $order_list);
  38. Tpl::showpage('refill.order.manual.index');
  39. }
  40. public function notify_manual_merchantOp()
  41. {
  42. $order_id = $_GET['order_id'];
  43. $type = $_GET['type'];
  44. $mod_order = Model('vr_order');
  45. $order_info = $mod_order->getOrderInfo(['order_id' => $order_id]);
  46. if ((time() - $order_info['order_time']) < 3600) {
  47. showMessage('订单时间未超过1小时', 'index.php?act=refill_order&op=index');
  48. }
  49. $mod_refill = Model('refill_order');
  50. $logic_vr_order = Logic("vr_order");
  51. $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id]);
  52. if ($type == 'success') {
  53. $logic_vr_order->changeOrderStateSuccess($order_id,true);
  54. } elseif ($type == 'cancel') {
  55. $logic_vr_order->changeOrderStateCancel($order_info, '', "充值失败", true, true);
  56. } else {
  57. showMessage('手动操作类型错误', 'index.php?act=refill_order&op=index');
  58. }
  59. if($refill_info['notify_time'] == 0) {
  60. $mod_refill->edit($order_id, ['notify_state' =>1, 'notify_time' => time()]);
  61. }
  62. util::pop_queue_order($refill_info['mchid'],$refill_info['mch_order']);
  63. QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true]);
  64. showMessage('操作成功');
  65. }
  66. public function refill_order_batchOp()
  67. {
  68. if (chksubmit()) {
  69. $model_refill_order = Model('refill_order');
  70. $condition = [];
  71. $type = $_POST['type'];
  72. $order_sn = $_POST['order_sn'];
  73. $order_sn = str_replace(["\r\n", "\r", "\n"], ",", $order_sn);
  74. $condition['refill_order.order_sn'] = ['in', $order_sn];
  75. if($type != 'notify') {
  76. $condition['vr_order.order_state'] = ORDER_STATE_SEND;
  77. }
  78. $order_list = $model_refill_order->getMerchantOrderList($condition,'','refill_order.*,vr_order.order_state');
  79. if($type == 'success') {
  80. foreach ($order_list as $order) {
  81. refill\util::manual_success($order['order_id']);
  82. }
  83. } elseif ($type == 'cancel') {
  84. foreach ($order_list as $order) {
  85. refill\util::manual_cancel($order['order_id']);
  86. }
  87. } elseif ($type == 'notify'){
  88. foreach ($order_list as $order) {
  89. if ($order['order_state'] == ORDER_STATE_SEND) {
  90. QueueClient::push("QueryRefillState", ['order_id' => $order['order_id']]);
  91. } else {
  92. QueueClient::push("NotifyMerchantComplete", ['order_id' => $order['order_id'], 'manual' => true]);
  93. }
  94. }
  95. } else {
  96. showMessage('手动操作类型错误');
  97. }
  98. showMessage('操作成功');
  99. } else {
  100. Tpl::showpage('refill.order.batch');
  101. }
  102. }
  103. }