Jelajahi Sumber

fix: 创建额度时 employee_id 存为 ALL/员工ID/DEPT:xxx

alphah 2 minggu lalu
induk
melakukan
80c552d60a

+ 10 - 1
backend/app/plugin/module_payment/expense/institution/service.py

@@ -246,8 +246,17 @@ class InstitutionService:
         # 第6步:保存发放规则到本地
         if issuerule_data and issue_rule_id:
             from app.plugin.module_payment.expense.quota.model import QuotaModel
+            # 根据适用范围确定 employee_id
+            scope = (raw_data or {}).get("applicable_scope", "")
+            emp_id = "ALL"
+            if scope == "employee":
+                owner_ids = (raw_data or {}).get("scope_owner_id_list") or []
+                emp_id = owner_ids[0] if owner_ids else "ALL"
+            elif scope == "department":
+                dept_id = (raw_data or {}).get("department_id", "")
+                emp_id = f"DEPT:{dept_id}" if dept_id else "ALL"
             quota_save_data = {
-                "employee_id": "",
+                "employee_id": emp_id,
                 "institution_id": institution_id,
                 "out_biz_no": issuerule_data.get("outer_source_id", f"issue_{institution_id}"),
                 "quota_id": issue_rule_id,