|
|
@@ -317,28 +317,29 @@ class InstitutionService:
|
|
|
if adapter_type == "EMPLOYEE_SELECT":
|
|
|
# 按员工选择 → 直接使用传入的员工ID
|
|
|
employee_ids = [str(i) for i in add_ids if i]
|
|
|
- elif adapter_type in ("EMPLOYEE_DEPARTMENT", "DEPARTMENT_SELECT"):
|
|
|
- # 按部门 → 查该部门下的所有员工
|
|
|
+ elif adapter_type == "EMPLOYEE_ALL":
|
|
|
+ # 全部员工(包括未激活的,待后续激活时更新状态)
|
|
|
+ from app.plugin.module_payment.employee.model import EmployeeModel
|
|
|
+ emp_stmt = select(EmployeeModel).where(
|
|
|
+ EmployeeModel.enterprise_id == enterprise_id,
|
|
|
+ EmployeeModel.status.in_(["EMPLOYEE_CREATE", "EMPLOYEE_ACTIVATED"]),
|
|
|
+ )
|
|
|
+ emp_result = await auth.db.execute(emp_stmt)
|
|
|
+ employee_ids = [emp.employee_id for emp in emp_result.scalars().all() if emp.employee_id]
|
|
|
+
|
|
|
+ elif adapter_type == "EMPLOYEE_DEPARTMENT":
|
|
|
+ # 按部门 → 查该部门下的所有员工(包括未激活的)
|
|
|
for dept_id in add_ids:
|
|
|
dept_id_str = str(dept_id)
|
|
|
from app.plugin.module_payment.employee.model import EmployeeModel
|
|
|
emp_stmt = select(EmployeeModel).where(
|
|
|
EmployeeModel.enterprise_id == enterprise_id,
|
|
|
- EmployeeModel.status == "EMPLOYEE_ACTIVATED",
|
|
|
+ EmployeeModel.status.in_(["EMPLOYEE_CREATE", "EMPLOYEE_ACTIVATED"]),
|
|
|
)
|
|
|
emp_result = await auth.db.execute(emp_stmt)
|
|
|
for emp in emp_result.scalars().all():
|
|
|
if emp.department_ids and dept_id_str in emp.department_ids:
|
|
|
employee_ids.append(emp.employee_id)
|
|
|
- elif adapter_type == "EMPLOYEE_ALL":
|
|
|
- # 全部员工
|
|
|
- from app.plugin.module_payment.employee.model import EmployeeModel
|
|
|
- emp_stmt = select(EmployeeModel).where(
|
|
|
- EmployeeModel.enterprise_id == enterprise_id,
|
|
|
- EmployeeModel.status == "EMPLOYEE_ACTIVATED",
|
|
|
- )
|
|
|
- emp_result = await auth.db.execute(emp_stmt)
|
|
|
- employee_ids = [emp.employee_id for emp in emp_result.scalars().all() if emp.employee_id]
|
|
|
|
|
|
# 去重
|
|
|
employee_ids = list(set(employee_ids))
|