refill_order_manual.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. $mod_refill = Model('refill_order');
  47. $logic_vr_order = Logic("vr_order");
  48. $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id]);
  49. $check_fetch_order = $this->check_fetch_order($order_info['order_sn']);
  50. if($check_fetch_order == false) {
  51. showMessage('此订单不可手动操作,请联系抢单人员操作!');
  52. }
  53. if ($type == 'success') {
  54. $logic_vr_order->changeOrderStateSuccess($order_id,true);
  55. } elseif ($type == 'cancel') {
  56. $logic_vr_order->changeOrderStateCancel($order_info, '', "充值失败", true, true);
  57. } else {
  58. showMessage('手动操作类型错误', 'index.php?act=refill_order&op=index');
  59. }
  60. if($refill_info['notify_time'] == 0) {
  61. $mod_refill->edit($order_id, ['notify_state' =>1, 'notify_time' => time()]);
  62. }
  63. util::pop_queue_order($refill_info['mchid'],$refill_info['mch_order']);
  64. QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true]);
  65. showMessage('操作成功');
  66. }
  67. public function refill_order_batchOp()
  68. {
  69. if (chksubmit()) {
  70. $model_refill_order = Model('refill_order');
  71. $condition = [];
  72. $type = $_POST['type'];
  73. $order_sn = $_POST['order_sn'];
  74. $order_sn = str_replace(["\r\n", "\r", "\n"], ",", $order_sn);
  75. $condition['refill_order.order_sn'] = ['in', $order_sn];
  76. if($type != 'notify') {
  77. $condition['vr_order.order_state'] = ORDER_STATE_SEND;
  78. }
  79. $order_list = $model_refill_order->getMerchantOrderList($condition,'','refill_order.*,vr_order.order_state');
  80. if($type == 'success') {
  81. foreach ($order_list as $order) {
  82. $check_fetch_order = $this->check_fetch_order($order['order_sn']);
  83. if($check_fetch_order == false) continue;
  84. refill\util::manual_success($order['order_id']);
  85. }
  86. } elseif ($type == 'cancel') {
  87. foreach ($order_list as $order) {
  88. $check_fetch_order = $this->check_fetch_order($order['order_sn']);
  89. if($check_fetch_order == false) continue;
  90. refill\util::manual_cancel($order['order_id']);
  91. }
  92. } elseif ($type == 'notify'){
  93. foreach ($order_list as $order) {
  94. if ($order['order_state'] == ORDER_STATE_SEND) {
  95. QueueClient::push("QueryRefillState", ['order_id' => $order['order_id']]);
  96. } else {
  97. QueueClient::push("NotifyMerchantComplete", ['order_id' => $order['order_id'], 'manual' => true]);
  98. }
  99. }
  100. } else {
  101. showMessage('手动操作类型错误');
  102. }
  103. showMessage('操作成功');
  104. } else {
  105. Tpl::showpage('refill.order.batch');
  106. }
  107. }
  108. }