调整估值与交易逻辑
This commit is contained in:
parent
97b872aa9b
commit
7df2bde70b
@ -141,8 +141,7 @@ async def get_quota(current_user: AppUser = Depends(get_current_app_user)):
|
|||||||
- 若后续接入配额系统,可从数据库中读取真实值
|
- 若后续接入配额系统,可从数据库中读取真实值
|
||||||
"""
|
"""
|
||||||
remaining_count = current_user.remaining_quota
|
remaining_count = current_user.remaining_quota
|
||||||
user_type = "体验用户"
|
return Success(data={"remaining_count": remaining_count})
|
||||||
return Success(data={"remaining_count": remaining_count, "user_type": user_type})
|
|
||||||
|
|
||||||
|
|
||||||
@router.put("/profile", response_model=BasicResponse[dict], summary="更新用户信息")
|
@router.put("/profile", response_model=BasicResponse[dict], summary="更新用户信息")
|
||||||
|
|||||||
@ -232,6 +232,7 @@ async def _perform_valuation_calculation(user_id: int, data: UserValuationCreate
|
|||||||
market_value_c=calculation_result.get('market_value_c'),
|
market_value_c=calculation_result.get('market_value_c'),
|
||||||
final_value_ab=calculation_result.get('final_value_ab'),
|
final_value_ab=calculation_result.get('final_value_ab'),
|
||||||
calculation_result=calculation_result,
|
calculation_result=calculation_result,
|
||||||
|
status='pending',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
@ -468,7 +469,6 @@ async def calculate_valuation(
|
|||||||
operator_name=user.alias or user.username or user.phone or "",
|
operator_name=user.alias or user.username or user.phone or "",
|
||||||
before_count=before,
|
before_count=before,
|
||||||
after_count=before - 1,
|
after_count=before - 1,
|
||||||
op_type="consume",
|
|
||||||
remark="发起估值"
|
remark="发起估值"
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@ -103,7 +103,7 @@ async def send_email(payload: SendEmailRequest = Body(...)):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
result = {"status": "FAIL", "error": str(e)}
|
result = {"status": "FAIL", "error": str(e)}
|
||||||
|
|
||||||
body_summary = payload.body[:500]
|
body_summary = payload.body
|
||||||
status = result.get("status")
|
status = result.get("status")
|
||||||
error = result.get("error")
|
error = result.get("error")
|
||||||
first_name = attachments[0][1] if attachments else None
|
first_name = attachments[0][1] if attachments else None
|
||||||
@ -128,6 +128,14 @@ async def send_email(payload: SendEmailRequest = Body(...)):
|
|||||||
if r:
|
if r:
|
||||||
r.extra = (r.extra or {}) | payload.model_dump()
|
r.extra = (r.extra or {}) | payload.model_dump()
|
||||||
await r.save()
|
await r.save()
|
||||||
|
try:
|
||||||
|
inv = await r.invoice
|
||||||
|
if inv:
|
||||||
|
inv.status = "invoiced"
|
||||||
|
await inv.save()
|
||||||
|
logger.info("transactions.invoice_mark_invoiced receipt_id={} invoice_id={}", payload.receipt_id, inv.id)
|
||||||
|
except Exception as e2:
|
||||||
|
logger.warning("transactions.invoice_mark_invoiced_fail receipt_id={} err={}", payload.receipt_id, str(e2))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("transactions.email_extra_save_fail id={} err={}", payload.receipt_id, str(e))
|
logger.error("transactions.email_extra_save_fail id={} err={}", payload.receipt_id, str(e))
|
||||||
|
|
||||||
|
|||||||
@ -491,7 +491,7 @@ class ValuationController:
|
|||||||
await valuation.update_from_dict(update_data)
|
await valuation.update_from_dict(update_data)
|
||||||
await valuation.save()
|
await valuation.save()
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
valuation.status = "success"
|
valuation.status = update_data.get("status", "pending")
|
||||||
if not getattr(valuation, "audited_at", None):
|
if not getattr(valuation, "audited_at", None):
|
||||||
valuation.audited_at = datetime.now()
|
valuation.audited_at = datetime.now()
|
||||||
await valuation.save()
|
await valuation.save()
|
||||||
|
|||||||
@ -106,7 +106,7 @@ class BasicValueB11Calculator:
|
|||||||
# 使用两个增长率的平均值
|
# 使用两个增长率的平均值
|
||||||
avg_growth_rate = (growth_rate_1 + growth_rate_2) / 2
|
avg_growth_rate = (growth_rate_1 + growth_rate_2) / 2
|
||||||
|
|
||||||
return avg_growth_rate
|
return max(avg_growth_rate, 0.0)
|
||||||
|
|
||||||
def calculate_legal_strength_l(self,
|
def calculate_legal_strength_l(self,
|
||||||
patent_score: float,
|
patent_score: float,
|
||||||
@ -379,4 +379,4 @@ if __name__ == "__main__":
|
|||||||
# print(f"增长率: {growth_rate*100}%")
|
# print(f"增长率: {growth_rate*100}%")
|
||||||
# print(f"(1+14%)^5 = {growth_factor:.4f}")
|
# print(f"(1+14%)^5 = {growth_factor:.4f}")
|
||||||
# print(f"2333 × {growth_factor:.4f} = {initial_value * growth_factor:.2f}")
|
# print(f"2333 × {growth_factor:.4f} = {initial_value * growth_factor:.2f}")
|
||||||
# print(f"再除以5: {initial_value * growth_factor:.2f} ÷ 5 = {result:.2f}")
|
# print(f"再除以5: {initial_value * growth_factor:.2f} ÷ 5 = {result:.2f}")
|
||||||
|
|||||||
@ -48,6 +48,20 @@ class TrafficFactorB12Calculator:
|
|||||||
|
|
||||||
traffic_factor = (math.log(search_index_s1 / industry_average_s2) * 0.3 +
|
traffic_factor = (math.log(search_index_s1 / industry_average_s2) * 0.3 +
|
||||||
social_media_spread_s3 * 0.7)
|
social_media_spread_s3 * 0.7)
|
||||||
|
|
||||||
|
"""
|
||||||
|
为什么需要
|
||||||
|
|
||||||
|
- 经济价值 B1 的公式是 B1 = B11 × (1 + B12) × B13 (app/utils/calculation_engine/economic_value_b1/economic_value_b1.py:34-45)。
|
||||||
|
- 如果 B12 < -1 ,则 (1 + B12) 会变成负数,导致 B1 翻成负值并把模型估值 B(final_value_ab/model_value_b.py:48-50)拉到巨负。
|
||||||
|
- 通过设置 B12 ≥ -0.9 ,确保 (1 + B12) ≥ 0.1 ,即乘数始终为正且不至于过小。
|
||||||
|
直观示例
|
||||||
|
|
||||||
|
- 原始计算得到 B12 = -1.8 (例如 ln(S1/S2) 很大负、社交传播度 S3 又很低),则 (1 + B12) = -0.8 ,会让 B1 变负。
|
||||||
|
- 裁剪后 B12 = -0.9 ,则 (1 + B12) = 0.1 , B1 保持为正,避免最终估值出现大幅负值。
|
||||||
|
"""
|
||||||
|
if traffic_factor < -0.9:
|
||||||
|
traffic_factor = -0.9
|
||||||
|
|
||||||
return traffic_factor
|
return traffic_factor
|
||||||
|
|
||||||
@ -346,4 +360,4 @@ if __name__ == "__main__":
|
|||||||
print(f"覆盖人群指数: {coverage_index:.4f}")
|
print(f"覆盖人群指数: {coverage_index:.4f}")
|
||||||
print(f"转化效率: {conversion_efficiency:.4f}")
|
print(f"转化效率: {conversion_efficiency:.4f}")
|
||||||
print(f"社交媒体传播度S3: {social_media_spread_s3:.4f}")
|
print(f"社交媒体传播度S3: {social_media_spread_s3:.4f}")
|
||||||
print(f"流量因子B12: {traffic_factor:.4f}")
|
print(f"流量因子B12: {traffic_factor:.4f}")
|
||||||
|
|||||||
4
估值字段.txt
4
估值字段.txt
@ -37,8 +37,8 @@
|
|||||||
|
|
||||||
|
|
||||||
export DOCKER_DEFAULT_PLATFORM=linux/amd64
|
export DOCKER_DEFAULT_PLATFORM=linux/amd64
|
||||||
docker build -t zfc931912343/guzhi-fastapi-admin:v2.0 .
|
docker build -t zfc931912343/guzhi-fastapi-admin:v2.1 .
|
||||||
docker push zfc931912343/guzhi-fastapi-admin:v2.0
|
docker push zfc931912343/guzhi-fastapi-admin:v2.1
|
||||||
|
|
||||||
|
|
||||||
# 运行容器
|
# 运行容器
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user