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

充值管理,根据查询计算总金额和总茶宝

董荣正 1 місяць тому
батько
коміт
ee2b6766f7

+ 1 - 1
.env.sample

@@ -1,5 +1,5 @@
 [app]
-debug = true
+debug = false
 trace = false
 
 [database]

+ 71 - 3
application/admin/controller/offline/OfflineRecharge.php

@@ -31,7 +31,7 @@ class OfflineRecharge extends Backend
      * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
-       /**
+    /**
      * 查看
      *
      * @return string|Json
@@ -42,6 +42,14 @@ class OfflineRecharge extends Backend
     {
         //设置过滤方法
         $this->request->filter(['strip_tags', 'trim']);
+        $filter = $this->request->get('filter');
+        $filter = json_decode($filter, true);
+        $data=$filter;
+        // 统一计算统计值
+        $amount = $this->get($filter,'amount');
+        $cha_bao = $this->get($filter,'cha_bao');
+
+
         if (false === $this->request->isAjax()) {
             return $this->view->fetch();
         }
@@ -54,9 +62,69 @@ class OfflineRecharge extends Backend
             ->where($where)
             ->order($sort, $order)
             ->paginate($limit);
-  
-        $result = ['total' => $list->total(), 'rows' => $list->items(), 'total_revenue'=> 669];
+
+        
+
+        $result = ['total' => $list->total(), 'rows' => $list->items(), 'amount' => $amount, 'cha_bao' => $cha_bao, 'total_revenue' => 669];
         return json($result);
     }
+    private function get($filter,$key){
+        
+
+
+        // 统一时间范围解析
+        $createTimeRange = $this->parseTimeRange('create_time', $filter);
+        $updateTimeRange = $this->parseTimeRange('update_time', $filter);
+        $amountRange = $this->parseAmountRange('amount', $filter);
+
+        // 构建基础查询
+        $query = $this->model->where($filter);
+
+        // 添加时间条件
+        if (!empty($createTimeRange)) {
+            $query->whereTime('create_time', $createTimeRange);
+        }
+        if (!empty($updateTimeRange)) {
+            $query->whereTime('update_time', $updateTimeRange);
+        }
+
+        if (!empty($amountRange)) {
+            $query->whereBetween('amount', $amountRange);
+        }
+        
+
+
+        // 统一计算统计值
+        return $query->sum($key);
+
+        
+    }
+    private function parseTimeRange($key, &$filter)
+    {
+
+        if (isset($filter[$key])) {
+            list($startTime, $endTime) = explode(' - ', $filter[$key]);
+            $time = [
+                trim($startTime), // 去除可能存在的空格
+                trim($endTime)
+            ];
+            unset($filter[$key]);
+            return $time;
+        }
+        return [];
+    }
+    private function parseAmountRange($key, &$filter)
+    {
 
+        if (isset($filter[$key])) {
+            list($startTime, $endTime) = explode(',', $filter[$key]);
+            $time = [
+                trim($startTime), // 去除可能存在的空格
+                trim($endTime)
+            ];
+            unset($filter[$key]);
+            return $time;
+        }
+        return [];
+    }
 }

+ 13 - 1
application/admin/view/offline/offline_recharge/index.html

@@ -7,11 +7,23 @@
 
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">
+
             <div class="tab-pane fade active in" id="one">
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                     
+                        <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:#23b7e5;">
+                            <!-- <i class="fa fa-dollar"></i> -->
+                            <span class="extend">
+                                USDT:<span id="amount">0</span>
+                            </span>
+                        </a>
+                        <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:#27C24C;">
+                            <!-- <i class="fa fa-dollar"></i> -->
+                            <span class="extend">
+                                茶宝:<span id="cha_bao">0</span>
+                            </span>
+                        </a>
                     </div>
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit=""

+ 2 - 0
application/admin/view/user/userpledge/detail.html

@@ -3,12 +3,14 @@
 <script src="__CDN__/assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
 
 <script src="__CDN__/assets/libs/sweetalert/sweetalert.min.js"></script>
+
 <style>
     .confirm-btn {
         background-color: #f75444 !important;
         color: white !important;
     }
 </style>
+
 <table class="table table-striped">
 
     <thead>

+ 1 - 1
application/admin/view/user/userpledge/index.html

@@ -1,6 +1,6 @@
 <div class="panel panel-default panel-intro">
     {:build_heading()}
-
+    
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">
             <div class="tab-pane fade active in" id="one">

+ 1 - 1
application/extra/site.php

@@ -4,7 +4,7 @@ return array (
   'name' => 'RWA茶',
   'beian' => '',
   'cdnurl' => '',
-  'version' => '1.0.10',
+  'version' => '1.0.40',
   'timezone' => 'Asia/Shanghai',
   'forbiddenip' => '',
   'languages' => 

+ 13 - 0
public/assets/js/backend/offline/offline_recharge.js

@@ -47,6 +47,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
             // 为表格绑定事件
             Table.api.bindevent(table);
+
+            //当表格数据加载完成时
+            table.on('load-success.bs.table', function (e, data) {
+                //这里可以获取从服务端获取的JSON数据
+                console.log(e);
+                console.log(data);
+                let amount=data['amount'];
+                let cha_bao=data['cha_bao']
+                //这里我们手动设置底部的值
+                $("#amount").text(amount);
+                $("#cha_bao").text(cha_bao);
+            });
+
         },
         add: function () {
             Controller.api.bindevent();