diff --git a/app/Http/Controllers/Admin/CourseController.php b/app/Http/Controllers/Admin/CourseController.php index ed904b8..3e8ca9b 100755 --- a/app/Http/Controllers/Admin/CourseController.php +++ b/app/Http/Controllers/Admin/CourseController.php @@ -44,6 +44,9 @@ class CourseController extends BaseController * @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"), * @OA\Parameter(name="has_course_forms", in="query", @OA\Schema(type="string"), required=true, description="是否有自定义表单0否1是"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), + * @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=true, description="开始日期"), + * @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=true, description="结束日期"), + * @OA\Parameter(name="course_type_id", in="query", @OA\Schema(type="string"), required=true, description="课程体系id,多个英文逗号"), * @OA\Response( * response="200", * description="暂无" @@ -56,8 +59,7 @@ class CourseController extends BaseController $list = $this->model->with(underlineToHump($all['show_relation'] ?? [])) ->withCount(['courseSigns' => function ($query) { $query->whereNotIn('status', [4, 5]); - }]) - ->withCount(['courseSigns as sign_pass_total' => function ($query) { + }])->withCount(['courseSigns as sign_pass_total' => function ($query) { $query->where('status', 1)->whereHas('user'); }])->withCount(['courseSigns as sign_wait_total' => function ($query) { $query->where('status', 0)->whereHas('user'); @@ -75,7 +77,16 @@ class CourseController extends BaseController if (isset($all['has_course_forms']) && !empty($all['has_course_forms'])) { $query->whereHas('courseForms'); } - + if (isset($all['start_date'])) { + $query->where('start_date', '>=', $all['start_date']); + } + if (isset($all['end_date'])) { + $query->where('end_date', '<=', $all['end_date']); + } + if (isset($all['course_type_id'])) { + $course_type_id = explode(',', $all['course_type_id']); + $query->whereIn('type', $course_type_id); + } if (isset($all['filter']) && !empty($all['filter'])) { foreach ($all['filter'] as $condition) { $key = $condition['key'] ?? null; diff --git a/app/Http/Controllers/Admin/CourseSignController.php b/app/Http/Controllers/Admin/CourseSignController.php index eed18b4..4b2df63 100755 --- a/app/Http/Controllers/Admin/CourseSignController.php +++ b/app/Http/Controllers/Admin/CourseSignController.php @@ -61,6 +61,9 @@ class CourseSignController extends BaseController * @OA\Parameter(name="mobile", in="query", @OA\Schema(type="string"), required=true, description="手机号"), * @OA\Parameter(name="education", in="query", @OA\Schema(type="string"), required=true, description="education学历"), * @OA\Parameter(name="filter_date", in="query", @OA\Schema(type="string"), required=true, description="自定义字段筛选二维数组,包含键名name,value"), + * @OA\Parameter(name="start_date", in="query", @OA\Schema(type="string"), required=true, description="开始日期"), + * @OA\Parameter(name="end_date", in="query", @OA\Schema(type="string"), required=true, description="结束日期"), + * @OA\Parameter(name="course_type_id", in="query", @OA\Schema(type="string"), required=true, description="课程体系id,多个英文逗号"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), * @OA\Response( * response="200", @@ -126,6 +129,27 @@ class CourseSignController extends BaseController } } })->where(function ($query) use ($all) { + if (isset($all['start_date'])) { + $query->whereDate('created_at', '>=', $all['start_date']); + } + if (isset($all['end_date'])) { + $query->whereDate('created_at', '<=', $all['end_date']); + } + if (isset($all['course_type_id'])) { + $course_type_id = explode(',', $all['course_type_id']); + $courses = Course::where(function ($query) use ($all) { + if (isset($all['start_date'])) { + $query->where('start_date', '>=', $all['start_date']); + } + if (isset($all['end_date'])) { + $query->where('start_date', '<=', $all['end_date']); + } + })->whereIn('type', $course_type_id)->get(); + $query->whereNotIn('status', [4, 5]) + ->where(function ($query) use ($courses) { + $query->whereIn('course_id', $courses->pluck('id')); + }); + } if (isset($all['name'])) { $query->where(function ($q) use ($all) { $q->whereHas('user', function ($q) use ($all) { diff --git a/app/Http/Controllers/Admin/OtherController.php b/app/Http/Controllers/Admin/OtherController.php index 7912f9e..fd25a62 100755 --- a/app/Http/Controllers/Admin/OtherController.php +++ b/app/Http/Controllers/Admin/OtherController.php @@ -46,12 +46,29 @@ class OtherController extends CommonController $schoolmate['schoolmate_total'] = User::where('is_schoolmate', 1)->count(); // 2025年校友数 $schoolmate['schoolmate_year'] = User::where('is_schoolmate', 1)->where('created_at', 'like', '%' . date('Y') . '%')->count(); - // 上市企业总市值 - $company['company_market'] = Company::where('company_market', 1)->sum('market_value'); + + // 开课场次(全部) + $calendar = Calendar::get(); + $company['course_total'] = $calendar->count(); + $company['course_day_total'] = $calendar->sum(function ($course) { + $start = Carbon::parse($course->start_time); + $end = Carbon::parse($course->end_time); + return $end->diffInDays($start) + 1; // 包含起始和结束日期 + }); + // 开课场次(当年) + $calendarYear = Calendar::where('date', 'like', '%' . date('Y') . '%')->get(); + $company['course_total_year'] = $calendarYear->count(); + $company['course_day_total_year'] = $calendarYear->sum(function ($course) { + $start = Carbon::parse($course->start_time); + $end = Carbon::parse($course->end_time); + return $end->diffInDays($start) + 1; // 包含起始和结束日期 + }); + // 校友企业总融资额 $company['company_fund'] = Company::where('is_schoolmate', 1)->sum('company_fund'); // 校友企业总估值 $company['valuation'] = Company::where('is_schoolmate', 1)->sum('valuation'); + // 校友企业所属领域 $industryTotal = []; $industries = ParameterDetail::where('parameter_id', 4)->get(); diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 28ba2a3..76cdfb5 100755 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -408,6 +408,7 @@ class UserController extends BaseController * @OA\Parameter(name="remark", in="query", @OA\Schema(type="string"), description="备注"), * @OA\Parameter(name="is_black", in="query", @OA\Schema(type="string"), description="是否黑名单0否1是"), * @OA\Parameter(name="has_appointment_total", in="query", @OA\Schema(type="string"), description="预约剩余次数"), + * @OA\Parameter(name="from", in="query", @OA\Schema(type="string"), description="来源"), * @OA\Response( * response=200, * description="操作成功" diff --git a/app/Models/User.php b/app/Models/User.php index 3eda1ab..cbdadd7 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -90,6 +90,15 @@ class User extends Authenticatable implements Auditable return $this->username; } + public function getMobileAttribute($value) + { + // 如果url中包含admin字符串,则所有的手机号显示中间4位星号代替 + if (strpos(request()->url(), 'admin') !== false && env('APP_ENV') == 'local') { + return substr_replace($value, '****', 3, 4); + } + return $value; + } + public function getAppointmentTotalAttribute($value) { $now = date('Y-m-d H:i:s'); diff --git a/database/migrations/2025_08_14_105924_alert_users_table.php b/database/migrations/2025_08_14_105924_alert_users_table.php index 868ef19..30c1bff 100644 --- a/database/migrations/2025_08_14_105924_alert_users_table.php +++ b/database/migrations/2025_08_14_105924_alert_users_table.php @@ -16,6 +16,8 @@ return new class extends Migration Schema::table('users', function (Blueprint $table) { // 是否黑名单 $table->boolean('is_black')->default(0)->comment('是否黑名单'); + // 来源 + $table->string('from')->nullable()->comment('来源'); }); } diff --git a/database/migrations/2025_08_27_130530_alert_course_types_table.php b/database/migrations/2025_08_27_130530_alert_course_types_table.php new file mode 100644 index 0000000..0c78538 --- /dev/null +++ b/database/migrations/2025_08_27_130530_alert_course_types_table.php @@ -0,0 +1,38 @@ +string('color')->nullable()->comment('颜色'); + $table->tinyInteger('is_arrange')->nullable()->comment('是否排课-0否1是'); + $table->tinyInteger('is_fee')->nullable()->comment('是否缴费-0否1是'); + $table->boolean('show_txl')->nullable()->comment('是否显示通讯录-0否1是 默认1'); + $table->boolean('show_mobile')->nullable()->comment('是否显示手机号-0否1是 默认1'); + $table->boolean('auto_schoolmate')->nullable()->comment('已审核学员是否自动进入校友库0否1是'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('course_types', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2025_08_27_130837_alert_calendars_table.php b/database/migrations/2025_08_27_130837_alert_calendars_table.php new file mode 100644 index 0000000..7de42ea --- /dev/null +++ b/database/migrations/2025_08_27_130837_alert_calendars_table.php @@ -0,0 +1,33 @@ +string('color')->nullable()->comment('颜色'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('calendars', function (Blueprint $table) { + // + }); + } +};