feat: P0-1 价格脚本引擎(安全公式解析+脚本CRUD+试算+报价集成)
This commit is contained in:
@@ -99,6 +99,24 @@ async def seed() -> None:
|
||||
await db.commit()
|
||||
print("平台公告就绪")
|
||||
|
||||
# 6) 价格脚本示例(幂等:按名称去重)
|
||||
async with SessionLocal() as db:
|
||||
from huamenchuang.models.business import PriceScript
|
||||
SAMPLE_SCRIPTS = [
|
||||
("断桥铝-55系列", "frame", "(w+h)*2/1000*52"),
|
||||
("断桥铝-55系列", "mullion", "length*46"),
|
||||
("断桥铝-55系列", "sash", "length*58"),
|
||||
("双层中空玻璃", "glass", "max(110, area*135)"),
|
||||
("标准五金", "hardware", "sashes*195"),
|
||||
]
|
||||
existing = {n for (n,) in (await db.execute(select(PriceScript.name))).all()}
|
||||
for name, target, formula in SAMPLE_SCRIPTS:
|
||||
if name not in existing:
|
||||
db.add(PriceScript(name=name, target=target, formula=formula,
|
||||
note="种子示例脚本,可在产品管理中修改"))
|
||||
await db.commit()
|
||||
print("价格脚本就绪")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(seed())
|
||||
|
||||
Reference in New Issue
Block a user