* 'main' of https://git.1024tool.vip/zfc/guzhi:
  feat: 凭证上传的图片加了大小限制,10mb
  feat: 上传凭证图片地址参数更改
  更新 app/api/v1/app_valuations/app_valuations.py
  更新 app/api/v1/app_valuations/app_valuations.py
  更新 app/utils/calculation_engine/formula_registry.py
This commit is contained in:
Wei_佳 2025-11-27 10:35:49 +08:00
commit d98330d5ce
3 changed files with 48 additions and 15 deletions

View File

@ -70,15 +70,19 @@ async def _perform_valuation_calculation(user_id: int, data: UserValuationCreate
except Exception as e:
logger.warning("valuation.policy_fetch_timeout industry={} err={}", data.industry, repr(e))
policy_match_score = getattr(policy_obj, 'score', 0.0) or 0.0
# 提取 经济价值B1 计算参数
input_data_by_b1 = await _extract_calculation_params_b1(data)
# ESG关联价值 ESG分 (0-10分)
input_data_by_b1["esg_score"] = esg_score
# 行业修正系数I
input_data_by_b1["industry_coefficient"] = fix_num_score
# 政策匹配度
input_data_by_b1["policy_match_score"] = policy_match_score
# 提取 经济价值B1 计算参数
input_data_by_b1 = await _extract_calculation_params_b1(
data, esg_score=esg_score, industry_coefficient=fix_num_score, policy_match_score=policy_match_score
)
# 侵权分 默认 6
try:
@ -342,7 +346,12 @@ async def calculate_valuation(
raise HTTPException(status_code=500, detail=f"任务提交失败: {str(e)}")
async def _extract_calculation_params_b1(data: UserValuationCreate) -> Dict[str, Any]:
async def _extract_calculation_params_b1(
data: UserValuationCreate,
esg_score: float = 0.0,
industry_coefficient: float = 0.0,
policy_match_score: float = 0.0,
) -> Dict[str, Any]:
"""
从用户提交的数据中提取计算所需的参数
@ -442,7 +451,10 @@ async def _extract_calculation_params_b1(data: UserValuationCreate) -> Dict[str,
'link_views': safe_float(data.link_views),
# 政策乘数B13相关参数
'implementation_stage': implementation_stage,
'funding_support': funding_support
'funding_support': funding_support,
'esg_score': safe_float(esg_score),
'industry_coefficient': safe_float(industry_coefficient),
'policy_match_score': safe_float(policy_match_score),
}
@ -539,7 +551,7 @@ async def _extract_calculation_params_b3(data: UserValuationCreate) -> Dict[str,
price_fluctuation = [float(i) for i in data.price_fluctuation]
highest_price, lowest_price = max(price_fluctuation), min(price_fluctuation)
# lawsuit_status = "无诉讼" # 诉讼状态 TODO (API获取)
inheritor_ages = data.inheritor_age_count # [45, 60, 75] # 传承人年龄列表
inheritor_ages = [float(i) for i in data.inheritor_age_count] # [45, 60, 75] # 传承人年龄列表
return {
"highest_price": highest_price,
"lowest_price": lowest_price,

View File

@ -44,12 +44,12 @@ def _node(
FORMULA_TREE: List[FormulaTreeNode] = [
_node(
"FINAL_A",
"最终估值A",
"最终估值A = 模型估值B × 0.7 + 市场估值C × 0.3",
"10",
children=[
_node(
"FINAL_A",
"最终估值A",
"最终估值A = 模型估值B × 0.7 + 市场估值C × 0.3",
"10",
children=[
_node(
"MODEL_B",
"模型估值B",
@ -224,6 +224,13 @@ FORMULA_TREE: List[FormulaTreeNode] = [
),
],
),
_node(
"DYNAMIC_PLEDGE_RATE",
"动态质押率DPR",
"动态质押率DPR = 基础质押率 × (1 + 流量修正系数) + 政策加成系数 - 流动性调节因子",
"40",
group="DYNAMIC_PLEDGE",
),
],
)
]

View File

@ -145,10 +145,10 @@
<n-form-item label="上传支付凭证" required>
<n-upload
:action="actionUrl"
v-model:file-list="fileList"
list-type="image-card"
:max="1"
accept="image/png,image/jpeg,image/jpg"
@before-upload="beforeUpload"
@finish="handleUploadFinish"
@remove="deleteUpload"
>
@ -293,12 +293,16 @@ const formModel = reactive({
invoiceHeader: null,
invoiceType: null,
})
const fileList = ref([])
const message = useMessage()
//
const isFormValid = computed(() => {
return fileList.value.length > 0 && formModel.invoiceHeader && formModel.invoiceType
return (
uploadedFile.value &&
uploadedFile.value.length > 0 &&
formModel.invoiceHeader &&
formModel.invoiceType
)
})
const handleUploadFinish = (file) => {
@ -309,6 +313,16 @@ const deleteUpload = () => {
uploadedFile.value = ''
}
const beforeUpload = (data) => {
const file = data.file.file
const isLt10M = file.size / 1024 / 1024 < 10
if (!isLt10M) {
message.error('图片大小不能超过10MB请重新上传')
return false
}
return true
}
//
function handleUploadSubmit() {
if (!isFormValid.value) {