SELECT DISTINCT
`u`.`user_id` AS `id`,
`u`.`user_name` AS `loginName`,
`u`.`staff_name` AS `name`,
`u`.`password` AS `password`,
`c`.`company_id` AS `companyId`,
`c`.`company_name` AS `companyName`,
`c`.`member_id` AS `memberId`,
`c`.`company_desc` AS `companyDesc`,
`g`.`group_id` AS `departmentId`,
`g`.`group_name` AS `departmentName`,
`u`.`staff_id` AS `staff_id`,
(
SELECT
group_concat(`r`.`pinyin` SEPARATOR ',')
FROM
(
`ralasafe_ralasafe_userrole` `ur`
LEFT JOIN `ralasafe_role` `r` ON ((`ur`.`roleid` = `r`.`id`))
)
WHERE
(
`ur`.`userid` = `u`.`user_id`
)
GROUP BY
`ur`.`userid`
) AS `roles`,
`staf`.`staff_work_status` AS `status`
FROM
(
(
(
(
(
`sys_user` `u`
LEFT JOIN `sys_user_group` `ug` ON (
(
`u`.`user_id` = `ug`.`user_id`
)
)
)
LEFT JOIN `sys_group` `g` ON (
(
`ug`.`group_id` = `g`.`group_id`
)
)
)
LEFT JOIN `sys_user_company` `cm` ON (
(
`u`.`user_id` = `cm`.`user_id`
)
)
)
LEFT JOIN `sys_company` `c` ON (
(
`cm`.`company_id` = `c`.`company_id`
)
)
)
LEFT JOIN `hr_staff` `staf` ON (
(
`u`.`staff_id` = `staf`.`staff_id`
)
)
)
WHERE
(
(
(
`staf`.`staff_work_status` = '1'
)
OR (
`staf`.`staff_work_status` = '2'
)
)
AND (`u`.`status` = '1')
)