Просмотр исходного кода

feat(finance): 添加共富会员身份统计功能

- 查询共富会员用户数据并按用户组分组统计
- 添加普通用户、一星至三星合伙人数据显示
- 添加钻石合伙人、总裁合伙人及联席主席团统计
- 使用array_column函数优化数据结构转换
- 集成到现有统计数据返回结果中
shichen месяцев назад: 5
Родитель
Сommit
bfbb153e96
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      app/common/repositories/finance/FinanceRepository.php

+ 12 - 0
app/common/repositories/finance/FinanceRepository.php

@@ -385,6 +385,18 @@ class FinanceRepository extends BaseRepository
385 385
             $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '股权', 'user_group' => 0];
386 386
             $maker = Db::query("SELECT count(uid) as count FROM `rrx_merchant` where {$where}");
387 387
             $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '商户', 'user_group' => 0];
388
+
389
+            // 共富会员身份
390
+            $sharedUserDataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_shared_prosperity_user` where {$where} group by user_group");
391
+            $sharedUserDataQuery = array_column($sharedUserDataQuery, 'count', 'user_group');
392
+            $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[0] ?? 0), 'name' => '普通用户', 'user_group' => 0];
393
+            $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[1] ?? 0), 'name' => '一星合伙人', 'user_group' => 1];
394
+            $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[2] ?? 0), 'name' => '二星合伙人', 'user_group' => 2];
395
+            $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[3] ?? 0), 'name' => '三星合伙人', 'user_group' => 3];
396
+            $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[4] ?? 0), 'name' => '钻石合伙人', 'user_group' => 4];
397
+            $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[5] ?? 0), 'name' => '总裁合伙人', 'user_group' => 5];
398
+            $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[6] ?? 0), 'name' => '联席主席团', 'user_group' => 6];
399
+
388 400
             $res['left'] = $data;
389 401
         }
390 402
         return $res;