| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import pymysql
- conn = pymysql.connect(
- host="127.0.0.1",
- user="root",
- password="root",
- database="recycle",
- charset="utf8mb4"
- )
- damage_groups = [
- ("boot", "开机状态组", 1.00, 1.00),
- ("body", "机身外观组", 1.20, 1.00),
- ("screen", "屏幕综合组", 1.25, 1.10),
- ("account", "账号状态组", 1.00, 1.00),
- ("function", "功能异常组", 1.15, 1.00),
- ("hinge", "转轴结构组", 1.10, 1.00),
- ("repair", "维修履历组", 1.30, 1.10),
- ("other_special", "其他功能问题组", 1.00, 1.00),
- ]
- group_overrides = [
- # 有维修 → 屏幕组权重下降
- ("repair", "screen", "weight", 0.85),
- # 无法开机类问题存在时,功能异常组跳过
- ("boot", "function", "skip", None),
- ]
- with conn.cursor() as cur:
- # ----------------------------
- # price_damage_group
- # ----------------------------
- for g in damage_groups:
- cur.execute("""
- INSERT INTO price_damage_group
- (group_code, group_name, cap_ratio, group_weight)
- VALUES (%s,%s,%s,%s)
- ON DUPLICATE KEY UPDATE
- group_name=VALUES(group_name),
- cap_ratio=VALUES(cap_ratio),
- group_weight=VALUES(group_weight)
- """, g)
- # ----------------------------
- # price_group_override
- # ----------------------------
- for o in group_overrides:
- cur.execute("""
- INSERT INTO price_group_override
- (trigger_group_code, target_group_code, override_type, override_value)
- VALUES (%s,%s,%s,%s)
- ON DUPLICATE KEY UPDATE
- override_type=VALUES(override_type),
- override_value=VALUES(override_value)
- """, o)
- conn.commit()
- print("price_damage_group / price_group_override 初始化完成")
|