123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- require_once(BASE_HELPER_PATH . '/refill/util.php');
- use refill\util;
- class refill_order_manualControl extends SystemControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function indexOp()
- {
- $model_refill_order = Model('refill_order');
- $condition['inner_status'] = 0;
- $order_list = [];
- if (!empty($_GET['order_sn'])) {
- $condition['refill_order.order_sn'] = $_GET['order_sn'];
- $merchants = [];
- $merchant_list = Model('')->table('merchant')->limit(1000)->select();
- foreach ($merchant_list as $key => $value) {
- $merchants[$value['mchid']] = $value;
- }
- $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc','',true);
- foreach ($order_list as $order_id => $order_info) {
- $order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
- $order_list[$order_id]['mch_name'] = $merchants[$order_info['mchid']]['company_name'];
- if ($order_info['notify_time'] > 0) {
- $diff_time = $order_info['notify_time'] - $order_info['order_time'];
- } else {
- $diff_time = time() - $order_info['order_time'];
- }
- $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
- $order_list[$order_id]['diff_time'] = $diff_time;
- $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality'],$order_info['card_type']);
- $order_list[$order_id]['org_quality_text'] = $this->quality_format($order_info['org_quality'],$order_info['card_type']);
- }
- }
- 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]);
- if ((time() - $order_info['order_time']) < 3600) {
- showMessage('订单时间未超过1小时', 'index.php?act=refill_order&op=index');
- }
- $mod_refill = Model('refill_order');
- $logic_vr_order = Logic("vr_order");
- $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id]);
- 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()
- {
- if (chksubmit()) {
- $model_refill_order = Model('refill_order');
- $condition = [];
- $type = $_POST['type'];
- $order_sn = $_POST['order_sn'];
- $order_sn = str_replace(["\r\n", "\r", "\n"], ",", $order_sn);
- $condition['refill_order.order_sn'] = ['in', $order_sn];
- if($type != 'notify') {
- $condition['vr_order.order_state'] = ORDER_STATE_SEND;
- }
- $order_list = $model_refill_order->getMerchantOrderList($condition,'','refill_order.*,vr_order.order_state');
- if($type == 'success') {
- foreach ($order_list as $order) {
- refill\util::manual_success($order['order_id']);
- }
- } elseif ($type == 'cancel') {
- foreach ($order_list as $order) {
- refill\util::manual_cancel($order['order_id']);
- }
- } elseif ($type == 'notify'){
- foreach ($order_list 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]);
- }
- }
- } else {
- showMessage('手动操作类型错误');
- }
- showMessage('操作成功');
- } else {
- Tpl::showpage('refill.order.batch');
- }
- }
- }
|