Переглянути джерело

admin order query and mch_notify add form where

xiaoyu 3 роки тому
батько
коміт
1c9ad1a539

+ 0 - 40
admin/control/merchant.php

@@ -746,46 +746,6 @@ class merchantControl extends SystemControl
         echo 'true';
     }
 
-    public function OrderQueryOp()
-    {
-        $model_vr_order = Model('vr_order');
-        $condition['order_state'] = ORDER_STATE_SEND;
-        $orders = $model_vr_order->getOrderList($condition);
-        if (!empty($orders)) {
-            foreach ($orders as $order) {
-                $order_id = $order['order_id'];
-                QueueClient::push("QueryRefillState", ['order_id' => $order_id]);
-            }
-        }
-        showMessage('操作成功', 'index.php?act=refill_order&op=index');
-    }
-
-    public function mch_notifyOp()
-    {
-        $model_refill_order = Model('refill_order');
-
-        $condition['mch_notify_state'] = 0;
-        $condition['inner_status'] = 0;
-        $condition['is_retrying'] = 0;
-
-        $orders = $model_refill_order->getMerchantOrderList($condition, 1000, 'refill_order.*,vr_order.order_state', 'refill_order.order_time desc');
-        if (!empty($orders))
-        {
-            foreach ($orders as $order)
-            {
-                $order_id = $order['order_id'];
-                if ($order['order_state'] == ORDER_STATE_SEND) {
-                    QueueClient::push("QueryRefillState", ['order_id' => $order_id]);
-                } else {
-                    QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true]);
-                }
-            }
-        }
-
-        showMessage('操作成功', 'index.php?act=refill_order&op=index');
-    }
-
-
     public function notify_merchantOp()
     {
         $order_id = $_GET['order_id'];

+ 41 - 0
admin/control/ordersendlist.php

@@ -88,6 +88,10 @@ class ordersendlistControl extends SystemControl
         if (!empty($_GET['quality'])) {
             $condition['refill_order.quality'] = $_GET['quality'];
         }
+        if (!empty($_GET['order_query'])) {
+            $this->OrderQuery($condition);
+            exit;
+        }
 
         $order_list = $model_refill_order->getMerchantTimeOut($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.quality asc,refill_order.order_time asc');
 //        $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time asc');
@@ -325,4 +329,41 @@ class ordersendlistControl extends SystemControl
         }
         showMessage('操作成功');
     }
+
+    private function OrderQuery($condition)
+    {
+        $condition['order_state'] = ORDER_STATE_SEND;
+        $orders = $this->getAllTimeOutOrders($condition);
+        if (!empty($orders)) {
+            foreach ($orders as $order) {
+                $order_id = $order['order_id'];
+                QueueClient::push("QueryRefillState", ['order_id' => $order_id]);
+            }
+        }
+        showMessage('操作成功');
+    }
+
+    private function getAllTimeOutOrders($condition): array
+    {
+        $i = 0;
+        $orders = [];
+        while (true) {
+            $start = $i * 1000;
+            $order_list = Model('')->table('refill_order,vr_order,merchant')
+                ->join('inner,inner')
+                ->on('refill_order.order_id=vr_order.order_id,refill_order.mchid=merchant.mchid')
+                ->field('refill_order.*,vr_order.order_state')
+                ->where($condition)
+                ->order('refill_order.order_time desc')
+                ->limit("{$start},1000")->select();
+            if (empty($order_list)) {
+                break;
+            }
+            $i++;
+            foreach ($order_list as $order) {
+                $orders[] = $order;
+            }
+        }
+        return $orders;
+    }
 }

+ 65 - 14
admin/control/refill_order.php

@@ -110,6 +110,15 @@ class refill_orderControl extends SystemControl
 
         if (!empty($_GET['export']) || !empty($_GET['export_stats'])) {
             $this->RefillOrderExport($condition);
+            exit;
+        }
+        if (!empty($_GET['mch_notify'])) {
+            $this->mch_notify($condition);
+            exit;
+        }
+        if (!empty($_GET['order_query'])) {
+            $this->OrderQuery($condition);
+            exit;
         }
         $merchants = [];
         $merchant_list = $this->merchants();
