diff --git a/app/Http/Controllers/Admin/CourseController.php b/app/Http/Controllers/Admin/CourseController.php index 6854257..cc2bb78 100755 --- a/app/Http/Controllers/Admin/CourseController.php +++ b/app/Http/Controllers/Admin/CourseController.php @@ -281,6 +281,7 @@ class CourseController extends BaseController * @OA\Parameter(name="url_title", in="query", @OA\Schema(type="string"), description="链接地址"), * @OA\Parameter(name="is_ganbu", in="query", @OA\Schema(type="integer"), description="是否干部课程-0否1是"), * @OA\Parameter(name="is_chart", in="query", @OA\Schema(type="integer"), description="是否参与统计-0否1是,默认1"), + * @OA\Parameter(name="free_enter_schoolmate", in="query", @OA\Schema(type="integer"), description="免费/公益课程是否计入进入校友库资格-0否1是"), * @OA\Response( * response=200, * description="操作成功" diff --git a/app/Http/Controllers/Mobile/UserController.php b/app/Http/Controllers/Mobile/UserController.php index fd2fff0..6931c20 100755 --- a/app/Http/Controllers/Mobile/UserController.php +++ b/app/Http/Controllers/Mobile/UserController.php @@ -275,7 +275,14 @@ class UserController extends CommonController } // 是否有资格进入校友库 $enter_schoolmate = User::whereHas('courseSigns', function ($query) { - $query->where('fee_status', 1)->where('status', 1); + $query->where('status', 1) + ->where(function ($schoolmateQuery) { + $schoolmateQuery->where('fee_status', 1) + ->orWhereHas('course', function ($courseQuery) { + $courseQuery->where('is_fee', 0) + ->where('free_enter_schoolmate', 1); + }); + }); })->where('id', $this->getUserId())->count(); // 是否生日 $is_birthday = 0; diff --git a/app/Models/Course.php b/app/Models/Course.php index 8a764e5..f93e62d 100755 --- a/app/Models/Course.php +++ b/app/Models/Course.php @@ -21,6 +21,7 @@ class Course extends SoftDeletesModel 'show_txl_text', 'show_mobile_text', 'auto_schoolmate_text', + 'free_enter_schoolmate_text', 'is_virtual_text' ]; @@ -62,6 +63,12 @@ class Course extends SoftDeletesModel return $array[$this->attributes['auto_schoolmate']]; } + public function getFreeEnterSchoolmateTextAttribute() + { + $array = [0 => '否', 1 => '是']; + return $array[$this->attributes['free_enter_schoolmate'] ?? 0]; + } + public function getIsVirtualTextAttribute() { $array = [0 => '否', 1 => '是']; @@ -308,4 +315,3 @@ class Course extends SoftDeletesModel } } - diff --git a/database/migrations/2026_04_03_100000_add_free_enter_schoolmate_to_courses_table.php b/database/migrations/2026_04_03_100000_add_free_enter_schoolmate_to_courses_table.php new file mode 100644 index 0000000..6cc65c5 --- /dev/null +++ b/database/migrations/2026_04_03_100000_add_free_enter_schoolmate_to_courses_table.php @@ -0,0 +1,35 @@ +boolean('free_enter_schoolmate') + ->default(0) + ->comment('免费/公益课程是否计入进入校友库资格-0否1是') + ->after('auto_schoolmate'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('courses', function (Blueprint $table) { + $table->dropColumn('free_enter_schoolmate'); + }); + } +};