|
|
<?php
|
|
|
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
use App\Models\StatisticsConfig;
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
class StatisticsConfigSeeder extends Seeder
|
|
|
{
|
|
|
/**
|
|
|
* Run the database seeds.
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
public function run()
|
|
|
{
|
|
|
$configs = [
|
|
|
// 1. 校友总数 - 对应 homeV2 中的 schoolmate_total
|
|
|
[
|
|
|
'name' => '校友总数',
|
|
|
'key' => 'schoolmate_total',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计所有校友的总数',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'user',
|
|
|
'relations' => []
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'is_schoolmate',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'order_by' => [
|
|
|
'field' => 'id',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 2. 2025年校友数 - 对应 homeV2 中的 schoolmate_year
|
|
|
[
|
|
|
'name' => '2025年校友数',
|
|
|
'key' => 'schoolmate_year',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计2025年创建的校友数量',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'user',
|
|
|
'relations' => []
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'is_schoolmate',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'created_at',
|
|
|
'operator' => 'like',
|
|
|
'value' => date('Y')
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'order_by' => [
|
|
|
'field' => 'created_at',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 3. 已开设期数 - 对应 homeV2 中的 course_periods_total(按课程类型)
|
|
|
[
|
|
|
'name' => '各课程类型已开设期数',
|
|
|
'key' => 'course_periods_total_by_type',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计各课程类型已开设的期数',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course',
|
|
|
'relations' => []
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => []
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'group_by' => 'type',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 4. 培养人数去重 - 对应 homeV2 中的 course_signs_total(按课程类型)
|
|
|
// 注意:去重逻辑需要在应用层处理,这里先统计总数
|
|
|
[
|
|
|
'name' => '各课程类型培养人数',
|
|
|
'key' => 'course_signs_total_by_type',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计各课程类型的审核通过报名人数(2020-01-01至今)',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course_sign',
|
|
|
'relations' => ['course']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'created_at',
|
|
|
'operator' => 'between',
|
|
|
'value' => '2020-01-01,' . date('Y-m-d')
|
|
|
],
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'neq',
|
|
|
'value' => '4'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'neq',
|
|
|
'value' => '5'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'group_by' => 'course.type',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 5. 苏州区域数据 - 对应 homeV2 中的 suzhou
|
|
|
[
|
|
|
'name' => '苏州各区域校友人数',
|
|
|
'key' => 'suzhou_schoolmate_by_area',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计苏州各区域的校友人数',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'user',
|
|
|
'relations' => ['company']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'is_schoolmate',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company.company_city',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '苏州市'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company.company_area',
|
|
|
'operator' => 'isnotnull'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'group_by' => 'company.company_area',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 6. 全国数据 - 对应 homeV2 中的 country
|
|
|
[
|
|
|
'name' => '全国各城市校友人数',
|
|
|
'key' => 'country_schoolmate_by_city',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计全国各城市的校友人数',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'user',
|
|
|
'relations' => ['company']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'is_schoolmate',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company.company_city',
|
|
|
'operator' => 'isnotnull'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'group_by' => 'company.company_city',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 7. 本月课程 - 对应 homeV2 中的 monthCourses
|
|
|
[
|
|
|
'name' => '本月课程列表',
|
|
|
'key' => 'month_courses',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '获取本月开课的课程列表',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course',
|
|
|
'relations' => ['teacher']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'start_date',
|
|
|
'operator' => 'like',
|
|
|
'value' => date('Y-m')
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'order_by' => [
|
|
|
'field' => 'start_date',
|
|
|
'direction' => 'asc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 8. 投后企业 - 对应 homeV2 中的 yh_invested_total
|
|
|
[
|
|
|
'name' => '投后企业总数',
|
|
|
'key' => 'yh_invested_total',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计元禾已投企业的总数',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'company',
|
|
|
'relations' => []
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'is_yh_invested',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'order_by' => [
|
|
|
'field' => 'id',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 9. 元和员工参与企业 - 对应 homeV2 中的 yh_join_company_total
|
|
|
[
|
|
|
'name' => '元和员工参与企业总数',
|
|
|
'key' => 'yh_join_company_total',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计公司名称包含元禾相关关键词的企业总数',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'company',
|
|
|
'relations' => []
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'or',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾控股'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾原点'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾厚望'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾重元'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾璞华'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾谷风'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾绿柳'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾辰坤'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '元禾沙湖'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '禾裕集团'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '苏州科服'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '信诚管理咨询'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '集成电路公司'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '常州团队'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'company_name',
|
|
|
'operator' => 'like',
|
|
|
'value' => '国企元禾'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'order_by' => [
|
|
|
'field' => 'id',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 10. 全市干部参与企业 - 对应 homeV2 中的 yh_ganbu_total
|
|
|
[
|
|
|
'name' => '全市干部参与企业总数',
|
|
|
'key' => 'yh_ganbu_total',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计有"跟班学员"用户的企业总数',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'company',
|
|
|
'relations' => ['users']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'users.from',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '跟班学员'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'order_by' => [
|
|
|
'field' => 'id',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 11. 课程统计列表 - 对应 homeV2 中的 courseTypes(已开设期数)
|
|
|
[
|
|
|
'name' => '课程统计列表(已开设期数)',
|
|
|
'key' => 'course_types_list_periods',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计各课程类型的已开设期数(仅统计 is_chart=1 的课程类型)',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course',
|
|
|
'relations' => ['typeDetail']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'typeDetail.is_chart',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'group_by' => 'typeDetail.id',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 12. 课程统计列表 - 对应 homeV2 中的 courseTypes(培养人数)
|
|
|
[
|
|
|
'name' => '课程统计列表(培养人数)',
|
|
|
'key' => 'course_types_list_signs',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计各课程类型的培养人数(2020-01-01至今,审核通过,仅统计 is_chart=1 的课程类型)',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course_sign',
|
|
|
'relations' => ['course']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'created_at',
|
|
|
'operator' => 'between',
|
|
|
'value' => '2020-01-01,' . date('Y-m-d')
|
|
|
],
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'neq',
|
|
|
'value' => '4'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'neq',
|
|
|
'value' => '5'
|
|
|
],
|
|
|
[
|
|
|
'key' => 'course.typeDetail.is_chart',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'group_by' => 'course.typeDetail.id',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 13. 课程分类下的课程数量统计
|
|
|
[
|
|
|
'name' => '课程分类下的课程数量',
|
|
|
'key' => 'course_count_by_type',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计各课程分类下的所有课程数量',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course',
|
|
|
'relations' => ['typeDetail']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => []
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count',
|
|
|
'group_by' => 'typeDetail.id',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 14. 课程分类列表及审核通过用户数量统计(按手机号去重)
|
|
|
[
|
|
|
'name' => '课程分类列表及审核通过用户数量统计',
|
|
|
'key' => 'course_type_list_with_student_count',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '获取课程分类列表,并统计每个分类下审核通过的报名用户数量(按照手机号去重)',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course_sign',
|
|
|
'relations' => ['course', 'user']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count_distinct',
|
|
|
'distinct_field' => 'user.mobile',
|
|
|
'group_by' => 'course.type',
|
|
|
'order_by' => [
|
|
|
'field' => 'group_value',
|
|
|
'direction' => 'asc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
|
|
|
// 15. 课程分类下按手机号去重的审核通过用户数量统计
|
|
|
[
|
|
|
'name' => '课程分类下按手机号去重的审核通过用户数量',
|
|
|
'key' => 'course_type_student_count_distinct',
|
|
|
'decimal_places' => 0,
|
|
|
'description' => '统计各课程分类下审核通过的报名用户数量,按照手机号去重',
|
|
|
'config_json' => [
|
|
|
'data_source' => [
|
|
|
'main_model' => 'course_sign',
|
|
|
'relations' => ['course', 'user']
|
|
|
],
|
|
|
'conditions' => [
|
|
|
'logic' => 'and',
|
|
|
'items' => [
|
|
|
[
|
|
|
'key' => 'status',
|
|
|
'operator' => 'eq',
|
|
|
'value' => '1'
|
|
|
]
|
|
|
]
|
|
|
],
|
|
|
'statistics' => [
|
|
|
'type' => 'count_distinct',
|
|
|
'distinct_field' => 'user.mobile',
|
|
|
'group_by' => 'course.type',
|
|
|
'order_by' => [
|
|
|
'field' => 'total',
|
|
|
'direction' => 'desc'
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
]
|
|
|
];
|
|
|
|
|
|
foreach ($configs as $config) {
|
|
|
StatisticsConfig::updateOrCreate(
|
|
|
['key' => $config['key']],
|
|
|
$config
|
|
|
);
|
|
|
}
|
|
|
|
|
|
$this->command->info('已生成 ' . count($configs) . ' 条统计数据配置测试数据(基于 homeV2 方法)');
|
|
|
}
|
|
|
}
|