@@ -218,20 +227,7 @@ class refill_orderControl extends SystemControl
                 unset($condition['refill_order.order_time']);
             }
         }
-        $i = 0;
-        $result = [];
-        while (true) {
-            $start = $i * 1000;
-            $order_list = Model('')->table('refill_order,vr_order')->field('refill_order.*,vr_order.order_state')
-                ->where($condition)->join('inner')->on('refill_order.order_id=vr_order.order_id')->order('refill_order.order_time desc')->limit("{$start},1000")->select();
-            if (empty($order_list)) {
-                break;
-            }
-            $i++;
-            foreach ($order_list as $order) {
-                $result[] = $order;
-            }
-        }
+        $result = $this->getAllOrders($condition);
         $this->createExcel($result);
     }
 
@@ -420,4 +416,59 @@ class refill_orderControl extends SystemControl
         ];
         exit(json_encode($res));
     }
+
+    private function mch_notify($condition)
+    {
+        $condition['mch_notify_state'] = 0;
+        $condition['inner_status'] = 0;
+        $condition['is_retrying'] = 0;
+
+        $orders = $this->getAllOrders($condition);
+        if (!empty($orders))
+        {
+            foreach ($orders as $order)
+            {
+                $order_id = $order['order_id'];
+                if ($order['order_state'] == ORDER_STATE_SEND) {
+                    QueueClient::push("QueryRefillState", ['order_id' => $order_id]);
+                } else {
+                    QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true]);
+                }
+            }
+        }
+
+        showMessage('操作成功');
+    }
+
+    private function OrderQuery($condition)
+    {
+        $condition['order_state'] = ORDER_STATE_SEND;
+        $orders = $this->getAllOrders($condition);
+        if (!empty($orders)) {
+            foreach ($orders as $order) {
+                $order_id = $order['order_id'];
+                QueueClient::push("QueryRefillState", ['order_id' => $order_id]);
+            }
+        }
+        showMessage('操作成功');
+    }
+
+    private function getAllOrders($condition): array
+    {
+        $i = 0;
+        $orders = [];
+        while (true) {
+            $start = $i * 1000;
+            $order_list = Model('')->table('refill_order,vr_order')->field('refill_order.*,vr_order.order_state')
+                ->where($condition)->join('inner')->on('refill_order.order_id=vr_order.order_id')->order('refill_order.order_time desc')->limit("{$start},1000")->select();
+            if (empty($order_list)) {
+                break;
+            }
+            $i++;
+            foreach ($order_list as $order) {
+                $orders[] = $order;
+            }
+        }
+        return $orders;
+    }
 }

+ 56 - 8
admin/templates/default/refill.order.index.php

@@ -102,6 +102,8 @@
         <input type="hidden" name="act" value="refill_order"/>
         <input type="hidden" name="op" value="index"/>
         <input type="hidden" name="export" value=""/>
+        <input type="hidden" name="mch_notify" value=""/>
+        <input type="hidden" name="order_query" value=""/>
         <input type="hidden" name="export_stats" value=""/>
         <input type="hidden" name="fShowStat" value=""/>
         <input type="hidden" name="no_mchid" value=""/>
@@ -284,10 +286,10 @@
                 </td>
                 <td></td>
                 <td>
-                    <a href="index.php?act=merchant&op=OrderQuery" class="btns" >
+                    <a href="javascript:void(0);" id="order_query" class="btns" >
                         <span><i class="icon-edit"></i>更新待收货订单状态</span>
                     </a>
-                    <a href="index.php?act=merchant&op=mch_notify" class="btns" >
+                    <a href="javascript:void(0);" id="mch_notify" class="btns" >
                         <span><i class="icon-edit"></i>向客户回调</span>
                     </a>
                 </td>
@@ -457,14 +459,20 @@
                     <td class="align-center"><?php echo $order['org_quality_text']; ?></td>
                     <!--                    <td class="align-center">--><?php //echo $order['mch_amount']; ?><!--</td>-->
                     <td class="align-center">
