xiaoyu преди 3 години
родител
ревизия
caa87d668e

+ 1 - 0
admin/control/control.php

@@ -9,6 +9,7 @@
 defined('InShopNC') or exit('Access Invalid!');
 require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_HELPER_PATH . '/refill/rquery.php');
 class SystemControl
 {
 	/**

+ 9 - 63
admin/control/order_search.php

@@ -14,73 +14,19 @@ class order_searchControl extends SystemControl
         $order_list = [];
         $_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']);
-            }
-        }
-
-        if(!empty($condition)) {
-            $condition['refill_order.inner_status'] = 0;
+        $rquery = new \refill\rquery($_GET);
+        $normal = $rquery->normal_cond_result();
+        $time   = $rquery->time_cond_result();
 
-            $start_unixtime = intval(strtotime($_GET['query_start_time']));
-            $end_unixtime = intval(strtotime($_GET['query_end_time']));
+        $cond = array_merge($normal, $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];
-            }
-            $order_list = $model_refill_order->getMerchantOrderList($condition, 200, 0,'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
-
-            $merchant_list = Model('')->table('merchant')->limit(1000)->select();
-            foreach ($merchant_list as  $value) {
-                $merchants[$value['mchid']] = $value;
-            }
-            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']);
-            }
-        }
         $merchant_list = $this->merchants();
         $provider_list = $this->providers();
+        if(!empty($normal)) {
+            $cond['inner_status'] = 0;
+            $order_list = $model_refill_order->getMerchantOrderList($cond, 200, 0,'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
+            $order_list = $this->OrderDataFormat($order_list, $merchant_list);
+        }
         Tpl::output('provider_list', $provider_list);
         Tpl::output('merchant_list', $merchant_list);
         Tpl::output('order_list', $order_list);

+ 4 - 29
admin/control/ordersendlist.php

@@ -250,15 +250,11 @@ class ordersendlistControl extends SystemControl
     {
         $model_refill_order = Model('refill_order');
 
-        $base_cond['refill_order.inner_status'] = 0;
+        $rquery = new \refill\rquery($_GET);
+        $base_cond = $rquery->normal_cond_result();
+        $base_cond['inner_status'] = 0;
         $base_cond['vr_order.order_state'] = ORDER_STATE_SEND;
 
-        $card_type = $_GET['card_type'];
-
-        if (!empty($_GET['store_id'])) {
-            $base_cond['vr_order.store_id'] = $_GET['store_id'];
-        }
-
         $cur_time = time();
         $period = 180;
         if(!empty($_GET['time'])) {
@@ -268,27 +264,6 @@ class ordersendlistControl extends SystemControl
         }
         $time_cond = $this->notify_time($cur_time,$period);
 
-        if (!empty($_GET['mchid'])) {
-            $base_cond['refill_order.mchid'] = $_GET['mchid'];
-        }
-
-        if (!empty($card_type))
-        {
-            if (in_array($card_type, ['1', '2', '4', '5', '6', '7'])) {
-                $base_cond['refill_order.card_type'] = $card_type;
-            }
-            if ($card_type == 'oil') {
-                $base_cond['refill_order.card_type'] = ['in', ['1', '2']];
-            }
-            if ($card_type == 'phone') {
-                $base_cond['refill_order.card_type'] = ['in', ['4', '5', '6']];
-            }
-        }
-
-        if (!empty($_GET['quality'])) {
-            $base_cond['refill_order.quality'] = $_GET['quality'];
-        }
-
         $orders_cond = array_merge($base_cond,$time_cond);
         if (!empty($_GET['order_query'])) {
             $this->updateOrderSend($orders_cond);
@@ -319,7 +294,7 @@ class ordersendlistControl extends SystemControl
         }else{
             $order_count = $special_stat[$_GET['store_id']]['order_count'];
         }
-        $order_list = $model_refill_order->getMerchantTimeOut($orders_cond, 200, $order_count, $fields, $order_by);
+        $order_list = $model_refill_order->getMerchantOrderList($orders_cond, 200, $order_count, $fields, $order_by);
         if(!empty($order_list)) {
             $order_list = $this->orderFormat($order_list, $merchant_list);
         }

+ 3 - 77
admin/control/refill_order.php

@@ -23,82 +23,9 @@ class refill_orderControl extends SystemControl
         if(empty($time_type) || !in_array($time_type,['order_time','notify_time'])) {
             $time_type = 'order_time';
         }
-
-        $normal_cond = function ($input)
-        {
-            $cond['inner_status'] = 0;
-
-            if (!empty($input['order_sn'])) {
-                $cond['refill_order.order_sn'] = $input['order_sn'];
-
-            }
-            if (!empty($input['mch_order'])) {
-                $cond['refill_order.mch_order'] = $input['mch_order'];
-            }
-            if (!empty($input['ch_trade_no'])) {
-                $cond['refill_order.ch_trade_no'] = $input['ch_trade_no'];
-            }
-            if (!empty($input['card_no'])) {
-                $cond['refill_order.card_no'] = $input['card_no'];
-            }
-            if (!empty($input['no_mchid'])) {
-                $no_mchid = explode(',', $input['no_mchid']);
-                $cond['refill_order.mchid'] = ['not in', $no_mchid];
-            }
-            if (!empty($input['no_amount'])) {
-                $no_amount = explode(',', $input['no_amount']);
-                $cond['refill_order.refill_amount'] = ['not in', $no_amount];
-            }
-
-            if (!empty($input['mchid'])) {
-                $cond['refill_order.mchid'] = $input['mchid'];
-            }
-            if (!empty($input['channel_name'])) {
-                $cond['refill_order.channel_name'] = $input['channel_name'];
-            }
-            if (!empty($input['store_id'])) {
-                $cond['vr_order.store_id'] = $input['store_id'];
-            }
-            if (!empty($input['refill_amount'])) {
-                $cond['refill_order.refill_amount'] = $input['refill_amount'];
-            }
-            if (!empty($input['quality'])) {
-                $cond['refill_order.quality'] = $input['quality'];
-            }
-            if(!empty($input['official_status']))
-            {
-                if($input['official_status'] == 1) {
-                    $cond['official_sn'] = '';
-                } elseif ($input['official_status'] == 2) {
-                    $cond['official_sn'] = ['neq', ''];
-                }
-            }
-
-            if (!empty($input['card_type'])) {
-                if (in_array($input['card_type'], ['1', '2', '4', '5', '6', '7'])) {
-                    $cond['refill_order.card_type'] = intval($input['card_type']);
-                }
-                if ($input['card_type'] == 'oil') {
-                    $cond['refill_order.card_type'] = ['in', [1, 2]];
-                }
-                if ($input['card_type'] == 'phone') {
-                    $cond['refill_order.card_type'] = ['in', [4, 5, 6]];
-                }
-            }
-
-            if(in_array($input['cardno_state'], ['0','1', '2', '4', '5'])) {
-                $cond['refill_order.cardno_state'] = $input['cardno_state'];
-            }
-            if(in_array($input['is_transfer'], ['0','1'])) {
-                $cond['refill_order.is_transfer'] = $input['is_transfer'];
-            }
-            if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
-            {
-                $cond['vr_order.order_state'] = $_GET['order_state'];
-            }
-
-            return $cond;
-        };
+        $rquery = new \refill\rquery($input);
+        $normal = $rquery->normal_cond_result();
+        $normal['inner_status'] = 0;
 
         if(isset($input['export'])) {
             $scope['export_time'] = 'order_time';
@@ -168,7 +95,6 @@ class refill_orderControl extends SystemControl
             showMessage('结束日期必须大于起始日期.');
         }
 
-        $normal = $normal_cond($input);
         if (!empty($input['export'])) {
             $this->export_execl($normal, $scope, $input);
         }

+ 9 - 47
admin/control/refill_order_manual.php

@@ -63,58 +63,20 @@ class refill_order_manualControl extends SystemControl
     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']);
-            }
-        }
+
+        $rquery = new \refill\rquery($_GET);
+        $normal = $rquery->normal_cond_result();
+        $time   = $rquery->time_cond_result();
+        $cond = array_merge($normal, $time);
+
         $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];
-            }
+        if(!empty($cond)) {
+            $cond['inner_status'] = 0;
 
-            $orders = $model_refill_order->getMerchantOrderList($condition, 400, 0,'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
+            $orders = $model_refill_order->getMerchantOrderList($cond, 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 = $this->unique_array($order_ids);

+ 19 - 19
admin/templates/default/refill.order.search.php

@@ -268,21 +268,21 @@
         <tr class="thead">
             <th class="align-center">编号</th>
             <th class="align-center">订单号</th>
-            <th class="align-center">机构编号</th>
-            <th class="align-center">机构名称</th>
-            <th class="align-center">充值卡号</th>
-            <th class="align-center">充值卡类型</th>
+            <th class="align-left">机构编号</th>
+            <th class="align-left">机构名称</th>
+            <th class="align-left">充值卡号</th>
+            <th class="align-left">充值卡类型</th>
             <th class="align-center">充值额度</th>
-            <th class="align-right">下单日期</th>
+            <th class="align-center">下单日期</th>
             <th class="align-right">耗时</th>
             <th class="align-center">订单状态</th>
-            <th class="align-center">运营商流水号</th>
+            <th class="align-left">运营商流水号</th>
             <th class="align-center">通道质量</th>
-            <th class="align-center">失败原因</th>
-            <th class="align-center">商家单号</th>
-            <th class="align-center">扣款金额</th>
-            <th class="align-center">渠道单号</th>
-            <th class="align-center">渠道名称</th>
+            <th class="align-left">失败原因</th>
+            <th class="align-left">商家单号</th>
+            <th class="align-right">扣款金额</th>
+            <th class="align-left">渠道单号</th>
+            <th class="align-left">渠道名称</th>
         </tr>
         </thead>
         <tbody id="tbody">
@@ -291,13 +291,13 @@
             foreach ($output['order_list'] as $key => $order) { ?>
                 <tr class="hover trFlex">
                     <td class="align-center"><?php echo $key + 1; ?></td>
-                    <td class="align-left"><?php echo $order['order_sn']; ?></td>
-                    <td class="align-center"><?php echo $order['mchid']; ?></td>
-                    <td class="align-center"><?php echo $order['mch_name']; ?></td>
+                    <td class="align-center"><?php echo $order['order_sn']; ?></td>
+                    <td class="align-left"><?php echo $order['mchid']; ?></td>
+                    <td class="align-left"><?php echo $order['mch_name']; ?></td>
                     <td class="align-left"><?php echo $order['card_no']; ?></td>
-                    <td class="align-center"><?php echo $order['card_type_text']; ?></td>
+                    <td class="align-left"><?php echo $order['card_type_text']; ?></td>
                     <td class="align-center"><?php echo $order['refill_amount']; ?></td>
-                    <td class="align-right">
+                    <td class="align-center">
                         <span class="doubleclick" data-order="<?php echo $order['order_sn']; ?>">
                             <?php echo date('Y-m-d H:i:s', $order['order_time']); ?>
                         </span>
@@ -319,12 +319,12 @@
                     </td>
                     <td class="align-center"><?php echo orderState($order); ?></td>
                     <td class="align-left"><?php echo $order['official_sn']; ?></td>
-                    <td class="align-left"><?php echo $order['quality_text']; ?></td>
+                    <td class="align-center"><?php echo $order['quality_text']; ?></td>
                     <td class="align-left"><?php echo $order['err_msg']; ?></td>
                     <td class="align-left"><?php echo $order['mch_order']; ?></td>
-                    <td class="align-center"><?php echo $order['mch_amount']; ?></td>
+                    <td class="align-right"><?php echo $order['mch_amount']; ?></td>
                     <td class="align-left" class="ch_trade_no"><?php echo $order['ch_trade_no']; ?></td>
-                    <td class="align-center"><?php echo $order['channel_name']; ?></td>
+                    <td class="align-left"><?php echo $order['channel_name']; ?></td>
                 </tr>
             <?php } ?>
         <?php } else { ?>

+ 131 - 0
helper/refill/rquery.php

@@ -0,0 +1,131 @@
+<?php
+
+namespace refill;
+
+class rquery
+{
+    public $normal_cond = [];
+    public $time_cond = [];
+    
+    public function __construct($input)
+    {
+        $this->ct_query_cond($input);
+        $this->ct_time_cond($input);
+    }
+
+    public function ct_query_cond($input)
+    {
+        if (!empty($input['order_sn'])) {
+            $this->normal_cond['refill_order.order_sn'] = $input['order_sn'];
+        }
+        if (!empty($input['mch_order'])) {
+            $this->normal_cond['refill_order.mch_order'] = $input['mch_order'];
+        }
+        if (!empty($input['ch_trade_no'])) {
+            $this->normal_cond['refill_order.ch_trade_no'] = $input['ch_trade_no'];
+        }
+        if (!empty($input['card_no'])) {
+            $this->normal_cond['refill_order.card_no'] = $input['card_no'];
+        }
+        if (!empty($input['no_mchid'])) {
+            $no_mchid = explode(',', $input['no_mchid']);
+            $this->normal_cond['refill_order.mchid'] = ['not in', $no_mchid];
+        }
+        if (!empty($input['no_amount'])) {
+            $no_amount = explode(',', $input['no_amount']);
+            $this->normal_cond['refill_order.refill_amount'] = ['not in', $no_amount];
+        }
+        if (!empty($input['mchid'])) {
+            $this->normal_cond['refill_order.mchid'] = $input['mchid'];
+        }
+        if (!empty($input['store_id'])) {
+            $this->normal_cond['vr_order.store_id'] = $input['store_id'];
+        }
+        if (!empty($input['refill_amount'])) {
+            $this->normal_cond['refill_order.refill_amount'] = $input['refill_amount'];
+        }
+        if (!empty($input['quality'])) {
+            $this->normal_cond['refill_order.quality'] = $input['quality'];
+        }
+        if(!empty($input['official_status'])) {
+            if($input['official_status'] == 1) {
+                $this->normal_cond['official_sn'] = '';
+            } elseif ($input['official_status'] == 2) {
+                $this->normal_cond['official_sn'] = ['neq', ''];
+            }
+        }
+        if (!empty($input['card_type'])) {
+            if (in_array($input['card_type'], ['1', '2', '4', '5', '6', '7'])) {
+                $this->normal_cond['refill_order.card_type'] = intval($input['card_type']);
+            }
+            if ($input['card_type'] == 'oil') {
+                $this->normal_cond['refill_order.card_type'] = ['in', [1, 2]];
+            }
+            if ($input['card_type'] == 'phone') {
+                $this->normal_cond['refill_order.card_type'] = ['in', [4, 5, 6]];
+            }
+        }
+        if(in_array($input['cardno_state'], ['0','1', '2', '4', '5'])) {
+            $this->normal_cond['refill_order.cardno_state'] = $input['cardno_state'];
+        }
+        if(in_array($input['is_transfer'], ['0','1'])) {
+            $this->normal_cond['refill_order.is_transfer'] = $input['is_transfer'];
+        }
+        if (in_array($input['order_state'], ['0', '10', '20', '30', '40']))
+        {
+            $this->normal_cond['vr_order.order_state'] = $input['order_state'];
+        }
+        if(!empty($input['card_nos'])) {
+            $card_nos = trim($input['card_nos'], ',');
+            $this->normal_cond['refill_order.card_no'] = ['in', $card_nos];
+        }
+        if (!empty($input['mch_orders'])) {
+            $mch_orders = rtrim($input['mch_orders'], ',');
+            $this->normal_cond['refill_order.mch_order'] = ['in', $mch_orders];
+        }
+        if(!empty($input['order_sns'])) {
+            $order_sns = trim($input['order_sns'], ',');
+            $this->normal_cond['refill_order.order_sn'] = ['in', $order_sns];
+        }
+    }
+
+    public function ct_time_cond($input)
+    {
+        $start = intval(strtotime($input['query_start_time']));
+        $end   = intval(strtotime($input['query_end_time']));
+
+        $today = strtotime(date('Y-m-d',time()));
+        $tomorrow = $today + 86400;
+
+        if($start <= 0) {
+            $start = $today;
+        }
+
+        $cur = time();
+        $cur = $cur - ($cur % 300) + 300;
+        if($end <= 0) {
+            $end = $cur;
+        }
+        $end_date = strtotime(date('Y-m-d',$end));
+
+        if ($end >= $start)
+        {
+            $add_end = $end_date + 86400 * 5;
+            if($add_end > $tomorrow) {
+                $add_end = $tomorrow;
+            }
+            $this->time_cond['refill_order.order_time'] = [['egt', $start], ['lt', $end], 'and'];
+            $this->time_cond['vr_order.add_time'] = [['egt', $start], ['elt', $add_end], 'and'];
+        }
+    }
+
+    public function normal_cond_result(): array
+    {
+        return $this->normal_cond;
+    }
+
+    public function time_cond_result(): array
+    {
+        return $this->time_cond;
+    }
+}