|
|
@@ -84,7 +84,25 @@ class EmployeeHandler(BaseHandler[dict]):
|
|
|
async def _handle_add(self, data: EmployeeChangeContent, auth: AuthSchema) -> bool:
|
|
|
"""处理员工新增(未激活,不触发额度联动)"""
|
|
|
log.info(f"员工新增: employee_id={data.employee_id}, enterprise_id={data.enterprise_id}")
|
|
|
- await self.update_employee(data, auth)
|
|
|
+ # 有则更新,无则新增
|
|
|
+ from app.plugin.module_payment.employee.crud import EmployeeCRUD
|
|
|
+ crud = EmployeeCRUD(auth)
|
|
|
+ exists = await crud.get_by_employee_id(data.employee_id, data.enterprise_id)
|
|
|
+ if exists:
|
|
|
+ await self.update_employee(data, auth)
|
|
|
+ else:
|
|
|
+ update_data = EmployeeCreateOrUpdateSchema(
|
|
|
+ enterprise_id=data.enterprise_id,
|
|
|
+ employee_id=data.employee_id,
|
|
|
+ employee_name=data.employee_name,
|
|
|
+ employee_mobile=data.mobile,
|
|
|
+ status=data.activate,
|
|
|
+ employee_email=data.email,
|
|
|
+ identity_open_id=data.open_id,
|
|
|
+ department_list=data.department_list,
|
|
|
+ role_list=data.role_list,
|
|
|
+ )
|
|
|
+ await crud.create(data=update_data.model_dump(exclude_none=True))
|
|
|
return True
|
|
|
|
|
|
async def _handle_activate(self, data: EmployeeChangeContent, auth: AuthSchema) -> bool:
|