refill_order_manual.php 5.5 KB

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