|
|
|
|
@ -58,52 +58,4 @@ class Company extends SoftDeletesModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上市公司(统计或列表)
|
|
|
|
|
* @param bool $retList 是否返回列表,false返回数量,true返回列表
|
|
|
|
|
* @return int|\Illuminate\Database\Eloquent\Collection
|
|
|
|
|
*/
|
|
|
|
|
public static function companyMarket($start_date, $end_date, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignByType = CourseSign::whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->whereNotIn('status', [4, 5])
|
|
|
|
|
->get();
|
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignByType) {
|
|
|
|
|
$query->whereIn('id', $courseSignByType->pluck('user_id'));
|
|
|
|
|
})->where('company_market', 1)->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
// 返回列表
|
|
|
|
|
return $list;
|
|
|
|
|
} else {
|
|
|
|
|
// 返回统计数据
|
|
|
|
|
return $list->count();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 今年上市公司(统计或列表)
|
|
|
|
|
* @param int|null $year 年份,不传则使用当前年份
|
|
|
|
|
* @param bool $retList 是否返回列表,false返回数量,true返回列表
|
|
|
|
|
* @return int|\Illuminate\Database\Eloquent\Collection
|
|
|
|
|
*/
|
|
|
|
|
public static function companyMarketYear($start_date, $end_date, $course_ids, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$year = date('Y');
|
|
|
|
|
$courseSignByType = CourseSign::whereDate('created_at', '>=', $start_date)
|
|
|
|
|
->whereDate('created_at', '<=', $end_date)
|
|
|
|
|
->whereNotIn('status', [4, 5])
|
|
|
|
|
->get();
|
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignByType) {
|
|
|
|
|
$query->whereIn('id', $courseSignByType->pluck('user_id'));
|
|
|
|
|
})->where('company_market', 1)->whereYear('stock_date', $year)->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
// 返回列表
|
|
|
|
|
return $list;
|
|
|
|
|
} else {
|
|
|
|
|
// 返回统计数据
|
|
|
|
|
return $list->count();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|