瀏覽代碼

支收总览

afa 5 月之前
父節點
當前提交
8311290025
共有 2 個文件被更改,包括 9 次插入8 次删除
  1. 3 2
      app/api/controller/MoneyLog.php
  2. 6 6
      app/common/model/MoneyLog.php

+ 3 - 2
app/api/controller/MoneyLog.php

@@ -142,14 +142,15 @@ class MoneyLog extends Base
 
             $type = $this->request->post('type/d', 0); //1月 2年 3自定义
             $time = $this->request->post('time/s', '');
-            $uids = $this->request->post('user_ids/s', '');
+            $uids = $this->request->post('user_ids/a', []);
+
             //支收
             $count = $monuyModel::getCountAllBalance($type, $time, $uids);
 
             //记账账户余额
             $account = $monuyModel::getCountAllUserBalance($type, $time, $uids);
 
-            
+      
             //月统计
             $month = $monuyModel::getCountAllMonthBalance($type, $time, $uids);
          

+ 6 - 6
app/common/model/MoneyLog.php

@@ -96,7 +96,7 @@ class MoneyLog Extends Model
     }
 
     //支收总览
-    public static function getCountAllBalance(int $type, string $time = '', string $user_ids='')
+    public static function getCountAllBalance(int $type, string $time = '', array $user_ids=[])
     {
         $list = self::where('status', self::STATUS_NORMAL);
         if($type == 1 && !empty($time)) $list = $list->whereMonth('create_date', $time);
@@ -105,7 +105,7 @@ class MoneyLog Extends Model
             $expTime = explode(',', $time);
             $list = $list->whereTime('create_date', [$expTime[0], $expTime[1]]);
         }
-        if(!empty($user_ids)) $list = $list->whereIn('user_id', $user_ids);
+        if(count($user_ids) > 0) $list = $list->whereIn('user_id', $user_ids);
         $list = $list
                 ->field('type, sum(if(type=1,`change`,0)) as income, sum(if(type=2,`change`, 0)) as expenditure')
                 ->group('type')
@@ -115,7 +115,7 @@ class MoneyLog Extends Model
 
 
     //统计用户余额
-    public static function getCountAllUserBalance(int $type, string $time = '', string $user_ids='')
+    public static function getCountAllUserBalance(int $type, string $time = '', array $user_ids=[])
     {
         $list = self::where('status', self::STATUS_NORMAL);
 
@@ -125,7 +125,7 @@ class MoneyLog Extends Model
             $expTime = explode(',', $time);
             $list = $list->whereTime('create_date', [$expTime[0], $expTime[1]]);
         }
-        if(!empty($user_ids)) $list = $list->whereIn('user_id', $user_ids);
+        if(count($user_ids) >0) $list = $list->whereIn('user_id', $user_ids);
         $list = $list
                 ->field('bank_account, sum(if(type=1,`change`,0)) as income, sum(if(type=2,`change`, 0)) as expenditure')
                 ->group('bank_account')
@@ -134,7 +134,7 @@ class MoneyLog Extends Model
     }
 
     //统计所有月统计
-    public static function getCountAllMonthBalance(int $type, string $time = '', string $user_ids='')
+    public static function getCountAllMonthBalance(int $type, string $time = '', array $user_ids=[])
     {
         $list = self::where('status', self::STATUS_NORMAL);
 
@@ -146,7 +146,7 @@ class MoneyLog Extends Model
             $expTime = explode(',', $time);
             $list = $list->whereTime('create_date', [$expTime[0], $expTime[1]]);
         }
-        if(!empty($user_ids)) $list = $list->whereIn('user_id', $user_ids);
+        if(count($user_ids)> 0) $list = $list->whereIn('user_id', $user_ids);
         //月
         $list = $list
             ->field('create_month, sum(if(type=1,`change`,0)) as income, sum(if(type=2,`change`, 0)) as expenditure')