修复竞争比
This commit is contained in:
@@ -292,7 +292,7 @@ class CrawlerService
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算竞争比(格式:1:比例,保留2位小数)
|
||||
* 计算竞争比(格式:1:比例,四舍五入取整,无小数)
|
||||
* @param int $zprs 招聘人数
|
||||
* @param int $bkrs 审核通过人数
|
||||
* @return string
|
||||
@@ -309,16 +309,14 @@ class CrawlerService
|
||||
|
||||
// 将招聘人数简化为1,计算审核通过人数与招聘人数的比例
|
||||
$ratio = $bkrs / $zprs;
|
||||
$ratioRounded = (int) round($ratio, 0, PHP_ROUND_HALF_UP);
|
||||
|
||||
// 保留2位小数
|
||||
$ratioFormatted = number_format($ratio, 2, '.', '');
|
||||
|
||||
// 如果小数部分是.00,则显示为整数
|
||||
if (floatval($ratioFormatted) == intval($ratioFormatted)) {
|
||||
return '1:' . intval($ratioFormatted);
|
||||
// 防止四舍五入后为0的极端情况
|
||||
if ($ratioRounded < 0) {
|
||||
$ratioRounded = 0;
|
||||
}
|
||||
|
||||
return '1:' . $ratioFormatted;
|
||||
return '1:' . $ratioRounded;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user