master
cody 2 months ago
parent c1b9a32dc4
commit 90e0a24db5

@ -419,6 +419,7 @@ class CompanyController extends BaseController
* @OA\Parameter(name="overseas_experience", in="query", @OA\Schema(type="string", nullable=true), description="海外经验"),
* @OA\Parameter(name="sales_volume", in="query", @OA\Schema(type="string", nullable=true), description="销售额"),
* @OA\Parameter(name="tag", in="query", @OA\Schema(type="string", nullable=true), description="标签,千企走访这类的数据"),
* @OA\Parameter(name="ranking_tag", in="query", @OA\Schema(type="string", nullable=true), description="榜单标签,多个值用英文逗号分隔"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
* @OA\Response(
* response="200",

@ -421,7 +421,7 @@ class OtherController extends CommonController
'course_name' => $course->name,
'course_signs_pass' => CourseSign::courseSignsTotal($start_date, $end_date, 1, [$course->id], false, false),
// 跟班学员数量
'genban_total' => CourseSign::genban($start_date, $end_date, [$course->id]),
'genban_total' => CourseSign::genban($start_date, $end_date, [$course->id], false, false),
// 被投企业数
'yh_invested_total' => CourseSign::yhInvested($start_date, $end_date, [$course->id]),
// 元禾同事数

@ -356,9 +356,10 @@ class CourseSign extends SoftDeletesModel
* @param string $end_date 结束日期
* @param array|null $course_ids 课程ID数组不传则统计所有课程
* @param bool $retList 是否返回列表false返回数量true返回列表
* @param bool $needHistory 是否需要额外数据TraineeStudenttrue需要false不需要
* @return int|\Illuminate\Database\Eloquent\Collection
*/
public static function genban($start_date = null, $end_date = null, $course_ids = null, $retList = false)
public static function genban($start_date = null, $end_date = null, $course_ids = null, $retList = false, $needHistory = true)
{
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
// 获取需要统计跟班学员的课程
@ -374,14 +375,17 @@ class CourseSign extends SoftDeletesModel
return User::with('company')->whereIn('id', $courseSigns->pluck('user_id'))->get();
} else {
$baseCount = User::whereIn('id', $courseSigns->pluck('user_id'))->count();
// 额外数据:从 TraineeStudent 模型中统计
$traineeStudentTotal = TraineeStudent::where(function ($query) use ($start_date, $end_date) {
// 开始结束日期的筛选。or查询
if ($start_date && $end_date) {
$query->whereBetween('start_date', [$start_date, $end_date])
->orWhereBetween('end_date', [$start_date, $end_date]);
}
})->sum('total');
$traineeStudentTotal = 0;
if ($needHistory) {
// 额外数据:从 TraineeStudent 模型中统计
$traineeStudentTotal = TraineeStudent::where(function ($query) use ($start_date, $end_date) {
// 开始结束日期的筛选。or查询
if ($start_date && $end_date) {
$query->whereBetween('start_date', [$start_date, $end_date])
->orWhereBetween('end_date', [$start_date, $end_date]);
}
})->sum('total');
}
return $baseCount + $traineeStudentTotal;
}
}

@ -0,0 +1,32 @@
<?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('companies', function (Blueprint $table) {
// 榜单标签,多个值用英文逗号分隔
$table->string('ranking_tag')->nullable()->comment('榜单标签');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('companies', function (Blueprint $table) {
$table->dropColumn('ranking_tag');
});
}
};
Loading…
Cancel
Save