mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 08:27:13 +08:00
fix salary assert method
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
|||||||
import { parseSalary } from "@geekgeekrun/sqlite-plugin/dist/utils/parser"
|
import { parseSalary } from "@geekgeekrun/sqlite-plugin/dist/utils/parser"
|
||||||
import { waitForSageTimeOrJustContinue } from './sage-time.mjs'
|
import { waitForSageTimeOrJustContinue } from './sage-time.mjs'
|
||||||
import cityGroupData from './cityGroup.mjs'
|
import cityGroupData from './cityGroup.mjs'
|
||||||
|
import { hasIntersection } from '@geekgeekrun/utils/number.mjs';
|
||||||
const flattedCityList = []
|
const flattedCityList = []
|
||||||
;(cityGroupData?.zpData?.cityGroup ?? []).forEach(it => {
|
;(cityGroupData?.zpData?.cityGroup ?? []).forEach(it => {
|
||||||
const firstChar = it.firstChar
|
const firstChar = it.firstChar
|
||||||
@@ -986,20 +987,24 @@ async function toRecommendPage (hooks) {
|
|||||||
function checkIfSalarySuit(salaryDesc) {
|
function checkIfSalarySuit(salaryDesc) {
|
||||||
const salaryData = parseSalary(salaryDesc)
|
const salaryData = parseSalary(salaryDesc)
|
||||||
if (expectSalaryCalculateWay === SalaryCalculateWay.MONTH_SALARY) {
|
if (expectSalaryCalculateWay === SalaryCalculateWay.MONTH_SALARY) {
|
||||||
if (expectSalaryHigh && salaryData.high > expectSalaryHigh) {
|
let ourSalaryInterval = [expectSalaryLow ?? null, expectSalaryHigh ?? null]
|
||||||
return false
|
if (ourSalaryInterval.every(it => !isNaN(parseFloat(it)))) {
|
||||||
|
ourSalaryInterval = ourSalaryInterval.sort((a, b) => a - b)
|
||||||
}
|
}
|
||||||
if (expectSalaryLow && salaryData.high < expectSalaryLow) {
|
const theirSalaryInterval = [salaryData.low ?? null, salaryData.high ?? null]
|
||||||
return false
|
return hasIntersection(theirSalaryInterval, ourSalaryInterval)
|
||||||
}
|
}
|
||||||
} else if (expectSalaryCalculateWay === SalaryCalculateWay.ANNUAL_PACKAGE) {
|
else if (expectSalaryCalculateWay === SalaryCalculateWay.ANNUAL_PACKAGE) {
|
||||||
const salaryDataMonth = salaryData.month || 12
|
const salaryDataMonth = salaryData.month || 12
|
||||||
if (expectSalaryHigh && (salaryData.high * salaryDataMonth) / 10 > expectSalaryHigh) {
|
let ourSalaryInterval = [expectSalaryLow ?? null, expectSalaryHigh ?? null]
|
||||||
return false
|
if (ourSalaryInterval.every(it => !isNaN(parseFloat(it)))) {
|
||||||
}
|
ourSalaryInterval = ourSalaryInterval.sort((a, b) => a - b)
|
||||||
if (expectSalaryLow && (salaryData.high * salaryDataMonth) / 10 < expectSalaryLow) {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
const theirSalaryInterval = [salaryData.low ?? null, salaryData.high ?? null].map(
|
||||||
|
it =>
|
||||||
|
it === null ? null : (it * salaryDataMonth / 10)
|
||||||
|
)
|
||||||
|
return hasIntersection(theirSalaryInterval, ourSalaryInterval)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const expectSalaryCalculateWayOption = [
|
|||||||
value: SalaryCalculateWay.MONTH_SALARY
|
value: SalaryCalculateWay.MONTH_SALARY
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '“年包”(单位为 万元 - 即“W”)',
|
name: '总包(单位为 万元 - 即“W”)',
|
||||||
value: SalaryCalculateWay.ANNUAL_PACKAGE
|
value: SalaryCalculateWay.ANNUAL_PACKAGE
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
export function hasIntersection(interval1, interval2) {
|
||||||
|
// 通用函数:将区间标准化,null转换为对应的无穷大
|
||||||
|
const normalizeInterval = (interval) => {
|
||||||
|
const [start, end] = interval;
|
||||||
|
return [
|
||||||
|
[null, undefined].includes(start) ? -Infinity : start,
|
||||||
|
[null, undefined].includes(end) ? Infinity : end
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
const [norm1Start, norm1End] = normalizeInterval(interval1);
|
||||||
|
const [norm2Start, norm2End] = normalizeInterval(interval2);
|
||||||
|
|
||||||
|
// 判断交集
|
||||||
|
return Math.max(norm1Start, norm2Start) <= Math.min(norm1End, norm2End);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user