Browse Source

refill_balance_create

xiaoyu 3 years ago
parent
commit
9169fa1094
2 changed files with 18 additions and 3 deletions
  1. 17 3
      admin/control/orderstats.php
  2. 1 0
      admin/templates/default/system.refill.balance.php

+ 17 - 3
admin/control/orderstats.php

@@ -179,16 +179,30 @@ class orderstatsControl extends SystemControl
         $mod = Model('refill_balance');
         $mod = Model('refill_balance');
         $balance = $mod->getBalance(['balance_id' => $balance_id]);
         $balance = $mod->getBalance(['balance_id' => $balance_id]);
         if(empty($balance )) {
         if(empty($balance )) {
-            showMessage('记录不存在!');
+            exit(json_encode(['code' => false, 'msg' => '记录不存在!']));
         }
         }
 
 
-        $start_unixtime = intval(strtotime($_GET['query_start_time']));
-        $end_unixtime = intval(strtotime($_GET['query_end_time']));
+        $start_unixtime = intval(strtotime($_GET['selectStartDate']));
+        $end_unixtime = intval(strtotime($_GET['selectEndDate']));
+        if(empty($start_unixtime)) {
+            $start_unixtime = $balance['end_stamp'];
+        }
+        if(empty($end_unixtime)) {
+            exit(json_encode(['code' => false, 'msg' => '结束日期不能为空!']));
+        }
 
 
         $condition = [
         $condition = [
             'type' => $balance['type'], 'cid' => $balance['cid'], 'start' => $start_unixtime,
             'type' => $balance['type'], 'cid' => $balance['cid'], 'start' => $start_unixtime,
             'end'  => $end_unixtime, 'time_type' => $balance['time_type'], 'parent_id' => $balance_id
             'end'  => $end_unixtime, 'time_type' => $balance['time_type'], 'parent_id' => $balance_id
         ];
         ];
+
+        $manager = new task\manager();
+        $task = $manager->add_task('refill_balance_create',$condition,0);
+        if ($task->completed() && $task->success()) {
+            exit(json_encode(['code' => true, 'msg' => '操作成功,此记录已新建成功。']));
+        } else {
+            exit(json_encode(['code' => true, 'msg' => '操作成功,后台任务已开始新建,请稍后查看新数据']));
+        }
     }
     }
 
 
     public function refill_balance_rebuildOp()
     public function refill_balance_rebuildOp()

+ 1 - 0
admin/templates/default/system.refill.balance.php

@@ -327,6 +327,7 @@
                         mothod: 'get',
                         mothod: 'get',
                         success: function(res) {
                         success: function(res) {
                             console.log('success', res);
                             console.log('success', res);
+                            alert(res.msg)
                         }
                         }
                     })
                     })
                     layer.close(index);
                     layer.close(index);