Browse Source

admin neterr list batch exec

xiaoyu 3 years atrás
parent
commit
4045b1aad1

+ 64 - 19
admin/control/ordersendlist.php

@@ -1,6 +1,9 @@
 <?php
-
 require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_HELPER_PATH . '/refill/util.php');
+
+use refill\util;
+
 class ordersendlistControl extends SystemControl
 {
     public function __construct()
@@ -30,13 +33,13 @@ class ordersendlistControl extends SystemControl
         if ($_GET['time'] == 2) {
             $condition['refill_order.order_time'] = ['lt', (time() - 3600)];
         }
-        $time_out_order = function($time_out, $condition){
+        $time_out_order = function ($time_out, $condition) {
             $mchids = Model('')->table('merchant')->where(['time_out' => ['elt', $time_out]])->field('mchid')->select();
             $mchids = array_column($mchids, 'mchid');
             $mchids = implode(',', $mchids);
 
             $condition['refill_order.order_time'] = ['lt', (time() - $time_out)];
-            $condition['refill_order.mchid'] = ['in',$mchids];
+            $condition['refill_order.mchid'] = ['in', $mchids];
             return $condition;
         };
         if ($_GET['time'] == 3) {
@@ -86,11 +89,11 @@ class ordersendlistControl extends SystemControl
             ->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')
             ->where($condition)->find();
-        $count = $this->refill_stats($condition,$time_cond);
+        $count = $this->refill_stats($condition, $time_cond);
 
         $merchant_list = Model('')->table('merchant')->limit(1000)->order('name asc')->select();
 
-        $order_list = $this->orderFormat($order_list,$merchant_list);
+        $order_list = $this->orderFormat($order_list, $merchant_list);
         $provider_list = Model('')->table('refill_provider,store')
             ->field('refill_provider.*,store.store_name')
             ->join('inner')
@@ -129,7 +132,7 @@ class ordersendlistControl extends SystemControl
     public function neterr_orderOp()
     {
         $model_refill_order = Model('refill_order');
-        if(!empty($_GET['store_id'])) {
+        if (!empty($_GET['store_id'])) {
             $condition['vr_order.store_id'] = $_GET['store_id'];
         }
         $condition['refill_order.inner_status'] = 0;
@@ -138,7 +141,7 @@ class ordersendlistControl extends SystemControl
 
         $order_list = $model_refill_order->getMerchantOrderList($condition, 50, 'refill_order.*,vr_order.order_state', 'refill_order.order_time asc');
         $merchant_list = Model('')->table('merchant')->limit(1000)->order('name asc')->select();
-        $order_list = $this->orderFormat($order_list,$merchant_list);
+        $order_list = $this->orderFormat($order_list, $merchant_list);
 
         $provider_list = Model('')->table('refill_provider,store')
             ->field('refill_provider.*,store.store_name')
@@ -153,6 +156,48 @@ class ordersendlistControl extends SystemControl
         Tpl::showpage('refill.order.neterr.index');
     }
 
+    public function neterr_order_manualOp()
+    {
+        $type = $_GET['type'];
+        $official_sn = $_GET['official_sn'] ?? '';
+        if ($type != 'success' && $type != 'cancel') {
+            showMessage('手动操作类型错误');
+        }
+        $order_ids = $_GET['order_ids'];
+        $model_refill_order = Model('refill_order');
+        $condition['refill_order.order_id'] = ['in', $order_ids];
+        $condition['refill_order.inner_status'] = 0;
+        $condition['refill_order.neterr'] = 1;
+        $condition['vr_order.order_state'] = ORDER_STATE_PAY;
+
+        $order_list = $model_refill_order->getMerchantOrderList($condition);
+        if (empty($order_list)) {
+            showMessage('暂无数据');
+        }
+        $logic_vr_order = Logic("vr_order");
+        $mod_vr_order = Model('vr_order');
+        foreach ($order_list as $order) {
+            $order_id = $order['order_id'];
+            if ($type == 'success') {
+                $logic_vr_order->changeOrderStateSuccess($order_id, true);
+                if (!empty($official_sn)) {
+                    $model_refill_order->edit($order_id, ['official_sn' => $official_sn]);
+                }
+            } elseif ($type == 'cancel') {
+                $order_info = $mod_vr_order->getOrderInfo(['order_id' => $order_id]);
+                $logic_vr_order->changeOrderStateCancel($order_info, '', "充值失败", true, true);
+            } else {
+                continue;
+            }
+            if ($order['notify_time'] == 0) {
+                $model_refill_order->edit($order_id, ['notify_state' => 1, 'notify_time' => time()]);
+            }
+            util::pop_queue_order($order['mchid'], $order['mch_order']);
+            QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true]);
+        }
+        showMessage('操作成功');
+    }
+
     public function orderFormat($order_list, $merchant_list): array
     {
         $merchants = [];
@@ -170,13 +215,13 @@ class ordersendlistControl extends SystemControl
 
             $order_list[$order_id]['diff_time'] = $diff_time;
             $order_list[$order_id]['diff_time_text'] = $this->elapse_time($diff_time);
-            $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality'],$order_info['card_type']);
-            if($diff_time > $merchants[$order_info['mchid']]['time_out'] && $order_info['order_state'] == ORDER_STATE_SEND) {
+            $order_list[$order_id]['quality_text'] = $this->quality_format($order_info['quality'], $order_info['card_type']);
+            if ($diff_time > $merchants[$order_info['mchid']]['time_out'] && $order_info['order_state'] == ORDER_STATE_SEND) {
                 $order_list[$order_id]['time_out_state'] = 0;
-                if(in_array($order_info['card_type'],[mtopcard\PetroChinaCard,mtopcard\SinopecCard]) && $diff_time >= 1800) {
+                if (in_array($order_info['card_type'], [mtopcard\PetroChinaCard, mtopcard\SinopecCard]) && $diff_time >= 1800) {
                     $order_list[$order_id]['time_out_state'] = 1;
                 }
-                if(in_array($order_info['card_type'],[mtopcard\ChinaMobileCard,mtopcard\ChinaUnicomCard,mtopcard\ChinaTelecomCard])) {
+                if (in_array($order_info['card_type'], [mtopcard\ChinaMobileCard, mtopcard\ChinaUnicomCard, mtopcard\ChinaTelecomCard])) {
                     if (in_array($order_info['quality'], [
                         \refill\Quality::SlowTwentyFour,
                         \refill\Quality::SlowSix,
@@ -184,14 +229,14 @@ class ordersendlistControl extends SystemControl
                         \refill\Quality::SlowFortyEight,
                         \refill\Quality::SlowSeventyTwo])) {
                         $order_list[$order_id]['time_out_state'] = 2;
-                    } elseif(in_array($order_info['mchid'],[10132])) {
+                    } elseif (in_array($order_info['mchid'], [10132])) {
                         //重点机构
                         $order_list[$order_id]['time_out_state'] = 3;
                     } else {
                         $order_list[$order_id]['time_out_state'] = 4;
                     }
                 }
-            }else{
+            } else {
                 $order_list[$order_id]['time_out_state'] = 0;
             }
         }
@@ -206,12 +251,12 @@ class ordersendlistControl extends SystemControl
         $order_state_cancel = ORDER_STATE_CANCEL;
         $order_state_success = ORDER_STATE_SUCCESS;
         $condition['refill_order.inner_status'] = 0;
-        $condition['vr_order.order_state'] = ['in',"{$order_state_cancel},{$order_state_success}"];
+        $condition['vr_order.order_state'] = ['in', "{$order_state_cancel},{$order_state_success}"];
         $condition['refill_order.mch_notify_state'] = 0;
-        if(empty($_GET['time'])) {
+        if (empty($_GET['time'])) {
             $_GET['time'] = 1;
         }
-        if(empty($_GET['notify_time'])) {
+        if (empty($_GET['notify_time'])) {
             $_GET['notify_time'] = 180;
         }
         $time = $_GET['time'] * 3600;
@@ -223,7 +268,7 @@ class ordersendlistControl extends SystemControl
 
         $order_list = $model_refill_order->getMerchantOrderList($condition, '', 'refill_order.*,vr_order.order_state', 'refill_order.notify_time asc', 1000);
         $merchant_list = Model('')->table('merchant')->limit(1000)->order('name asc')->select();
-        $order_list = $this->orderFormat($order_list,$merchant_list);
+        $order_list = $this->orderFormat($order_list, $merchant_list);
 
         $provider_list = Model('')->table('refill_provider,store')
             ->field('refill_provider.*,store.store_name')
@@ -240,7 +285,7 @@ class ordersendlistControl extends SystemControl
 
     public function notifyerr_all_notifyOp()
     {
-        if(empty($_GET['time']) || empty($_GET['notify_time'])) {
+        if (empty($_GET['time']) || empty($_GET['notify_time'])) {
             showMessage('日期条件错误');
         }
         $model_refill_order = Model('refill_order');
@@ -248,7 +293,7 @@ class ordersendlistControl extends SystemControl
         $order_state_cancel = ORDER_STATE_CANCEL;
         $order_state_success = ORDER_STATE_SUCCESS;
         $condition['refill_order.inner_status'] = 0;
-        $condition['vr_order.order_state'] = ['in',"{$order_state_cancel},{$order_state_success}"];
+        $condition['vr_order.order_state'] = ['in', "{$order_state_cancel},{$order_state_success}"];
         $condition['refill_order.mch_notify_state'] = 0;
 
         $time = $_GET['time'] * 3600;

+ 102 - 1
admin/templates/default/refill.order.neterr.index.php

@@ -107,6 +107,9 @@
                     <a href="#" class="btns" onclick="hCopyCardNo(event)">
                         <span><i class="icon-edit"></i>拷贝充值卡号</span>
                     </a>
+                    <a href="#" class="btns"  id="hFail">
+                        <span><i class="icon-edit"></i>批量失败</span>
+                    </a>
                 </td>
             </tr>
         </table>
@@ -114,6 +117,7 @@
     <table class="table tb-type2 nobdb">
         <thead>
         <tr class="thead">
+            <th class="align-center" id="selectAll">全选</th>
             <th class="align-center">编号</th>
             <th class="align-center">订单号</th>
             <th class="align-center">机构编号</th>
@@ -124,12 +128,14 @@
             <th class="align-right">下单日期</th>
             <th class="align-right">耗时</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-center">渠道单号</th>
             <th class="align-center">渠道名称</th>
+            <th class="align-center"><?php echo $lang['nc_handle']; ?></th>
         </tr>
         </thead>
         <tbody id="tbody">
@@ -137,6 +143,9 @@
             <?php
             foreach ($output['order_list'] as $key => $order) { ?>
                 <tr class="hover trFlex">
+                    <td class="align-center">
+                        <input type="checkbox" id="checkBoxList" name="checkbox" value="<?php echo $order['order_id'];?>">
+                    </td>
                     <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>
@@ -163,12 +172,23 @@
                         <?php } ?>
                     </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-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-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-center">
+                        <!-- <a href="#">
+                                回调</a>
+                        | -->
+                        <a class="hsuccess" data_id="<?php echo $order['order_id']; ?>" href="#" id="hsuccess">
+                        手动成功</a>
+                        |
+                        <a class="hcancel" data_id="<?php echo $order['order_id']; ?>" href="#" id="hcancel">
+                        手动失败</a>
+                    </td>
                 </tr>
             <?php } ?>
         <?php } else { ?>
@@ -204,8 +224,89 @@
         });
         $('#query_start_time').datepicker({dateFormat: 'yy-mm-dd'});
         $('#query_end_time').datepicker({dateFormat: 'yy-mm-dd'});
+                  //全选
+         $('#selectAll' ).click ( function () {
+          if ($(this).text() == '全选') {
+              $("input[name='checkbox']").each(function() {
+                  this.checked = true;
+              })
+              $(this).text("取消全选")
+          } else {
+              $("input[name='checkbox']").each(function() {
+                  this.checked = false;
+              })
+              $(this).text("全选")
+
+          }
+     
+
+            })
+            //批量
+             $('#hFail').click(function () {
+                layer.confirm('您确定要批量失败', {
+                btn: ['确定','取消'],
+                title:'批量失败'
+                }, function(){
+
+
+                let arr = [];
+                $("input:checkbox:checked").each(function (i) {
+                arr[i] = $(this).val();
+            })
+            let str = arr.join(",");
+            // console.log(str);
+            if (str != '') {
+            window.location.href =`index.php?act=ordersendlist&op=neterr_order_manual&order_ids= ${str ? str : ''}&type=cancel`
+            console.log(str);
+            // layer.msg('批量成功', {icon: 1});
+
+            } else {
+                layer.msg('请还没有任何操作,请先选择');
+            }
+
+		
+
+            }, function(){
+            });
+            })
+            //手动成功
+            $('.hsuccess').click(function() {
+                let succid = $(this).attr('data_id');
+                layer.prompt({
+
+                    // formType:  1 ,
+                    title:  '请输入运营商流水号' ,
+                    // area: [ '500px' ,  '150px' ],
+                    // btnAlign:  'c' ,
+                    yes: function(index, layero){
+                        // 获取文本框输入的值
+                        var value = layero.find( ".layui-layer-input" ).val();
+                        console.log(value);
+                        if  (value) {
+                            window.location.href =`index.php?act=ordersendlist&op=neterr_order_manual&order_ids= ${succid}&type=success&official_sn= ${value}`
+                            // layer.close(index);
+                        }  else  {
+                            window.location.href =`index.php?act=ordersendlist&op=neterr_order_manual&order_ids= ${succid}&type=success`
+                        }
+                    }
+                    });
+            })
+            //手动失败
+            $('.hcancel').click(function() {
+                let succid = $(this).attr('data_id');
+                layer.confirm('确定要手动失败 ?', {
+                  btn: ['确定','失败'] //按钮
+                }, function(){
+                    window.location.href =`index.php?act=ordersendlist&op=neterr_order_manual&order_ids= ${succid}&type=cancel`
+                }, function(){
+               
+                  });
+                });
+           
+
+
                         //双击
-                        $('.doubleclick').dblclick(function() {
+             $('.doubleclick').dblclick(function() {
             let db_click = $(this).attr('data-order')
             $.get('index.php?act=refill_order&op=showOrders', {
                 order_sn:db_click

+ 1 - 1
test/TestCardNo.php

@@ -41,7 +41,7 @@ class TestCardNo extends TestCase
 
     public function testTianYanValidPhone()
     {
-        [$validate,$card_type,$region_no,$isTransfer] = mtopcard\valid_phone('15120035568');
+        [$validate,$card_type,$region_no,$isTransfer] = mtopcard\valid_phone('15975503200');
         Log::record("validate={$validate} card_type={$card_type} region_no={$region_no}",Log::DEBUG);
     }