merchants(); $order_list = $model_refill_order->getMerchantOrderList($condition, 50,0, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc','',true); $order_list = $this->OrderDataFormat($order_list, $merchant_list); } Tpl::output('order_list', $order_list); Tpl::showpage('refill.order.manual.index'); } public function notify_manual_merchantOp() { $order_id = $_GET['order_id']; $type = $_GET['type']; $mod_order = Model('vr_order'); $order_info = $mod_order->getOrderInfo(['order_id' => $order_id]); $mod_refill = Model('refill_order'); $logic_vr_order = Logic("vr_order"); $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id,'inner_status' => 0,'is_retrying' => 0]); if(empty($refill_info)) { showMessage('订单不存在,或不符合条件', ''); } $check_fetch_order = $this->check_fetch_order($order_info['order_sn']); if($check_fetch_order == false) { showMessage('此订单不可手动操作,请联系抢单人员操作!'); } if ($type == 'success') { $logic_vr_order->changeOrderStateSuccess($order_id,true); } elseif ($type == 'cancel') { $logic_vr_order->changeOrderStateCancel($order_info, '', "充值失败", true, true); } else { showMessage('手动操作类型错误', 'index.php?act=refill_order&op=index'); } if($refill_info['notify_time'] == 0) { $mod_refill->edit($order_id, ['notify_state' =>1, 'notify_time' => time()]); } util::pop_queue_order($refill_info['mchid'],$refill_info['mch_order']); QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true]); showMessage('操作成功'); } public function refill_order_batchOp() { $model_refill_order = Model('refill_order'); $condition = []; $orders = []; $_GET['query_start_time'] = $_GET['query_start_time'] ?? date("Y-m-d 00:00:00"); if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40'])) { $condition['vr_order.order_state'] = $_GET['order_state']; } if (!empty($_GET['mchid'])) { $condition['refill_order.mchid'] = $_GET['mchid']; } if (!empty($_GET['store_id'])) { $condition['vr_order.store_id'] = $_GET['store_id']; } //批量查询,二者都有,以卡号为主 if(!empty($_GET['card_nos'])) { $card_nos = trim($_GET['card_nos'], ','); $condition['refill_order.card_no'] = ['in', $card_nos]; } elseif (!empty($_GET['mch_orders'])) { $mch_orders = rtrim($_GET['mch_orders'], ','); $condition['refill_order.mch_order'] = ['in', $mch_orders]; } if(!empty($_GET['order_sns'])) { $order_sns = trim($_GET['order_sns'], ','); $condition['refill_order.order_sn'] = ['in', $order_sns]; } if (!empty($_GET['card_type'])) { if (in_array($_GET['card_type'], ['1', '2', '4', '5', '6', '7'])) { $condition['refill_order.card_type'] = intval($_GET['card_type']); } } $merchant_list = $this->merchants(); $provider_list = $this->providers(); if(!empty($condition)) { $condition['refill_order.inner_status'] = 0; $start_unixtime = intval(strtotime($_GET['query_start_time'])); $end_unixtime = intval(strtotime($_GET['query_end_time'])); if ($start_unixtime > 0 && $end_unixtime > $start_unixtime) { $condition['refill_order.order_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and']; $condition['vr_order.add_time'] = [['egt', $start_unixtime],['lt', $end_unixtime], 'and']; } elseif ($start_unixtime > 0) { $condition['refill_order.order_time'] = ['egt', $start_unixtime]; $condition['vr_order.add_time'] = ['egt', $start_unixtime]; } elseif ($end_unixtime > 0) { $condition['refill_order.order_time'] = ['lt', $end_unixtime]; } else { $start = strtotime(date('Y-m-d', time())); $condition['refill_order.order_time'] = ['egt', $start]; $condition['vr_order.add_time'] = ['egt', $start]; } $int_array = function ($sids) { $result = []; foreach ($sids as $sid) { $result[] = intval($sid); } return $result; }; $unique_array = function ($ids) { $ids = array_unique($ids); sort($ids); return $ids; }; $orders = $model_refill_order->getMerchantOrderList($condition, 400, 0,'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC '); $orders = $this->OrderDataFormat($orders, $merchant_list); $order_ids = array_column($orders,'order_id'); $order_ids = $unique_array($order_ids); $refill_buyback_model = Model('refill_buyback'); $buybacks = $refill_buyback_model->getList(['order_id' => ['in',$order_ids]]); $buyback_ids = array_column($buybacks, 'order_id'); $buyback_ids = $int_array($buyback_ids); $buyback_ids = $unique_array($buyback_ids); foreach ($orders as $key => $order) { if($order['order_state'] != ORDER_STATE_SUCCESS) { $order[$key]['buyback'] = false; continue; } $order_id = intval($order['order_id']); if(algorithm::binary_search($buyback_ids,$order_id)) { $orders[$key]['buyback'] = true; }else{ $orders[$key]['buyback'] = false; } } } Tpl::output('merchant_list', $merchant_list); Tpl::output('provider_list', $provider_list); Tpl::output('order_list', $orders); Tpl::output('show_page', $model_refill_order->showpage()); Tpl::showpage('refill.order.batch'); } public function refill_order_batch_disposeOp() { $int_array = function ($sids) { $result = []; foreach ($sids as $sid) { $result[] = intval($sid); } return $result; }; $unique_array = function ($ids) { $ids = array_unique($ids); sort($ids); return $ids; }; $oid_reader = function ($sids) use ($int_array,$unique_array) { $sids = explode(',',$sids); $ids = $int_array($sids); return $unique_array($ids); }; $oper_type = $_GET['type']; $order_ids = $oid_reader($_GET['order_id']); $cond = []; $cond['refill_order.order_id'] = ['in',$order_ids]; $cond['refill_order.is_retrying'] = 0; if ($oper_type == 'success' || $oper_type == 'cancel') { $cond['vr_order.order_state'] = ORDER_STATE_SEND; } elseif ($oper_type == 'buyback') { $cond['vr_order.order_state'] = ORDER_STATE_SUCCESS; } $model_refill_order = Model('refill_order'); $orders = $model_refill_order->getMerchantOrderList($cond,'',0,'refill_order.*,vr_order.order_state','refill_order.order_id desc',2000); if($oper_type == 'success') { foreach ($orders as $order) { $check_fetch_order = $this->check_fetch_order($order['order_sn']); if($check_fetch_order == false) continue; refill\util::manual_success($order['order_id']); } } elseif ($oper_type == 'cancel') { foreach ($orders as $order) { $check_fetch_order = $this->check_fetch_order($order['order_sn']); if($check_fetch_order == false) continue; refill\util::manual_cancel($order['order_id']); } } elseif ($oper_type == 'notify') { foreach ($orders as $order) { if ($order['order_state'] == ORDER_STATE_SEND) { QueueClient::push("QueryRefillState", ['order_id' => $order['order_id']]); } else { QueueClient::push("NotifyMerchantComplete", ['order_id' => $order['order_id'], 'manual' => true]); } } } elseif ($oper_type == 'buyback') { $refill_buyback_model = Model('refill_buyback'); $buybacks = $refill_buyback_model->getList(['order_id' => ['in',$order_ids]]); $buyback_ids = array_column($buybacks, 'order_id'); $buyback_ids = $int_array($buyback_ids); $buyback_ids = $unique_array($buyback_ids); foreach ($orders as $order) { $order_id = intval($order['order_id']); if(!algorithm::binary_search($buyback_ids,$order_id)) { $ins[] = ['order_id' => $order['order_id'], 'order_sn' => $order['order_sn'],'order_time' => $order['order_time'], 'notify_time' => $order['notify_time']]; } } if(!empty($ins)) { $refill_buyback_model->insertAll($ins); } } else { showMessage('手动操作类型错误'); } showMessage('操作成功'); } public function set_cancel_orderOp() { $mod = Model('refill_order'); $condition = []; $order_list = []; $mch_orderData = []; if(!empty($_GET['mchid'])) { $condition['mchid'] = $_GET['mchid']; } if (!empty($_GET['mch_orders'])) { $mch_orders = rtrim($_GET['mch_orders'],','); $condition['mch_order'] = ['in', $mch_orders]; } $merchant_list = $this->merchants(); if(!empty($condition)) { $condition['inner_status'] = 0; $order_list = $mod->getMerchantOrderList($condition, 200, 0,'refill_order.*,vr_order.order_state', 'refill_order.order_time desc'); $order_list = $this->OrderDataFormat($order_list, $merchant_list); if(empty($mch_orders)) { $mch_orderData = []; }else{ $mch_orderData = explode(',',$mch_orders); } foreach ($order_list as $order_id => $order) { $mch_order = $order['mch_order']; if(in_array($mch_order, $mch_orderData)) { $key = array_search($mch_order, $mch_orderData); unset($mch_orderData[$key]); } $order_list[$order_id]['can_cancel'] = $this->can_cancel_order($order); } } Tpl::output('noexist_mch_order', $mch_orderData); Tpl::output('merchant_list', $merchant_list); Tpl::output('list', $order_list); Tpl::output('show_page', $mod->showpage()); Tpl::showpage('set.cancel.order'); } public function order_cancel_disposeOp() { $order_id = $_GET['order_id']; $condition['refill_order.order_id'] = ['in',$order_id]; $order_list = Model('refill_order')->getMerchantOrderList($condition,1000,0,'refill_order.*,vr_order.order_state'); foreach ($order_list as $order) { if($this->can_cancel_order($order)) { $mchid = $order['mchid']; $mch_order = $order['mch_order']; refill\util::set_cancel_order($mchid,$mch_order); $this->log("拦截订单,订单号:{$order['order_sn']},商家单号:{$mch_order},机构编码:{$mchid}", 1); } } showMessage('操作成功'); } private function can_cancel_order($order): bool { if($order['order_state'] == ORDER_STATE_SUCCESS) { return false; } if($order['order_state'] == ORDER_STATE_CANCEL && $order['is_retrying'] == 0) { return false; } return true; } public function refill_buybackOp() { $model_refill_order = Model('refill_order'); $order_list = []; if(!empty($_GET['card_nos'])) { $card_nos = trim($_GET['card_nos'], ','); $condition['refill_order.card_no'] = ['in', $card_nos]; } if(!empty($_GET['order_sns'])) { $order_sns = trim($_GET['order_sns'], ','); $condition['refill_order.order_sn'] = ['in', $order_sns]; } if(!empty($condition)) { $condition['inner_status'] = 0; $merchant_list = $this->merchants(); $order_list = $model_refill_order->getBuyBackList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc','',true); $order_list = $this->OrderDataFormat($order_list, $merchant_list); } Tpl::output('order_list', $order_list); Tpl::showpage('refill.buyback.order'); } }