+
+                        <?php if( ($order['order_state'] == ORDER_STATE_CANCEL || $order['order_state'] == ORDER_STATE_SUCCESS) && $order['is_retrying'] == 0){?>
                         <a href="index.php?act=merchant&op=notify_merchant&order_id=<?php echo $order['order_id']; ?>">
                                 回调</a>
-                        |
-                        <a href="index.php?act=merchant&op=notify_manual_merchant&type=cancel&order_id=<?php echo $order['order_id']; ?>">
-                            手动失败</a>
-                        |
-                        <a href="index.php?act=merchant&op=notify_manual_merchant&type=success&order_id=<?php echo $order['order_id']; ?>">
-                            手动成功</a>
+                        <?php }?>
+
+                        <?php if($order['order_state'] == ORDER_STATE_SEND){?>
+                            <a href="index.php?act=merchant&op=notify_manual_merchant&type=cancel&order_id=<?php echo $order['order_id']; ?>">
+                                手动失败</a>
+                            |
+                            <a href="index.php?act=merchant&op=notify_manual_merchant&type=success&order_id=<?php echo $order['order_id']; ?>">
+                                手动成功</a>
+                        <?php }?>
+
                         <?php if($order['card_type'] == mtopcard\ThirdRefillCard){?>
                             |
                             <a href="#" class="examine" data-order="<?php echo $order['order_id']; ?>">
@@ -701,6 +709,46 @@
             $('#formSearch').submit();
             $('input[name="fShowStat"]').val('');
         })
+        // 向客户回调
+        $('#mch_notify').click(function () {
+
+            $('input[name="mch_notify"]').val('1');
+            $('input[name="op"]').val('index');
+            // 不包含客户
+            let selectArr = selest_nc.getValue();
+            let selectStr = ''
+            for (let i = 0; i < selectArr.length; i++) {
+                selectStr += selectArr[i].value+','
+            }
+            selectStr = selectStr.substr(0, selectStr.length-1)
+            $('input[name="no_mchid"]').val(selectStr);
+            $('#formSearch').submit();
+            $('input[name="mch_notify"]').val('');
+            var ii = layer.load();
+            setTimeout(function(){
+                layer.close(ii);
+            }, 800);
+        })
+        // 更新待收货状态
+        $('#order_query').click(function () {
+
+            $('input[name="order_query"]').val('1');
+            $('input[name="op"]').val('index');
+            // 不包含客户
+            let selectArr = selest_nc.getValue();
+            let selectStr = ''
+            for (let i = 0; i < selectArr.length; i++) {
+                selectStr += selectArr[i].value+','
+            }
+            selectStr = selectStr.substr(0, selectStr.length-1)
+            $('input[name="no_mchid"]').val(selectStr);
+            $('#formSearch').submit();
+            $('input[name="order_query"]').val('');
+            var ii = layer.load();
+            setTimeout(function(){
+                layer.close(ii);
+            }, 800);
+        })
         // 日期选择器
         laydate.render({
             elem: '#startTime',

+ 15 - 1
admin/templates/default/refill.order.send.index.php

@@ -77,6 +77,7 @@
     <form method="get" action="index.php" name="formSearch" id="formSearch">
         <input type="hidden" name="act" value="OrderSendList"/>
         <input type="hidden" name="op" value="index"/>
+        <input type="hidden" name="order_query" value=""/>
         <table class="tb-type1 noborder search">
             <tr>
                 <th><label>客户名称</label></th>
@@ -205,7 +206,7 @@
         <table class="tb-type1 noborder search">
             <tr>
                 <td>
-                    <a href="index.php?act=merchant&op=OrderQuery" class="btns">
+                    <a href="javascript:void(0);" id="order_query" class="btns" >
                         <span><i class="icon-edit"></i>更新待收货订单状态</span>
                     </a>
                     <a href="#" class="btns" onclick="hCopyOrder(event)">
@@ -488,6 +489,19 @@
                 $(this).css('color', 'red')
             }
         })
+
+        // 更新待收货状态
+        $('#order_query').click(function () {
+
+            $('input[name="order_query"]').val('1');
+            $('input[name="op"]').val('index');
+            $('#formSearch').submit();
+            $('input[name="order_query"]').val('');
+            var ii = layer.load();
+            setTimeout(function(){
+                layer.close(ii);
+            }, 800);
+        })
     });
     function hCopyOrder(e) {
         let str = ''