|
|
@@ -615,6 +615,27 @@ class InstitutionService:
|
|
|
scope_map = {"EMPLOYEE_SELECT": "employee", "EMPLOYEE_DEPARTMENT": "department", "EMPLOYEE_ALL": "all"}
|
|
|
result_dict["applicable_scope"] = scope_map.get(adapter_type, result_dict.get("applicable_scope", "none"))
|
|
|
|
|
|
+ # 补充:从 scope 接口获取员工列表(detailinfo.query 可能不返回 owner_id_list)
|
|
|
+ if not result_dict.get("employee_ids"):
|
|
|
+ try:
|
|
|
+ scope_result = await InstitutionScopeService.scopepageinfo_query_service(
|
|
|
+ auth=auth,
|
|
|
+ institution_id=institution_id,
|
|
|
+ enterprise_id=enterprise_id,
|
|
|
+ page_num=1,
|
|
|
+ page_size=500,
|
|
|
+ )
|
|
|
+ owner_list = scope_result.get("owner_id_list", []) or []
|
|
|
+ adapter = scope_result.get("adapter_type")
|
|
|
+ if owner_list and adapter in ("EMPLOYEE_SELECT", None):
|
|
|
+ result_dict["employee_ids"] = owner_list
|
|
|
+ result_dict["scope_owner_id_list"] = owner_list
|
|
|
+ if adapter and not result_dict.get("applicable_scope"):
|
|
|
+ scope_map = {"EMPLOYEE_SELECT": "employee", "EMPLOYEE_DEPARTMENT": "department", "EMPLOYEE_ALL": "all"}
|
|
|
+ result_dict["applicable_scope"] = scope_map.get(adapter, result_dict.get("applicable_scope", "none"))
|
|
|
+ except Exception as e:
|
|
|
+ log.debug(f"查询 scope 补充员工列表失败(不影响主流程): {e}")
|
|
|
+
|
|
|
# 补充本地规则和额度
|
|
|
from app.plugin.module_payment.expense.rule.model import ExpenseRuleModel
|
|
|
from app.plugin.module_payment.expense.quota.model import QuotaModel
|
|
|
@@ -632,10 +653,24 @@ class InstitutionService:
|
|
|
"standard_name": r.standard_name,
|
|
|
"standard_desc": r.standard_desc,
|
|
|
}
|
|
|
- if hasattr(r, 'condition_info') and r.condition_info:
|
|
|
- rule_item["condition_info"] = r.condition_info
|
|
|
if hasattr(r, 'single_limit') and r.single_limit:
|
|
|
rule_item["single_limit"] = float(r.single_limit)
|
|
|
+ if hasattr(r, 'condition_info') and r.condition_info:
|
|
|
+ rule_item["condition_info"] = r.condition_info
|
|
|
+ for cond in r.condition_info:
|
|
|
+ factor = cond.get("rule_factor")
|
|
|
+ try:
|
|
|
+ value = float(cond.get("rule_value", 0))
|
|
|
+ except (ValueError, TypeError):
|
|
|
+ continue
|
|
|
+ if factor == "QUOTA_DAY":
|
|
|
+ rule_item["max_day_amount"] = value
|
|
|
+ elif factor == "QUOTA_MONTH":
|
|
|
+ rule_item["max_month_amount"] = value
|
|
|
+ elif factor == "QUOTA_QUARTER":
|
|
|
+ rule_item["max_quarter_amount"] = value
|
|
|
+ elif factor == "QUOTA_YEAR":
|
|
|
+ rule_item["max_year_amount"] = value
|
|
|
rule_list.append(rule_item)
|
|
|
result_dict["rule_list"] = rule_list
|
|
|
|