Procházet zdrojové kódy

财务概况统计的数据需要去除删除账号和测试账号的数据-订单概况

sunxbiao před 1 rokem
rodič
revize
0dc0c9ca96

+ 28 - 0
app/common/dao/user/UserDao.php

@@ -378,4 +378,32 @@ class UserDao extends BaseDao
378 378
     {
379 379
         return User::getDB()->where('phone', $phone)->field('uid,nickname,avatar,user_type')->select();
380 380
     }
381
+
382
+    /**
383
+     * 获取测试用户 uid List
384
+     * @return array
385
+     */
386
+    public function getTestUidList(): array
387
+    {
388
+        return $this::getModel()::getDB()->where('test_user', '=', 1)->column('uid');
389
+    }
390
+
391
+    /**
392
+     * 获取删除用户 uid List
393
+     * @return array
394
+     */
395
+    public function getDelUidList(): array
396
+    {
397
+        return $this::getModel()::getDB()->where('is_del', '=', 1)->column('uid');
398
+    }
399
+
400
+    /**
401
+     * 获取删除用户 uid List
402
+     * @return array
403
+     */
404
+    public function getInvalidUidList(): array
405
+    {
406
+        return $this::getModel()::getDB()->where('test_user', '=', 1)->whereOr('is_del', '=', 1)->column('uid');
407
+    }
408
+
381 409
 }

+ 17 - 2
app/common/repositories/finance/FinanceRepository.php

@@ -28,8 +28,17 @@ class FinanceRepository extends BaseRepository
28 28
      */
29 29
     public function order_overview($mer_id = 0)
30 30
     {
31
+        // 需要过滤掉的用户
32
+        /** @var UserRepository $userRepository */
33
+        $userRepository = app()->make(UserRepository::class);
34
+        $invalidUidList = $userRepository->getInvalidUidList();
35
+
31 36
         if ($mer_id) {
32 37
             $where = "mer_id = " . $mer_id . " and paid = 1";
38
+            if (!empty($invalidUidList)) {
39
+                $invalidSqlStr = ' AND uid NOT IN (' . implode(',', $invalidUidList) . ')';
40
+                $where .= $invalidSqlStr;
41
+            }
33 42
             $type = input('type', 1);
34 43
             $day = input('day', '');
35 44
     
@@ -138,8 +147,14 @@ class FinanceRepository extends BaseRepository
138 147
             $weekWhere .= " and DATE(create_time) >= '" . $oneWeekAgoFormatted . "' and DATE(create_time) <= '" . $todayFormatted . "'";
139 148
             //今日时间条件
140 149
             $dayWhere .= " and DATE(create_time) = '" . $todayFormatted . "'";
141
-    
142
-    
150
+
151
+            if (!empty($invalidUidList)) {
152
+                $invalidSqlStr = ' AND uid NOT IN (' . implode(',', $invalidUidList) . ')';
153
+                $where .= $invalidSqlStr;
154
+                $weekWhere .= $invalidSqlStr;
155
+                $dayWhere .= $invalidSqlStr;
156
+            }
157
+
143 158
             // 会员专区订单总数
144 159
             //总数
145 160
             $chengjiaomoney = Db::name('store_order')->where($where)->where('mer_id', 496)->count();