|
@@ -812,12 +812,21 @@ class merchantControl extends SystemControl
|
|
|
{
|
|
|
$model_refill_order = Model('refill_order');
|
|
|
$condition['inner_status'] = 0;
|
|
|
+
|
|
|
+ $fSingle = false;
|
|
|
if (!empty($_GET['order_sn'])) {
|
|
|
$condition['refill_order.order_sn'] = $_GET['order_sn'];
|
|
|
+ $fSingle = true;
|
|
|
}
|
|
|
if (!empty($_GET['mch_order'])) {
|
|
|
$condition['refill_order.mch_order'] = $_GET['mch_order'];
|
|
|
+ $fSingle = true;
|
|
|
}
|
|
|
+ if (!empty($_GET['ch_trade_no'])) {
|
|
|
+ $condition['refill_order.ch_trade_no'] = $_GET['ch_trade_no'];
|
|
|
+ $fSingle = true;
|
|
|
+ }
|
|
|
+
|
|
|
if (!empty($_GET['mchid'])) {
|
|
|
$condition['refill_order.mchid'] = $_GET['mchid'];
|
|
|
}
|
|
@@ -827,13 +836,12 @@ class merchantControl extends SystemControl
|
|
|
if (!empty($_GET['store_id'])) {
|
|
|
$condition['vr_order.store_id'] = $_GET['store_id'];
|
|
|
}
|
|
|
- if (!empty($_GET['ch_trade_no'])) {
|
|
|
- $condition['refill_order.ch_trade_no'] = $_GET['ch_trade_no'];
|
|
|
- }
|
|
|
+
|
|
|
if (!empty($_GET['card_no'])) {
|
|
|
$condition['refill_order.card_no'] = $_GET['card_no'];
|
|
|
}
|
|
|
- if (!empty($_GET['card_type'])) {
|
|
|
+ if (!empty($_GET['card_type']))
|
|
|
+ {
|
|
|
if(in_array($_GET['card_type'] , ['1' , '2' , '4' , '5' , '6'])) {
|
|
|
$condition['refill_order.card_type'] = $_GET['card_type'];
|
|
|
}
|
|
@@ -845,38 +853,54 @@ class merchantControl extends SystemControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $start_unixtime = strtotime($_GET['query_start_time']);
|
|
|
- $end_unixtime = strtotime($_GET['query_end_time']);
|
|
|
- if ($start_unixtime > 0) {
|
|
|
- if($end_unixtime == 0){
|
|
|
- $end_unixtime = time();
|
|
|
- }
|
|
|
- $condition['refill_order.order_time'] = [ ['egt', $start_unixtime] , ['lt', $end_unixtime] , 'and'];
|
|
|
- }
|
|
|
- if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
|
|
|
+ if(!$fSingle)
|
|
|
{
|
|
|
- $condition['vr_order.order_state'] = $_GET['order_state'];
|
|
|
- if($_GET['order_state'] == ORDER_STATE_SEND)
|
|
|
+ $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'];
|
|
|
+ }
|
|
|
+ elseif ($start_unixtime > 0) {
|
|
|
+ $condition['refill_order.order_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];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
|
|
|
{
|
|
|
- if($_GET['time'] == 1){
|
|
|
- $condition['refill_order.order_time'] = ['between', [(time() - 3600) , (time() - 1800)]];
|
|
|
- }
|
|
|
- if($_GET['time'] == 2){
|
|
|
- $condition['refill_order.order_time'] = ['lt', (time() - 3600)];
|
|
|
+ $condition['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)]];
|
|
|
+ }
|
|
|
+ if($_GET['time'] == 2){
|
|
|
+ $condition['refill_order.order_time'] = ['lt', (time() - 3600)];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ $merchants = [];
|
|
|
$merchant_list = Model('')->table('merchant')->limit(100)->select();
|
|
|
- foreach ($merchant_list as $key =>$value) {
|
|
|
+ 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');
|
|
|
|
|
|
$stat = $this->all_order_state_stat($condition);
|
|
|
+
|
|
|
$count = $this->refill_stat($condition ,
|
|
|
[['between', [(time() - 3600) , (time() - 1800)]],
|
|
|
['lt', (time() - 3600)]]
|
|
|
);
|
|
|
+
|
|
|
foreach ($order_list as $order_id => $order_info)
|
|
|
{
|
|
|
$order_list[$order_id]['card_type_text'] = $this->scard_type($order_info['card_type']);
|
|
@@ -892,7 +916,13 @@ class merchantControl extends SystemControl
|
|
|
$order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
|
|
|
$order_list[$order_id]['diff_time'] = $diff_time;
|
|
|
}
|
|
|
- $provider_list = Model('')->table('refill_provider,store')->field('refill_provider.*,store.store_name')->join('inner')->on('store.store_id=refill_provider.store_id')->limit(100)->select();
|
|
|
+
|
|
|
+ $provider_list = Model('')->table('refill_provider,store')
|
|
|
+ ->field('refill_provider.*,store.store_name')
|
|
|
+ ->join('inner')
|
|
|
+ ->on('store.store_id=refill_provider.store_id')
|
|
|
+ ->limit(100)
|
|
|
+ ->select();
|
|
|
|
|
|
Tpl::output('stat', $stat);
|
|
|
Tpl::output('count', $count);
|
|
@@ -1347,7 +1377,7 @@ class merchantControl extends SystemControl
|
|
|
};
|
|
|
$result = [];
|
|
|
$condition['order_state'] = ORDER_STATE_SEND;
|
|
|
- foreach($times as $time) {
|
|
|
+ foreach ($times as $time) {
|
|
|
$condition['refill_order.order_time'] = $time;
|
|
|
$result[] = $stat_order($condition);
|
|
|
}
|
|
@@ -1356,31 +1386,33 @@ class merchantControl extends SystemControl
|
|
|
|
|
|
private function all_order_state_stat($condition)
|
|
|
{
|
|
|
- $stat_order = function ($condition) {
|
|
|
- return Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
- ->on('refill_order.order_id=vr_order.order_id')
|
|
|
- ->field('count(*) as order_count ,sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts, order_state')
|
|
|
- ->where($condition)->group('order_state')->select();
|
|
|
- };
|
|
|
+ $counts = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->field('count(*) as order_count, sum(refill_amount) as refill_amounts, sum(channel_amount) as channel_amounts, sum(mch_amount) as mch_amounts, order_state')
|
|
|
+ ->where($condition)
|
|
|
+ ->group('order_state')
|
|
|
+ ->select();
|
|
|
+
|
|
|
$all = [];
|
|
|
$data['order_count'] = $data['refill_amounts'] = $data['channel_amounts'] = $data['mch_amounts'] = 0;
|
|
|
$sending = $success = $cancel = $data;
|
|
|
- $counts = $stat_order($condition);
|
|
|
- foreach ($counts as $count){
|
|
|
- if($count['order_state'] == ORDER_STATE_SEND) {
|
|
|
+ foreach ($counts as $count)
|
|
|
+ {
|
|
|
+ if ($count['order_state'] == ORDER_STATE_SEND) {
|
|
|
$sending = $count;
|
|
|
- }elseif ($count['order_state'] == ORDER_STATE_SUCCESS) {
|
|
|
+ } elseif ($count['order_state'] == ORDER_STATE_SUCCESS) {
|
|
|
$success = $count;
|
|
|
- }elseif($count['order_state'] == ORDER_STATE_CANCEL) {
|
|
|
+ } elseif ($count['order_state'] == ORDER_STATE_CANCEL) {
|
|
|
$cancel = $count;
|
|
|
}
|
|
|
+
|
|
|
$all['order_count'] += $count['order_count'];
|
|
|
$all['refill_amounts'] += ncPriceFormat($count['refill_amounts']);
|
|
|
$all['channel_amounts'] += ncPriceFormat($count['channel_amounts']);
|
|
|
$all['mch_amounts'] += ncPriceFormat($count['mch_amounts']);
|
|
|
}
|
|
|
|
|
|
- return ['all' => $all , 'sending' => $sending , 'success' => $success , 'cancel' => $cancel];
|
|
|
+ return ['all' => $all, 'sending' => $sending, 'success' => $success, 'cancel' => $cancel];
|
|
|
}
|
|
|
|
|
|
|