|
@@ -1,8 +1,8 @@
|
|
|
<?php
|
|
|
|
|
|
require_once(BASE_HELPER_PATH . '/refill/util.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/task/task_helper.php');
|
|
|
|
|
|
-use refill\util;
|
|
|
class refill_orderControl extends SystemControl
|
|
|
{
|
|
|
public function __construct()
|
|
@@ -19,66 +19,66 @@ class refill_orderControl extends SystemControl
|
|
|
public function refill_order($fShowStat = false)
|
|
|
{
|
|
|
$model_refill_order = Model('refill_order');
|
|
|
- $condition['inner_status'] = 0;
|
|
|
+ $cond['inner_status'] = 0;
|
|
|
$_GET['query_start_time'] = $_GET['query_start_time'] ?? date("Y-m-d H:i:s", strtotime("-1 hours"));
|
|
|
|
|
|
if (!empty($_GET['order_sn'])) {
|
|
|
- $condition['refill_order.order_sn'] = $_GET['order_sn'];
|
|
|
+ $cond['refill_order.order_sn'] = $_GET['order_sn'];
|
|
|
|
|
|
}
|
|
|
if (!empty($_GET['mch_order'])) {
|
|
|
- $condition['refill_order.mch_order'] = $_GET['mch_order'];
|
|
|
+ $cond['refill_order.mch_order'] = $_GET['mch_order'];
|
|
|
|
|
|
}
|
|
|
if (!empty($_GET['ch_trade_no'])) {
|
|
|
- $condition['refill_order.ch_trade_no'] = $_GET['ch_trade_no'];
|
|
|
+ $cond['refill_order.ch_trade_no'] = $_GET['ch_trade_no'];
|
|
|
|
|
|
}
|
|
|
if (!empty($_GET['card_no'])) {
|
|
|
- $condition['refill_order.card_no'] = $_GET['card_no'];
|
|
|
+ $cond['refill_order.card_no'] = $_GET['card_no'];
|
|
|
|
|
|
}
|
|
|
if (!empty($_GET['no_mchid'])) {
|
|
|
$no_mchid = explode(',', $_GET['no_mchid']);
|
|
|
- $condition['refill_order.mchid'] = ['not in', $no_mchid];
|
|
|
+ $cond['refill_order.mchid'] = ['not in', $no_mchid];
|
|
|
}
|
|
|
if (!empty($_GET['no_amount'])) {
|
|
|
$no_amount = explode(',', $_GET['no_amount']);
|
|
|
- $condition['refill_order.refill_amount'] = ['not in', $no_amount];
|
|
|
+ $cond['refill_order.refill_amount'] = ['not in', $no_amount];
|
|
|
}
|
|
|
|
|
|
if (!empty($_GET['mchid'])) {
|
|
|
- $condition['refill_order.mchid'] = $_GET['mchid'];
|
|
|
+ $cond['refill_order.mchid'] = $_GET['mchid'];
|
|
|
}
|
|
|
if (!empty($_GET['channel_name'])) {
|
|
|
- $condition['refill_order.channel_name'] = $_GET['channel_name'];
|
|
|
+ $cond['refill_order.channel_name'] = $_GET['channel_name'];
|
|
|
}
|
|
|
if (!empty($_GET['store_id'])) {
|
|
|
- $condition['vr_order.store_id'] = $_GET['store_id'];
|
|
|
+ $cond['vr_order.store_id'] = $_GET['store_id'];
|
|
|
}
|
|
|
if (!empty($_GET['refill_amount'])) {
|
|
|
- $condition['refill_order.refill_amount'] = $_GET['refill_amount'];
|
|
|
+ $cond['refill_order.refill_amount'] = $_GET['refill_amount'];
|
|
|
}
|
|
|
if (!empty($_GET['quality'])) {
|
|
|
- $condition['refill_order.quality'] = $_GET['quality'];
|
|
|
+ $cond['refill_order.quality'] = $_GET['quality'];
|
|
|
}
|
|
|
if(!empty($_GET['official_status'])) {
|
|
|
if($_GET['official_status'] == 1) {
|
|
|
- $condition['official_sn'] = '';
|
|
|
+ $cond['official_sn'] = '';
|
|
|
} elseif ($_GET['official_status'] == 2) {
|
|
|
- $condition['official_sn'] = ['neq', ''];
|
|
|
+ $cond['official_sn'] = ['neq', ''];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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']);
|
|
|
+ $cond['refill_order.card_type'] = intval($_GET['card_type']);
|
|
|
}
|
|
|
if ($_GET['card_type'] == 'oil') {
|
|
|
- $condition['refill_order.card_type'] = ['in', [1, 2]];
|
|
|
+ $cond['refill_order.card_type'] = ['in', [1, 2]];
|
|
|
}
|
|
|
if ($_GET['card_type'] == 'phone') {
|
|
|
- $condition['refill_order.card_type'] = ['in', [4, 5, 6]];
|
|
|
+ $cond['refill_order.card_type'] = ['in', [4, 5, 6]];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -87,56 +87,58 @@ class refill_orderControl extends SystemControl
|
|
|
$end_unixtime = intval(strtotime($_GET['query_end_time']));
|
|
|
|
|
|
if($end_unixtime <= 0) {
|
|
|
- $end_unixtime = time();
|
|
|
+ $cur_time = time();
|
|
|
+ $cur_time = $cur_time - ($cur_time % 300) + 300;
|
|
|
+ $end_unixtime = $cur_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'];
|
|
|
+ $cond['refill_order.order_time'] = [['egt', $start_unixtime], ['lt', $end_unixtime], 'and'];
|
|
|
+ $cond['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];
|
|
|
+ $cond['refill_order.order_time'] = ['egt', $start_unixtime];
|
|
|
+ $cond['vr_order.add_time'] = ['egt', $start_unixtime];
|
|
|
} elseif ($end_unixtime > 0) {
|
|
|
- $condition['refill_order.order_time'] = ['lt', $end_unixtime];
|
|
|
+ $cond['refill_order.order_time'] = ['lt', $end_unixtime];
|
|
|
} else {
|
|
|
$start = time() - 3600;
|
|
|
$_GET['query_start_time'] = date("Y-m-d H:i:s",$start);
|
|
|
- $condition['refill_order.order_time'] = ['egt', $start];
|
|
|
- $condition['vr_order.add_time'] = ['egt', $start-1];
|
|
|
+ $cond['refill_order.order_time'] = ['egt', $start];
|
|
|
+ $cond['vr_order.add_time'] = ['egt', $start-1];
|
|
|
$fToday = true;
|
|
|
}
|
|
|
|
|
|
if(in_array($_GET['cardno_state'], ['0','1', '2', '4', '5'])) {
|
|
|
- $condition['refill_order.cardno_state'] = $_GET['cardno_state'];
|
|
|
+ $cond['refill_order.cardno_state'] = $_GET['cardno_state'];
|
|
|
}
|
|
|
if(in_array($_GET['is_transfer'], ['0','1'])) {
|
|
|
- $condition['refill_order.is_transfer'] = $_GET['is_transfer'];
|
|
|
+ $cond['refill_order.is_transfer'] = $_GET['is_transfer'];
|
|
|
}
|
|
|
|
|
|
if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
|
|
|
{
|
|
|
- $condition['vr_order.order_state'] = $_GET['order_state'];
|
|
|
+ $cond['vr_order.order_state'] = $_GET['order_state'];
|
|
|
|
|
|
if ($_GET['order_state'] == ORDER_STATE_SEND) {
|
|
|
if ($_GET['time'] == 1) {
|
|
|
- $condition['refill_order.order_time'] = ['between', [(time() - 3600), (time() - 1800)]];
|
|
|
+ $cond['refill_order.order_time'] = ['between', [(time() - 3600), (time() - 1800)]];
|
|
|
}
|
|
|
if ($_GET['time'] == 2) {
|
|
|
- $condition['refill_order.order_time'] = ['lt', (time() - 3600)];
|
|
|
+ $cond['refill_order.order_time'] = ['lt', (time() - 3600)];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!empty($_GET['export']) || !empty($_GET['export_stats'])) {
|
|
|
- $this->RefillOrderExport($condition);
|
|
|
+ $this->RefillOrderExport($cond);
|
|
|
exit;
|
|
|
}
|
|
|
if (!empty($_GET['mch_notify'])) {
|
|
|
- $this->mch_notify($condition);
|
|
|
+ $this->mch_notify($cond);
|
|
|
exit;
|
|
|
}
|
|
|
if (!empty($_GET['order_query'])) {
|
|
|
- $this->updateOrderSend($condition);
|
|
|
+ $this->updateOrderSend($cond);
|
|
|
exit;
|
|
|
}
|
|
|
$merchants = [];
|
|
@@ -144,7 +146,7 @@ class refill_orderControl extends SystemControl
|
|
|
foreach ($merchant_list as $value) {
|
|
|
$merchants[$value['mchid']] = $value;
|
|
|
}
|
|
|
- $order_list = $model_refill_order->getMerchantOrderList($condition, 200, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc');
|
|
|
+ $order_list = $model_refill_order->getMerchantOrderList($cond, 200, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc');
|
|
|
|
|
|
foreach ($order_list as $order_id => $order_info) {
|
|
|
$order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
|
|
@@ -162,9 +164,15 @@ class refill_orderControl extends SystemControl
|
|
|
|
|
|
$provider_list = $this->providers();
|
|
|
|
|
|
- if ($fShowStat) {
|
|
|
- $stat = $this->all_order_state_stat($condition);
|
|
|
- Tpl::output('stat', $stat);
|
|
|
+ if ($fShowStat)
|
|
|
+ {
|
|
|
+ $manager = new task\manager();
|
|
|
+ $task = $manager->add_task('refill_order_stat',$cond,0);
|
|
|
+ if($task->completed() && $task->success())
|
|
|
+ {
|
|
|
+ $stat = $task->result();
|
|
|
+ Tpl::output('stat', $stat);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$dispatcher_queue_length = refill\util::dispatcher_queue_length();
|
|
@@ -187,8 +195,23 @@ class refill_orderControl extends SystemControl
|
|
|
unset($condition['vr_order.add_time']);
|
|
|
}
|
|
|
}
|
|
|
- $result = $this->getAllOrders($condition);
|
|
|
- $this->createExcel($result);
|
|
|
+// $result = Model('refill_order')->getAllOrders($condition);
|
|
|
+// $this->createExcel($result);
|
|
|
+
|
|
|
+ $hash = $this->task_hash_check($condition, 'order_export');
|
|
|
+
|
|
|
+ $insert['task_type'] = 'order_export';
|
|
|
+ $insert['add_time'] = time();
|
|
|
+ $insert['task_hash'] = $hash;
|
|
|
+ $insert['task_params'] = serialize($condition);
|
|
|
+
|
|
|
+ $model = Model('refill_task');
|
|
|
+ $resp = $model->insert($insert);
|
|
|
+ if($resp) {
|
|
|
+ showMessage("录入成功,任务ID:{$resp}", 'index.php?act=OrderStats&&op=refill_task');
|
|
|
+ }else{
|
|
|
+ showMessage('任务添加失败');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function createExcel($data = array())
|
|
@@ -386,7 +409,7 @@ class refill_orderControl extends SystemControl
|
|
|
$condition['inner_status'] = 0;
|
|
|
$condition['is_retrying'] = 0;
|
|
|
|
|
|
- $orders = $this->getAllOrders($condition);
|
|
|
+ $orders = Model('refill_order')->getAllOrders($condition);
|
|
|
if (!empty($orders))
|
|
|
{
|
|
|
foreach ($orders as $order)
|
|
@@ -406,7 +429,7 @@ class refill_orderControl extends SystemControl
|
|
|
private function updateOrderSend($condition)
|
|
|
{
|
|
|
$condition['order_state'] = ORDER_STATE_SEND;
|
|
|
- $orders = $this->getAllOrders($condition);
|
|
|
+ $orders = Model('refill_order')->getAllOrders($condition);
|
|
|
|
|
|
if (!empty($orders)) {
|
|
|
foreach ($orders as $order) {
|
|
@@ -417,30 +440,4 @@ class refill_orderControl extends SystemControl
|
|
|
}
|
|
|
showMessage('操作成功');
|
|
|
}
|
|
|
-
|
|
|
- private function getAllOrders($condition): array
|
|
|
- {
|
|
|
- $len = 1000;
|
|
|
-
|
|
|
- $i = 0;
|
|
|
- $orders = [];
|
|
|
- while (true)
|
|
|
- {
|
|
|
- $start = $i * $len;
|
|
|
- $items = Model('')->table('refill_order,vr_order')
|
|
|
- ->field('refill_order.*,vr_order.order_state')
|
|
|
- ->join('inner')
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
- ->where($condition)
|
|
|
- ->order('refill_order.order_time desc')
|
|
|
- ->limit("{$start},{$len}")
|
|
|
- ->select();
|
|
|
- $orders = array_merge($orders,$items);
|
|
|
- if (empty($items) || count($items) < $len) {
|
|
|
- break;
|
|
|
- }
|
|
|
- $i++;
|
|
|
- }
|
|
|
- return $orders;
|
|
|
- }
|
|
|
}
|