浏览代码

orderstats reload

xiaoyu 3 年之前
父节点
当前提交
bfd32a1418

+ 25 - 0
admin/control/orderstats.php

@@ -1,4 +1,5 @@
 <?php
+require_once(BASE_HELPER_PATH . '/task/task_helper.php');
 
 
 class orderstatsControl extends SystemControl
@@ -18,6 +19,13 @@ class orderstatsControl extends SystemControl
         if (!empty($_GET['order_time_type'])) {
             $condition['order_time_type'] = $_GET['order_time_type'];
         }
+        if(!empty($_GET['reload'])) {
+            $stats_list = $model_refill_order->getAllRefillStats($condition);
+            $this->stats_reload($stats_list);
+            $json_str = json_encode($condition);
+            $this->log("对账管理,批量重新统计,条件:{$json_str}", 1);
+            showMessage('操作完成');
+        }
         $stats_list = $model_refill_order->getOrderStatsList($condition, 50, '*', 'time_stamp desc, cname asc');
         if($type == 'merchant') {
             foreach ($stats_list as $key => $stats) {
@@ -38,6 +46,23 @@ class orderstatsControl extends SystemControl
         Tpl::showpage($page);
     }
 
+    private function stats_reload($stats_list)
+    {
+        foreach ($stats_list as $stats)
+        {
+            if($stats['send_count'] == 0) continue;
+            $cond = [
+                'type' => $stats['type'],
+                'time_stamp' => $stats['time_stamp'],
+                'cid' => $stats['cid'],
+                'order_time_type' => $stats['order_time_type']
+            ];
+            $manager = new task\manager();
+
+            $manager->add_task('order_stat_reload',$cond,0,3600);
+        }
+    }
+
     private function ct_cond($input,$time_stamp)
     {
         $condition['type'] = $input['type'];

+ 16 - 4
admin/templates/default/merchant.order.stats.php

@@ -44,7 +44,7 @@
         <input type="hidden" value="merchant" name="type">
         <input type="hidden" name="cid" value=""/>
         <input type="hidden" name="default_no_mch" value="<?php echo $_GET['cid']; ?>"/>
-        
+        <input type="hidden" name="reload" value=""/>
         <table class="tb-type1 noborder search">
             <tbody>
             <tr>
@@ -87,6 +87,11 @@
                         <span>导出</span>
                     </a>
                 </td>
+                <td>
+                    <a href="javascript:void(0);" id="ncreload" class="btn">
+                        <span>批量重新统计</span>
+                    </a>
+                </td>
             </tr>
             </tbody>
         </table>
@@ -241,8 +246,16 @@
       href="<?php echo ADMIN_TEMPLATES_URL; ?>/layui/css/layui.css"/>
 <script>
     $(function () {
+        $("#ncreload").click(function () {
+            $('input[name="reload"]').val('1');
+            select_set()
+            $('#formSearch').submit();
+        })
         $('#ncsubmit').click(function () {
-            $('input[name="op"]').val('index');
+            select_set()
+            $('#formSearch').submit();
+        });
+        function select_set(){
             let selectArr = selest_nc.getValue();
             let selectStr = ''
             for (let i = 0; i < selectArr.length; i++) {
@@ -251,8 +264,7 @@
             selectStr = selectStr.substr(0, selectStr.length-1)
             $('input[name="cid"]').val(selectStr);
             console.log("selectStr", selectStr);
-            $('#formSearch').submit();
-        });
+        }
         // 日期选择器
         laydate.render({
             elem: '#startTime',

+ 16 - 4
admin/templates/default/provider.order.stats.php

@@ -44,6 +44,7 @@
         <input type="hidden" value="provider" name="type">
         <input type="hidden" name="cid" value=""/>
         <input type="hidden" name="default_no_mch" value="<?php echo $_GET['cid']; ?>"/>
+        <input type="hidden" name="reload" value=""/>
         <table class="tb-type1 noborder search">
             <tbody>
             <tr>
@@ -78,6 +79,11 @@
                         <span>导出</span>
                     </a>
                 </td>
+                <td>
+                    <a href="javascript:void(0);" id="ncreload" class="btn">
+                        <span>批量重新统计</span>
+                    </a>
+                </td>
             </tr>
             </tbody>
         </table>
@@ -236,8 +242,16 @@
 <link rel="stylesheet" type="text/css" href="<?php echo ADMIN_TEMPLATES_URL; ?>/layui/css/layui.css"/>
 <script>
     $(function () {
+        $("#ncreload").click(function () {
+            $('input[name="reload"]').val('1');
+            select_set()
+            $('#formSearch').submit();
+        })
         $('#ncsubmit').click(function () {
-            $('input[name="op"]').val('index');
+            select_set()
+            $('#formSearch').submit();
+        });
+        function select_set(){
             let selectArr = selest_nc.getValue();
             let selectStr = ''
             for (let i = 0; i < selectArr.length; i++) {
@@ -245,9 +259,7 @@
             }
             selectStr = selectStr.substr(0, selectStr.length-1)
             $('input[name="cid"]').val(selectStr);
-            $('#formSearch').submit();
-            $('input[name="cid"]').val('');
-        });
+        }
         // 日期选择器
         laydate.render({
             elem: '#startTime',

+ 25 - 0
data/model/refill_order.model.php

@@ -189,4 +189,29 @@ class refill_orderModel extends Model
         }
         return $orders;
     }
+
+    public function getAllRefillStats($condition)
+    {
+        $len = 1000;
+
+        $i = 0;
+        $stats = [];
+        $field = '*';
+        while (true)
+        {
+            $start = $i * $len;
+            $items = $this->table('refill_stats')
+                ->field($field)
+                ->where($condition)
+                ->order('time_stamp desc')
+                ->limit("{$start},{$len}")
+                ->select();
+            $stats = array_merge($stats,$items);
+            if (empty($items) || count($items) < $len) {
+                break;
+            }
+            $i++;
+        }
+        return $stats;
+    }
 }