Merge branch 'master' of ssh://47.101.48.251:/data/git/wx.sstbc.com

master
lion 4 months ago
commit 1b2fca280d

@ -52,7 +52,9 @@ class AutoSchoolmate extends Command
// 获取报名通过的学员
$courseSigns = CourseSign::where('course_id', $course->id)->where('status', 1)->get();
// 用户设置成校友
User::whereIn('id', $courseSigns->pluck('user_id'))->where('is_black',0)->update(['is_schoolmate' => 1]);
User::whereIn('id', $courseSigns->pluck('user_id'))
//->where('is_black',0)
->update(['is_schoolmate' => 1]);
}
return $this->info('更新完成');
}

@ -43,7 +43,7 @@ class UpdateCompany extends Command
public function handle()
{
// $YuanheRepository = new YuanheRepository();
// $result = $YuanheRepository->companyInfo(['keyword' => '苏州元瞰科技有限公司']);
// $result = $YuanheRepository->companyInfo(['keyword' => '苏州元瞰科技有限公司','enterpriseName'=>'博世工程技术']);
// dd($result);
$user_id = $this->option('user_id');

@ -135,11 +135,11 @@ class UpdateCourseUrls extends Command
$this->info("处理行 {$row}: 课程='{$courseName}', 跳转链接='{$jumpLink}'");
// 从phome_ecms_news表获取titleurl
$titleUrl = $this->getTitleUrlFromNews($jumpLink);
list($title, $titleUrl) = $this->getTitleUrlFromNews($jumpLink);
if ($titleUrl) {
// 更新courses表
$updateCount = $this->updateCourseUrl($courseName, $titleUrl);
$updateCount = $this->updateCourseUrl($courseName, $titleUrl, $title);
$updated += $updateCount;
if ($updateCount > 0) {
@ -176,7 +176,7 @@ class UpdateCourseUrls extends Command
->first();
if ($news && !empty($news->titleurl)) {
return $news->titleurl;
return [$news->title, $news->titleurl];
}
// 模糊匹配
@ -186,7 +186,7 @@ class UpdateCourseUrls extends Command
if ($news && !empty($news->titleurl)) {
$this->info("通过模糊匹配找到: '{$news->title}' -> '{$news->titleurl}'");
return $news->titleurl;
return [$news->title, $news->titleurl];
}
// 使用相似度匹配
@ -210,7 +210,7 @@ class UpdateCourseUrls extends Command
if ($bestMatch && $highestSimilarity > 0) {
$this->info("通过相似度匹配找到 (相似度: " . round($highestSimilarity * 100, 2) . "%): '{$bestMatch->title}' -> '{$bestMatch->titleurl}'");
return $bestMatch->titleurl;
return [$bestMatch->title, $bestMatch->titleurl];
}
} catch (\Exception $e) {
@ -223,13 +223,13 @@ class UpdateCourseUrls extends Command
/**
* 更新courses表的url字段
*/
private function updateCourseUrl($courseName, $titleUrl)
private function updateCourseUrl($courseName, $titleUrl, $title)
{
try {
// 直接匹配
$updateCount = Course::where('name', $courseName)
->whereNull('deleted_at')
->update(['url' => $titleUrl]);
->update(['url' => $titleUrl, 'url_title' => $title]);
if ($updateCount > 0) {
return $updateCount;
@ -238,7 +238,7 @@ class UpdateCourseUrls extends Command
// 模糊匹配
$updateCount = Course::where('name', 'like', "%{$courseName}%")
->whereNull('deleted_at')
->update(['url' => $titleUrl]);
->update(['url' => $titleUrl, 'url_title' => $title]);
if ($updateCount > 0) {
$this->info("通过模糊匹配更新了课程");
@ -264,6 +264,7 @@ class UpdateCourseUrls extends Command
if ($bestMatch && $highestSimilarity > 0) {
$bestMatch->url = $titleUrl;
$bestMatch->url_title = $title;
$bestMatch->save();
$this->info("通过相似度匹配更新了课程 (相似度: " . round($highestSimilarity * 100, 2) . "%): '{$bestMatch->name}'");
return 1;

@ -138,7 +138,7 @@ class CourseContentController extends BaseController
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$detail = $this->model->with('courseContentEvaluation.courseContentEvaluationAsks')->find($all['id']);
$detail = $this->model->with('courseContentEvaluation.courseContentEvaluationAsks','teacher','directionDetail')->find($all['id']);
return $this->success($detail);
}

@ -16,6 +16,7 @@ use App\Models\ParameterDetail;
use App\Models\User;
use App\Repositories\DoorRepository;
use App\Repositories\EntranceRepository;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use App\Models\Course;
@ -81,6 +82,134 @@ class OtherController extends CommonController
return $this->success(compact('courseTypes', 'schoolmate', 'company', 'industryTotal', 'suzhou', 'country'));
}
/**
* @OA\Get(
* path="/api/admin/other/courses-home",
* tags={"其他"},
* summary="课程统计",
* description="",
* @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",
* description="暂无"
* )
* )
*/
public function coursesHome()
{
// 启用查询日志记录
DB::enableQueryLog();
$start_date = request('start_date', '2020-01-01');
$end_date = request('end_date', date('Y-m-d'));
$course_type_id = request('course_type_id', '');
if ($course_type_id) {
// 部分
$course_type_id = explode(',', $course_type_id);
} else {
// 全部
$course_type_id = CourseType::pluck('id')->toArray();
}
// 课程
$courses = Course::where('start_date', '>=', $start_date)
->where('start_date', '<=', $end_date)
->whereIn('type', $course_type_id)
->get();
// 报名人数
$list['course_signs_total'] = CourseSign::whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->where(function ($query) use ($courses) {
$query->whereIn('course_id', $courses->pluck('id'));
})->count();
// 审核通过人数
$list['course_signs_pass'] = CourseSign::where('status', 1)
->whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->where(function ($query) use ($courses) {
$query->whereIn('course_id', $courses->pluck('id'));
})
->count();
// 审核通过人数去重
$list['course_signs_pass_unique'] = CourseSign::where('status', 1)
->whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->where(function ($query) use ($courses) {
$query->whereIn('course_id', $courses->pluck('id'));
})->select('user_id')
->distinct()
->count();
// 开课场次
$list['course_total'] = $courses->count();
// 开课天数
$list['course_day_total'] = $courses->sum(function ($course) {
$start = Carbon::parse($course->start_date);
$end = Carbon::parse($course->end_date);
return $end->diffInDays($start) + 1; // 包含起始和结束日期
});
// 返回所有sql语句
$sql = DB::getQueryLog();
// 课程分类明细统计
$courseTypesSum = [];
$courseTypes = CourseType::whereIn('id', $course_type_id)->get();
foreach ($courseTypes as $courseType) {
// 获取课程
$courses2 = Course::where('start_date', '>=', $start_date)
->where('start_date', '<=', $end_date)
->where('type', $courseType->id)
->get();
// 培养人数
$courseTypeSignsPass = CourseSign::where('status', 1)
->whereIn('course_id', $courses2->pluck('id'))
->whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->count();
// 去重培养人数
$courseTypeSignsPassUnique = CourseSign::where('status', 1)
->whereIn('course_id', $courses2->pluck('id'))
->whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->select('user_id')
->distinct()
->count();
foreach ($courses2 as $course) {
$courseTypesSum[] = [
'course_type' => $courseType->name,
'course_type_signs_pass' => $courseTypeSignsPass,
'course_type_signs_pass_unique' => $courseTypeSignsPassUnique,
'course_name' => $course->name,
'course_signs_pass' => CourseSign::where('status', 1)
->where('course_id', $course->id)
->whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->count()
];
}
}
// 区域明细统计
$areas = ParameterDetail::where('parameter_id', 5)->get();
foreach ($areas as $area) {
$area->course_signs_pass = CourseSign::where('status', 1)
->whereHas('user', function ($query) use ($area) {
$query->where('company_area', $area->value);
})->whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->count();
$area->course_signs_pass_unique = CourseSign::where('status', 1)
->whereHas('user', function ($query) use ($area) {
$query->where('company_area', $area->value);
})->whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->select('user_id')
->distinct()
->count();
}
return $this->success(compact('list', 'courseTypesSum', 'areas', 'sql'));
}
/**
* @OA\Post(
* path="/api/admin/other/admin-user-list",

@ -32,6 +32,8 @@ class TeacherController extends BaseController
* @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"),
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="theme", in="query", @OA\Schema(type="string"), required=false, description="主题"),
* @OA\Parameter(name="direction", in="query", @OA\Schema(type="string"), required=false, description="方向"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
@ -42,7 +44,7 @@ class TeacherController extends BaseController
public function index()
{
$all = request()->all();
$list = $this->model->with('courseContents.course')->where(function ($query) use ($all) {
$list = $this->model->with('courseContents.course','courseContents.directionDetail')->where(function ($query) use ($all) {
if (isset($all['filter']) && !empty($all['filter'])) {
foreach ($all['filter'] as $condition) {
$key = $condition['key'] ?? null;
@ -110,6 +112,16 @@ class TeacherController extends BaseController
$filename = (new CustomForm())->getTableComment($tableName);
return Excel::download(new BaseExport($export_fields, $list, $tableName), $filename . date('YmdHis') . '.xlsx');
} else {
if (isset($all['theme']) || isset($all['direction'])) {
$list = $list->whereHas('courseContents', function ($query) use ($all) {
if (isset($all['theme'])) {
$query->where('theme', $all['theme']);
}
if (isset($all['direction'])) {
$query->where('direction', $all['direction']);
}
});
}
// 输出
$list = $list->paginate($all['page_size'] ?? 20);
}
@ -145,8 +157,6 @@ class TeacherController extends BaseController
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="访问令牌"),
* @OA\Parameter(name="name", in="query", @OA\Schema(type="integer"), description="名字"),
* @OA\Parameter(name="sex", in="query", @OA\Schema(type="string"), description="性别"),
* @OA\Parameter(name="speciality", in="query", @OA\Schema(type="string"), description="专业"),
* @OA\Parameter(name="theme", in="query", @OA\Schema(type="string"), description="主题"),
* @OA\Parameter(name="remark", in="query", @OA\Schema(type="string"), description="备注"),
* @OA\Parameter(name="introduce", in="query", @OA\Schema(type="string"), description="介绍"),
* @OA\Response(

@ -654,9 +654,9 @@ class UserController extends BaseController
if (isset($all['is_schoolmate'])) {
$data['is_schoolmate'] = $all['is_schoolmate'];
}
if (isset($all['is_black'])) {
$data['is_black'] = $all['is_black'];
}
// if (isset($all['is_black'])) {
// $data['is_black'] = $all['is_black'];
// }
$this->model->whereIn('id', $idsArray)->update($data);
return $this->success('批量更新成功');
}

@ -60,6 +60,11 @@ class CourseContent extends SoftDeletesModel
return $this->hasOne(CourseContentEvaluation::class, 'course_content_id', 'id');
}
public function directionDetail()
{
return $this->hasOne(ParameterDetail::class, 'id', 'direction');
}
/**
* 获取课程详情小程序码
*/

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('teachers', function (Blueprint $table) {
$table->string('name')->nullable()->comment('授课老师')->change();
$table->text('introduce')->nullable()->comment('老师简介')->change();
$table->string('mobile')->nullable()->comment('联系方式')->change();
// 备注
$table->string('remark')->nullable()->comment('备注');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('teachers', function (Blueprint $table) {
//
});
}
};

@ -35,6 +35,7 @@ Route::group(["namespace" => "Admin", "prefix" => "admin"], function () {
Route::get('users/index', [\App\Http\Controllers\Admin\UserController::class, "index"]);
Route::get('other/table-fileds', [\App\Http\Controllers\Admin\OtherController::class, "tableFileds"]);
Route::get('other/home', [\App\Http\Controllers\Admin\OtherController::class, "home"]);
Route::get('other/courses-home', [\App\Http\Controllers\Admin\OtherController::class, "coursesHome"]);
// 验证码登陆
Route::get('auth/sms-login', [\App\Http\Controllers\Admin\AuthController::class, "smsLogin"]);

Loading…
Cancel
Save