|
|
@@ -237,7 +237,9 @@ class PointsStatsService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 筛选项来源:用户/模型/中转站/日期范围。
|
|
|
+ * 筛选项来源:用户/模型/中转站/模型类型/日期范围。
|
|
|
+ *
|
|
|
+ * 选项统一为 {name: 显示名称, value: 传给后端的筛选值},前端展示 name、提交 value。
|
|
|
*/
|
|
|
public function getFilters(array $params = []): array
|
|
|
{
|
|
|
@@ -252,10 +254,13 @@ class PointsStatsService
|
|
|
->orderBy('id')
|
|
|
->get()
|
|
|
->map(function ($u) {
|
|
|
+ $name = (string)$u->nickname;
|
|
|
+ if ($name === '') {
|
|
|
+ $name = (string)$u->account;
|
|
|
+ }
|
|
|
return [
|
|
|
- 'id' => (int)$u->id,
|
|
|
- 'nickname' => (string)$u->nickname,
|
|
|
- 'account' => (string)$u->account,
|
|
|
+ 'name' => $name,
|
|
|
+ 'value' => (int)$u->id,
|
|
|
];
|
|
|
})->all();
|
|
|
|
|
|
@@ -263,20 +268,30 @@ class PointsStatsService
|
|
|
if ($cpid > 0) {
|
|
|
$statsQuery->where('s.cpid', $cpid);
|
|
|
}
|
|
|
- $models = (clone $statsQuery)->distinct()->pluck('s.model')->values()->all();
|
|
|
- $relays = (clone $statsQuery)->distinct()->pluck('s.relay')->values()->all();
|
|
|
- $modelTypes = (clone $statsQuery)->distinct()->pluck('s.model_type')->values()->all();
|
|
|
- $dateRange = (clone $statsQuery)->selectRaw('MIN(stat_date) AS min_date, MAX(stat_date) AS max_date')->first();
|
|
|
+ $models = (clone $statsQuery)->distinct()->orderBy('s.model')->pluck('s.model')->values()->map(function ($model) {
|
|
|
+ return ['name' => (string)$model, 'value' => (string)$model];
|
|
|
+ })->all();
|
|
|
+ $relays = (clone $statsQuery)->distinct()->orderBy('s.relay')->pluck('s.relay')->values()->map(function ($relay) {
|
|
|
+ return ['name' => (string)$relay, 'value' => (string)$relay];
|
|
|
+ })->all();
|
|
|
+ $modelTypes = (clone $statsQuery)->distinct()->pluck('s.model_type')->values()->map(function ($type) {
|
|
|
+ $labels = ['chat' => '文本', 'image' => '图片', 'video' => '视频'];
|
|
|
+ return [
|
|
|
+ 'name' => $labels[$type] ?? (string)$type,
|
|
|
+ 'value' => (string)$type,
|
|
|
+ ];
|
|
|
+ })->all();
|
|
|
+ // $dateRange = (clone $statsQuery)->selectRaw('MIN(stat_date) AS min_date, MAX(stat_date) AS max_date')->first();
|
|
|
|
|
|
return [
|
|
|
- 'users' => $users,
|
|
|
- 'models' => $models,
|
|
|
- 'relays' => $relays,
|
|
|
- 'model_types'=> $modelTypes,
|
|
|
- 'date_range' => [
|
|
|
- 'min' => $dateRange->min_date ?? null,
|
|
|
- 'max' => $dateRange->max_date ?? null,
|
|
|
- ],
|
|
|
+ 'users' => $users,
|
|
|
+ 'models' => $models,
|
|
|
+ 'relays' => $relays,
|
|
|
+ 'model_types' => $modelTypes,
|
|
|
+ // 'date_range' => [
|
|
|
+ // 'min' => $dateRange->min_date ?? null,
|
|
|
+ // 'max' => $dateRange->max_date ?? null,
|
|
|
+ // ],
|
|
|
];
|
|
|
}
|
|
|
|