66 lines
2.0 KiB
Python
Executable File
66 lines
2.0 KiB
Python
Executable File
def get_reward_by_distance(project_type, distance):
|
|
"""
|
|
根据项目类型和距离计算奖励金额
|
|
|
|
Args:
|
|
project_type (str): 项目类型
|
|
distance (float): 距离(公里)
|
|
|
|
Returns:
|
|
float: 奖励金额(元)
|
|
"""
|
|
# 2025.04.21 by v6ole
|
|
# 奖励配置说明:
|
|
# 格式为: '项目类型': [(距离上限1, 奖励金额1), (距离上限2, 奖励金额2), ...]
|
|
# 距离单位: 公里, 金额单位: 元
|
|
# 配置按照距离从小到大排序,系统会自动匹配第一个符合条件的奖励金额
|
|
rewards_config = {
|
|
# 校园安防"4+N"项目奖励标准:
|
|
# - 0-5公里: 20元/台
|
|
# - 5-30公里: 40元/台
|
|
# - 30-50公里: 50元/台
|
|
# - 50公里以上: 60元/台
|
|
'校园安防"4+N"项目': [
|
|
(5, 20),
|
|
(30, 40),
|
|
(50, 50),
|
|
(float('inf'), 60)
|
|
],
|
|
|
|
# 综治视联网奖励标准:
|
|
# - 0-10公里: 30元/台
|
|
# - 10-30公里: 40元/台
|
|
# - 30-50公里: 50元/台
|
|
# - 50公里以上: 60元/台
|
|
'综治视联网': [
|
|
(10, 30),
|
|
(30, 40),
|
|
(50, 50),
|
|
(float('inf'), 60)
|
|
],
|
|
|
|
# 教育城域网奖励标准:
|
|
# - 0-5公里: 20元/台
|
|
# - 5-30公里: 30元/台
|
|
# - 30-50公里: 40元/台
|
|
# - 50公里以上: 50元/台
|
|
'教育城域网': [
|
|
(5, 20),
|
|
(30, 30),
|
|
(50, 40),
|
|
(float('inf'), 50)
|
|
],
|
|
|
|
# 其他项目统一标准:
|
|
# - 任何距离: 30元/台
|
|
'其他': [(float('inf'), 30)]
|
|
}
|
|
|
|
if project_type not in rewards_config:
|
|
return 0
|
|
|
|
for max_distance, reward in rewards_config[project_type]:
|
|
if distance <= max_distance:
|
|
return reward
|
|
|
|
return 0 |