mengchang před 2 měsíci
rodič
revize
50b4981a17

binární
backend/routers/__pycache__/estimate.cpython-310.pyc


+ 38 - 3
backend/routers/estimate.py

@@ -745,6 +745,28 @@ async def simulate_calc(
         if k.startswith("option_"):
             option_ids.append(int(v))
 
+
+    # ---------------- 重新取模板与机型名 ----------------
+    row = db.execute(text("""
+        SELECT m.name,
+               t.estimate_packet
+        FROM machine_temp t
+        JOIN t_machine m ON t.machine_id = m.machine_id
+        WHERE t.machine_id = :mid
+    """), {"mid": machine_id}).fetchone()
+
+    if not row:
+        return HTMLResponse("机型模板不存在")
+    tpl = json.loads(row.estimate_packet)
+    # ---------------- 构造 valueId -> valueText 映射 ----------------
+    value_name_map = {}
+
+    for step in tpl["template"]:
+        for p in step["properties"]:
+            for v in p["values"]:
+                value_name_map[str(v["valueId"])] = v["valueText"]
+
+
     # ---------------- 基准价 ----------------
 
     base_row = db.execute(text("""
@@ -754,7 +776,14 @@ async def simulate_calc(
         LIMIT 1
     """), {"mid": machine_id}).fetchone()
 
-    base_price = float(base_row.base_price) if base_row else 1000.0
+
+    base_price_input = form.get("base_price")
+
+    if base_price_input and str(base_price_input).strip():
+        base_price = float(base_price_input)
+    else:
+        base_price = float(base_row.base_price) if base_row else 1
+    # base_price = float(base_row.base_price) if base_row else 1000.0
 
     # ---------------- 读取选项扣减规则 ----------------
 
@@ -871,7 +900,8 @@ async def simulate_calc(
 
         for it in items:
             detail_rows.append({
-                "option_name": it.option_id,
+                # "option_name": it.option_id,
+                "option_name":  value_name_map.get(str(it.option_id), str(it.option_id)),
                 "factor": it.factor
             })
 
@@ -929,7 +959,7 @@ async def simulate_calc(
         WHERE t.machine_id = :mid
     """), {"mid": machine_id}).fetchone()
 
-    import json
+    # import json
     tpl = json.loads(row.estimate_packet)
 
     return templates.TemplateResponse(
@@ -1229,3 +1259,8 @@ def calculate_price(db, base_price: float, selected_option_ids: list[int]):
         "special_discount_applied": special_applied,
         "details": details
     }
+
+
+
+
+# curl -sS -X POST "http://127.0.0.1:8002/api/product/bid" -H "Content-Type: application/json" -H "X-API-Key: dHiw0yduUhnpQRV9z30EGpJD8fAne1CJ" -d '{"task_id":2,"task_types":["bid"]}'

+ 1 - 1
backend/templates/simulate_one.html

@@ -145,7 +145,7 @@ td,th{
 {% for d in result.details %}
 <tr>
     <td
-        {% if d.option_name and d.option_name.startswith('--') %}
+        {% if d.option_name and (d.option_name|string).startswith('--') %}
             style="color:red;font-weight:bold;"
         {% endif %}
     >

+ 0 - 0
mysql/init.sql

@@ -117,7 +117,6 @@ CREATE TABLE price_option_factor (
 -- ADD COLUMN is_special TINYINT DEFAULT 0 COMMENT '是否特殊选项(用于特殊规则组)',
 -- ADD COLUMN repair_level TINYINT DEFAULT 0 COMMENT '维修分级:0非维修 1次要 2重要 3核心',
 -- ADD COLUMN priority INT DEFAULT 0 COMMENT '覆盖与排序优先级';
 -- ADD COLUMN base_template_id BIGINT NOT NULL COMMENT '所属基础模板';
 
 CREATE TABLE price_damage_group (

+ 29 - 0
tools/requests_xiaoinag_huishou.py

@@ -0,0 +1,29 @@
+import requests
+import json
+
+url = "https://www.itcodestep.com/xz/admin/quotationApplet/quoteDetails/getAllQuoteDetailsWithLatestImage"
+params = {
+    "filterDate": "2026-02-08"
+}
+
+headers = {
+    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows",
+    "Content-Type": "application/json",
+    "Referer": "https://servicewechat.com/wx823ece6cf3881c0d/28/page-frame.html",
+    "xweb_xhr": "1",
+    "Accept": "*/*",
+    "Accept-Encoding": "gzip, deflate, br",
+    "Accept-Language": "zh-CN,zh;q=0.9"
+}
+
+# 注意:这里的 payload 需要根据你在 Fiddler "JSON" 标签页看到的内容进行修改
+# 因为 Content-Length 是 27,大概率是一个简短的 JSON 对象
+payload = {} 
+
+try:
+    response = requests.post(url, params=params, headers=headers, json=payload)
+    print(f"Status Code: {response.status_code}")
+    print("Response Body:")
+    print(response.text)
+except Exception as e:
+    print(f"Error: {e}")