<?xml version="1.0" encoding="UTF-8" ?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<mapper namespace="com.panzhihua.service_user.dao.UserDao">
|
<resultMap id="baseResult" type="com.panzhihua.service_user.model.dos.SysUserDO">
|
<id property="userId" column="user_id"/>
|
<result property="account" column="account"/>
|
<result property="password" column="password"/>
|
<result property="openid" column="openid"/>
|
<result property="sessionKey" column="session_key"/>
|
<result property="unionid" column="unionid"/>
|
<result property="phone" column="phone"/>
|
<result property="nickName" column="nick_name"/>
|
<result property="name" column="name"/>
|
<result property="communityId" column="community_id"/>
|
<result property="sex" column="sex"/>
|
<result property="idCard" column="id_card"/>
|
<result property="birthday" column="birthday"/>
|
<result property="imageUrl" column="image_url"/>
|
<result property="type" column="type"/>
|
<result property="job" column="job"/>
|
<result property="isVolunteer" column="is_volunteer"/>
|
<result property="isPartymember" column="is_partymember"/>
|
<result property="status" column="status"/>
|
<result property="createAt" column="create_at"/>
|
<result property="lastLoginTime" column="last_login_time"/>
|
<result property="tags" column="tags"/>
|
<result property="familyId" column="family_id"/>
|
<result property="faceUrl" column="face_url"/>
|
<result property="faceState" column="face_state"/>
|
<result property="rejectReson" column="reject_reson"/>
|
<result property="areaId" column="area_id"/>
|
<result property="cardPhotoFront" column="card_photo_front"/>
|
<result property="cardPhotoBack" column="card_photo_back"/>
|
<result property="familyBook" column="family_book"/>
|
<result property="continuousLandingDays" column="continuous_landing_days"/>
|
<result property="isTips" column="is_tips"/>
|
<result property="workStatus" column="work_status"/>
|
<result property="workStartTime" column="work_start_time"/>
|
<result property="workEndTime" column="work_end_time"/>
|
<result property="bigAgeTips" column="big_age_tips"/>
|
<result property="plaintextPassword" column="plaintext_password"/>
|
<result property="relationName" column="relation_name"/>
|
<result property="loveIntegral" column="love_integral"/>
|
<result property="playPwd" column="play_pwd"/>
|
|
</resultMap>
|
<sql id="columns">
|
`user_id`,`account`,`password`,`openid`,`session_key`,`unionid`,`phone`,`nick_name`,`name`,play_pwd,
|
`community_id`,`sex`,`id_card`,`birthday`,`image_url`,`type`,`job`,`is_volunteer`,`is_partymember`,
|
`status`,`create_at`,`last_login_time`,`tags`,`family_id`,`face_url`,`face_state`,`reject_reson`,`area_id`,
|
`card_photo_front`,`card_photo_back`,`family_book`,`continuous_landing_days`,`is_tips`,`work_status`,
|
`work_start_time`,`work_end_time`,`big_age_tips`,love_integral
|
</sql>
|
|
|
<select id="indexDataCommunityBackstage" resultType="com.panzhihua.common.model.vos.IndexDataVO">
|
SELECT
|
COUNT(DISTINCT u.user_id)allUser,
|
(select COUNT(m.id) from com_mng_volunteer_mng m where m.community_id = #{communityId} and m.`state`=2)volunteerUser,
|
(select count(id) from com_pb_member cpm where cpm.audit_result = 1 and cpm.community_id = #{communityId}) partymemberUser,
|
COUNT(h.id)house
|
FROM
|
sys_user u
|
JOIN com_act c ON u.community_id = c.community_id
|
LEFT JOIN com_mng_struct_house_user h on u.user_id=h.user_id
|
WHERE u.community_id = #{communityId} and u.type=1
|
</select>
|
|
<update id="timedTaskContinuousLandingDays">
|
UPDATE sys_user u
|
SET u.continuous_landing_days =
|
IF
|
(
|
DATE_FORMAT( u.last_login_time, '%m-%d-%Y' )= DATE_FORMAT( SYSDATE(), '%m-%d-%Y' ),
|
u.continuous_landing_days + 1,
|
0)
|
</update>
|
|
<select id="selectVolunteerMngByPhone" resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
|
select id,create_at,state,name,phone,photo_path,political_face,reject_reson,apply_reson,address,age,job,integral,love_integral
|
community_id,submit_user_id from com_mng_volunteer_mng where phone=#{phone} order by create_at desc limit 1
|
</select>
|
|
<select id="selectCountMemberRole" resultType="java.lang.Integer">
|
SELECT
|
COUNT(a.id)
|
FROM
|
com_pb_member_role a
|
WHERE
|
a.phone = #{phone} and community_id = #{userCommunityId}
|
</select>
|
|
<select id="pageUserAppletsBackstage" resultType="com.panzhihua.common.model.vos.user.SysUserVO">
|
select
|
u.user_id,
|
u.phone,
|
u.nick_name,
|
u.name,
|
u.tags,
|
a.name communityName,
|
u.status,
|
u.create_at,
|
u.love_integral,
|
u.play_pwd,
|
u.last_login_time
|
from sys_user u
|
left join com_act a on u.community_id=a.community_id
|
where
|
u.type=1 and u.community_id is not null and u.app_id =#{pageUserAppletsBackstageDTO.appId}
|
<if test='pageUserAppletsBackstageDTO.phone != null and pageUserAppletsBackstageDTO.phone.trim() != ""'>
|
and u.phone=#{pageUserAppletsBackstageDTO.phone}
|
</if>
|
<if test='pageUserAppletsBackstageDTO.communityId != null and pageUserAppletsBackstageDTO.communityId != 0'>and
|
u.community_id = #{pageUserAppletsBackstageDTO.communityId}
|
</if>
|
<if test='pageUserAppletsBackstageDTO.status != null and pageUserAppletsBackstageDTO.status != 0'>and
|
u.status=#{pageUserAppletsBackstageDTO.status}
|
</if>
|
<if test='pageUserAppletsBackstageDTO.createAtBegin != null '>and u.create_at between
|
#{pageUserAppletsBackstageDTO.createAtBegin} and #{pageUserAppletsBackstageDTO.createAtEnd}
|
</if>
|
<if test='pageUserAppletsBackstageDTO.lastLoginTimeBegin != null '>and u.last_login_time between
|
#{pageUserAppletsBackstageDTO.lastLoginTimeBegin} and #{pageUserAppletsBackstageDTO.lastLoginTimeEnd}
|
</if>
|
order by u.create_at desc
|
|
</select>
|
|
<select id="selectIndexDataKanban" resultType="com.panzhihua.common.model.vos.IndexDataKanbanVO">
|
SELECT
|
COUNT(user_id)allUser,
|
COUNT(case WHEN DATE_FORMAT(t.create_at,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )addUser,
|
COUNT(case WHEN DATE_FORMAT(last_login_time,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )activeDayUser,
|
(SELECT count(user_id) FROM sys_user t left join com_act t1 on t.community_id = t1.community_id WHERE t.type = 1 and t.app_id = #{areaCode} AND last_login_time > date_sub(SYSDATE(), INTERVAL 7 DAY))activeWeekUser
|
FROM
|
sys_user t LEFT JOIN com_act t1 on t.community_id = t1.community_id
|
where t.type=1 and t.community_id is not null and t.app_id = #{areaCode}
|
</select>
|
|
<select id="selectCommunityUserOrder" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
|
SELECT
|
a.`name`,
|
COUNT(u.user_id)num,
|
t1.dayNum
|
FROM
|
com_act a
|
LEFT JOIN sys_user u ON a.community_id = u.community_id and u.type=1 and a.state=0 and u.app_id=#{areaCode}
|
left join (SELECT count( user_id ) dayNum,community_id FROM sys_user WHERE type = 1 and app_id=#{areaCode}
|
AND last_login_time > DATE_FORMAT( date_sub( SYSDATE(), INTERVAL 0 DAY ), '%Y-%m-%d 00:00:00') GROUP BY community_id) t1 on a.community_id = t1.community_id where a.app_id =#{areaCode} GROUP BY a.community_id
|
</select>
|
|
<select id="selectCommunityUserOrderMonth" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
|
select t.* from (
|
SELECT
|
a.`name`,
|
COUNT(u.user_id)num,
|
(SELECT count( user_id ) FROM sys_user WHERE type = 1 and community_id = a.community_id and app_id=#{areaCode}
|
AND last_login_time > DATE_FORMAT( date_sub( SYSDATE(), INTERVAL 0 DAY ), '%Y-%m-%d 00:00:00')) as dayNum
|
FROM
|
com_act a
|
LEFT JOIN sys_user u ON a.community_id = u.community_id
|
and u.type=1 and a.state=0 and u.app_id=#{areaCode} and u.create_at >= DATE_ADD(curdate(),interval -day(curdate())+1 day)
|
GROUP BY a.community_id)t ORDER BY t.num desc
|
</select>
|
|
<select id="pageUserBackstage" resultType="com.panzhihua.common.model.vos.user.AdministratorsUserVO">
|
SELECT
|
u.user_id,
|
u.account,
|
u.`name`,
|
u.`password`,
|
u.phone,
|
e.role_name,
|
e.role_id ,
|
u.`status`,
|
u.love_integral,
|
u.create_at,
|
u.last_login_time
|
FROM
|
sys_user u
|
JOIN sys_user_role r ON u.user_id = r.user_id
|
JOIN sys_role e ON r.role_id = e.role_id
|
left join com_act ca on u.community_id = ca.community_id
|
<if test='administratorsUserVO.roleId != null and administratorsUserVO.roleId!=0'>and
|
e.role_id=#{administratorsUserVO.roleId}
|
</if>
|
<where>
|
u.type=3
|
<if test='administratorsUserVO.communityId != null '>AND u.community_id =
|
#{administratorsUserVO.communityId}
|
</if>
|
<if test='administratorsUserVO.name != null and administratorsUserVO.name.trim() != ""'>AND u.name
|
like concat (#{administratorsUserVO.name},'%')
|
</if>
|
<if test='administratorsUserVO.phone != null and administratorsUserVO.phone.trim() != ""'>AND
|
u.phone like concat(#{administratorsUserVO.phone},'%')
|
</if>
|
<if test='administratorsUserVO.account != null and administratorsUserVO.account.trim() != ""'>AND
|
u.account like concat(#{administratorsUserVO.account},'%')
|
</if>
|
</where>
|
order by u.create_at desc
|
</select>
|
|
<select id="selectCommunityActiveUserOrder" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
|
SELECT
|
COUNT( a.id ) num
|
FROM
|
com_act_activity a
|
WHERE
|
DATE_FORMAT( #{date1}, '%Y-%m-%d' )= DATE_FORMAT( a.create_at,'%Y-%m-%d')
|
</select>
|
|
<select id="selectCommunityAddUserOrder" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
|
select count(user_id) as num,
|
(SELECT count( user_id ) FROM sys_user t LEFT JOIN com_act t1 on t.community_id=t1.community_id WHERE t.type = 1 and t.app_id = #{areaCode}
|
AND last_login_time <![CDATA[ >= ]]> DATE_FORMAT( #{date1}, '%Y-%m-%d 00:00:00')
|
AND last_login_time <![CDATA[ <= ]]> DATE_FORMAT( #{date1}, '%Y-%m-%d 23:59:59')) as dayNum from sys_user as su LEFT JOIN com_act t1 on su.community_id = t1.community_id
|
where su.create_at <![CDATA[ >= ]]> DATE_SUB(DATE_FORMAT(#{date1},'%Y-%m-%d 00:00:00'),INTERVAL 0 DAY)
|
and su.create_at <![CDATA[ <= ]]> DATE_SUB(DATE_FORMAT(#{date1},'%Y-%m-%d 23:59:59'),INTERVAL 0 DAY)
|
and su.type = 1 and su.app_id = #{areaCode}
|
</select>
|
|
<select id="selectDailyAdd" resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
|
SELECT DATE_FORMAT( u.create_at, '%Y-%m-%d' ) as specificDate,count( u.user_id ) total FROM sys_user u
|
LEFT JOIN com_act t1 ON u.community_id = t1.community_id WHERE u.type = 1 AND u.app_id = #{appId} AND u.create_at > #{createAt} GROUP BY specificDate;
|
</select>
|
|
<select id="selectActive" resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
|
SELECT DATE_FORMAT( u.last_login_time, '%Y-%m-%d' ) as specificDate,count( u.user_id ) total FROM sys_user u
|
LEFT JOIN com_act t1 ON u.community_id = t1.community_id WHERE u.type = 1 AND u.app_id = #{appId} AND u.last_login_time > #{lastLoginTime} GROUP BY specificDate;
|
</select>
|
|
<update id="gridMemberEditStatus">
|
update sys_user set status = #{gridMemberEditDTO.status} where user_id in
|
<foreach item="item" collection="gridMemberEditDTO.ids" separator="," open="(" close=")" index="">
|
#{item}
|
</foreach>
|
|
</update>
|
|
<select id="getGridMemberList" resultType="com.panzhihua.common.model.vos.grid.GridMemberVO">
|
select su.user_id,su.image_url,su.nick_name,su.account,su.phone,su.work_status,su.`status`,ca.name as
|
communityName,su.work_start_time,su.work_end_time from sys_user su left join com_act as ca on ca.community_id =
|
su.community_id where su.type = 6
|
<if test='memberRelationDTO.status != null'>AND su.status =
|
#{memberRelationDTO.status}
|
</if>
|
<if test='memberRelationDTO.gridCommunityId != null'>AND ca.community_id =
|
#{memberRelationDTO.gridCommunityId}
|
</if>
|
<if test='memberRelationDTO.gridStreetId != null'>AND ca.street_id = #{memberRelationDTO.gridStreetId}</if>
|
<if test='memberRelationDTO.workStatus != null'>AND su.work_status = #{memberRelationDTO.workStatus}</if>
|
<if test='memberRelationDTO.keyWord != null and memberRelationDTO.keyWord != ""'>and (su.nick_name
|
like concat(#{memberRelationDTO.keyWord},'%') OR su.user_id = #{memberRelationDTO.keyWord} OR su.account
|
like concat(#{memberRelationDTO.keyWord},'%') OR su.phone like concat(#{memberRelationDTO.keyWord},'%'))
|
</if>
|
order by su.create_at desc
|
</select>
|
|
<update id="updateServiceTeam">
|
update com_pb_service_team u set u.phone=#{newphone},is_reg=1 where u.phone=#{oldphone}
|
</update>
|
|
<delete id="deleteStoreByPhoneAndStatus">
|
delete from com_shop_store where delete_status = 1 and phone = #{phone}
|
</delete>
|
|
<select id="getPartyBuildingByIdCard" resultType="java.lang.Long">
|
select id from com_pb_member where audit_result = 1 and id_card = #{idCard}
|
</select>
|
|
<select id="getGridsMemberList"
|
resultType="com.panzhihua.common.model.vos.community.screen.event.EventGridMemberVO">
|
select user_id,nick_name,phone from sys_user where type = 6 and community_id = #{communityId} limit 3
|
</select>
|
|
<update id="updateUserArchives">
|
update sys_user set card_photo_front = #{userArchivesVO.cardPhotoFront}
|
, card_photo_back = #{userArchivesVO.cardPhotoBack}
|
,family_book = #{userArchivesVO.familyBook}
|
,job = #{userArchivesVO.job}
|
where user_id = #{userArchivesVO.userId}
|
</update>
|
|
<select id="selectCountSysUser" resultType="java.lang.Integer">
|
SELECT
|
COUNT(ur.role_id)
|
FROM
|
sys_user u LEFT JOIN sys_user_role ur ON u.user_id = ur.user_id
|
LEFT JOIN sys_role r ON ur.role_id = r.role_id
|
WHERE ur.role_id IS NOT NULL AND u.phone = #{phone} and r.community_id = #{userCommunityId}
|
</select>
|
|
<delete id="delGridMemberRelation">
|
delete from event_grid_member_building_relation where grid_member_id = #{gridMemberId}
|
</delete>
|
|
<update id="updateStoreByPhone">
|
update com_shop_store set sys_user_id = #{sysUserId} where phone = #{phone}
|
</update>
|
|
<update id="updateComPbMemberUserId">
|
update com_pb_member set user_id = #{userId} where audit_result = 1 and id_card = #{idCard}
|
</update>
|
|
<select id="getServiceTeamList" resultType="com.panzhihua.common.model.vos.partybuilding.ComPbServiceTeamWishVO">
|
select id as managerId,`name` from com_pb_service_team where community_id = #{communityId}
|
<if test='param != null and param != ""'>AND `name` like concat(#{param},'%')</if>
|
</select>
|
|
<select id="getUserListByCommunityId" resultType="com.panzhihua.common.model.vos.user.SysUserVO">
|
select user_id,`name` from sys_user as su where type = 3 and community_id = #{communityId}
|
</select>
|
|
<select id="pageUserFace" resultType="com.panzhihua.common.model.vos.LoginUserInfoVO">
|
SELECT
|
u.user_id,
|
u.face_url,
|
u.nick_name,
|
u.`name`,
|
u.phone,
|
u.id_card,
|
u.face_state,
|
u.love_integral,
|
c.area_name communityName,
|
u.create_at
|
FROM
|
sys_user u
|
JOIN com_mng_struct_area c ON u.area_id = c.id
|
<if test='loginUserInfoVO.communityName != null and loginUserInfoVO.communityName.trim() != ""'>
|
AND c.`area_name` like concat(#{loginUserInfoVO.communityName},'%')
|
</if>
|
where u.face_state is not null and u.type=1 and u.community_id = #{loginUserInfoVO.communityId}
|
<if test='loginUserInfoVO.name != null and loginUserInfoVO.name.trim() != ""'>
|
and u.`name` like concat(#{loginUserInfoVO.name},'%')
|
</if>
|
<if test='loginUserInfoVO.phone != null and loginUserInfoVO.phone.trim() != ""'>
|
AND u.phone like concat(#{loginUserInfoVO.phone},'%')
|
</if>
|
order by u.face_state asc,u.create_at asc
|
</select>
|
|
<update id="putUserTag">
|
update sys_user set tags = #{sysUserDO.tags} where user_id = #{sysUserDO.userId}
|
</update>
|
|
<update id="updateMemberRole">
|
update com_pb_member_role u set u.phone=#{newphone},is_reg=1 where u.phone=#{oldphone}
|
</update>
|
|
<select id="selectCountTeam" resultType="java.lang.Integer">
|
SELECT
|
COUNT(a.id)
|
FROM
|
com_pb_service_team a
|
WHERE
|
a.phone = #{phone} and community_id = #{userCommunityId}
|
</select>
|
|
<select id="selectExport" resultType="com.panzhihua.common.model.dtos.user.EexcelUserDTO">
|
SELECT
|
u.user_id 'order',
|
h.house_name doorNumber,
|
if(h.state=2,'租住','自主')isRent,
|
u.`name`,
|
'汉' nation,
|
if(u.is_partymember=1,'党员','群众')politicalOutlook,
|
'未知' maritalStatus,
|
u.phone,
|
'未知' education,
|
u.id_card,
|
'未知' company,
|
'未知' residence,
|
'未知' isPanZhiHua,
|
'未知' situation,
|
'未知' isContact,
|
'未知' major,
|
'未知' soldier,
|
'未知' disability,
|
'未知' lowIncomeHouseholds,
|
'未知' lowIncomePeople,
|
'未知' oldPeople,
|
'未知' specialServiceFamily,
|
'未知' keyPersonnel
|
FROM
|
sys_user u
|
left join com_mng_struct_house_user hu on hu.user_id=u.user_id
|
left join com_mng_struct_house h on hu.house_code=h.house_code
|
<if test='exportUserDTO.areaName != null and exportUserDTO.areaName.trim() != ""'>JOIN
|
com_mng_struct_area c ON u.area_id = c.id
|
</if>
|
<if test='exportUserDTO.areaName == null or exportUserDTO.areaName.trim() == ""'>LEFT JOIN
|
com_mng_struct_area c ON u.area_id = c.id
|
</if>
|
<if test='exportUserDTO.areaName != null and exportUserDTO.areaName.trim() != ""'>AND c.`area_name`
|
like concat(#{exportUserDTO.areaName},'%')
|
</if>
|
where u.community_id = #{exportUserDTO.communityId} and u.type=1
|
<if
|
test='exportUserDTO.name != null and exportUserDTO.name.trim() != ""'>and u.`name` like
|
concat(#{exportUserDTO.name},'%')
|
</if>
|
<if test='exportUserDTO.phone != null and exportUserDTO.phone.trim() != ""'>AND u.phone like
|
concat(#{exportUserDTO.phone},'%')
|
</if>
|
group by u.user_id
|
</select>
|
|
<select id="pageNotice" resultType="com.panzhihua.common.model.vos.user.SysUserNoticeVO">
|
select * from
|
sys_user_notice
|
where
|
user_id=#{pageDTO.userId}
|
<if test='pageDTO.type != null and pageDTO.type != 0'>and type=#{pageDTO.type}
|
</if>
|
order by create_at desc
|
|
</select>
|
|
<select id="selectCountHouse" resultType="java.lang.Integer">
|
SELECT
|
COUNT(h.id)
|
FROM
|
com_mng_struct_area a
|
LEFT JOIN com_mng_struct_house h on h.parent_code=a.area_code
|
WHERE
|
a.area_name = #{areaName}
|
</select>
|
|
<update id="passResetUser">
|
update sys_user set password = #{gridMemberDTO.password} where user_id in
|
<foreach item="item" collection="gridMemberDTO.ids" separator="," open="(" close=")" index="">
|
#{item}
|
</foreach>
|
|
</update>
|
|
<update id="deleteUserTest">
|
update sys_user set nick_name=null ,community_id=null,area_id=null where user_id=#{userId}
|
</update>
|
|
<select id="selectCountArea" resultType="java.lang.Integer">
|
select COUNT(a.id) from com_mng_struct_area a where a.area_name=#{areaName}
|
</select>
|
|
<update id="addLcMember">
|
update lc_compare_code_member set local_grid_member_id = #{userId},grid_member_name = #{userName} where id = #{lcMemberId}
|
</update>
|
|
<update id="updateFaceState">
|
update sys_user set face_state=null where user_id=#{userId}
|
</update>
|
|
<select id="selectCommunity" resultType="com.panzhihua.common.model.vos.community.ComActVO">
|
select name,community_id,lng,lat,area_code,contacts_phone from com_act where community_id = #{communityId}
|
</select>
|
|
<delete id="delLcMember">
|
delete from lc_compare_code_member where local_grid_member_id = #{gridMemberId}
|
</delete>
|
|
<select id="getBuilding" resultType="java.util.Map">
|
select id,village_id,act_id from com_mng_building where id = #{buildingId}
|
</select>
|
|
<select id="getLcMemberId" resultType="java.util.Map">
|
select lc_grid_member_id,lc_grid_member_name,lc_bind_user_id from lc_compare_code_member where local_grid_member_id = #{gridMemberId}
|
</select>
|
|
<select id="getGridIsOk" resultType="java.lang.Integer">
|
select count(id) from event_grid_member_relation where grid_member_id = #{userId}
|
</select>
|
|
<update id="judgeCommunityTeam">
|
update com_pb_service_team set is_reg = 1 where phone = #{phone}
|
</update>
|
|
<select id="getCommunityTeamCount" resultType="integer">
|
select count(id) from com_pb_service_team where is_reg = 2 and phone = #{phone}
|
</select>
|
|
<select id="getUserStreetList" resultType="com.panzhihua.common.model.vos.community.IndexUserStreetVo">
|
SELECT
|
street_id,
|
`name`,(
|
SELECT
|
count( user_id )
|
FROM
|
sys_user AS su
|
LEFT JOIN com_act AS ca ON ca.community_id = su.community_id
|
WHERE
|
type = 1 and state = 0 and ca.app_id = #{areaCode}
|
AND ca.street_id = cs.street_id
|
) AS userNum
|
FROM
|
`com_street` AS cs where cs.app_id = #{areaCode}
|
order by userNum desc
|
</select>
|
|
<select id="getUserCommunityList" resultType="com.panzhihua.common.model.vos.community.IndexUserCommunityVo">
|
SELECT
|
ca.community_id,
|
ca.`name`,
|
count( user_id ) as userNum
|
FROM
|
sys_user as su
|
left join com_act as ca on ca.community_id = su.community_id
|
WHERE
|
type = 1 and state = 0
|
AND ca.street_id = #{streetId}
|
group by ca.community_id
|
order by userNum desc
|
</select>
|
|
<select id="getUserCommunityExcelExport" resultType="com.panzhihua.common.model.vos.community.IndexUserStreetExcelExportVo">
|
SELECT
|
cs.`name` AS streetName,
|
ca.`name` AS communityName,
|
(
|
SELECT
|
count( user_id )
|
FROM
|
sys_user AS su1
|
LEFT JOIN com_act AS ca1 ON ca1.community_id = su1.community_id
|
WHERE
|
su1.type = 1
|
AND su1.community_id IS NOT NULL
|
AND ca1.street_id = ca.street_id
|
) AS streetNum,
|
count( user_id ) AS userNum
|
FROM
|
sys_user AS su
|
LEFT JOIN com_act AS ca ON ca.community_id = su.community_id
|
LEFT JOIN com_street AS cs ON cs.street_id = ca.street_id
|
WHERE
|
su.type = 1
|
AND su.community_id IS NOT NULL
|
GROUP BY
|
ca.community_id
|
ORDER BY
|
ca.street_id DESC,
|
userNum DESC
|
</select>
|
|
<select id="countPropertyWorker" resultType="integer">
|
SELECT COUNT(id) FROM com_property
|
WHERE user_id = #{userId} AND community_id = #{communityId}
|
</select>
|
|
<select id="countSocialWorker" resultType="integer">
|
select count(id) from com_act_social_worker where telephone = #{phone} and community_id = #{communityId}
|
</select>
|
|
<select id="countSocialOrg" resultType="Integer">
|
select count(id) from com_act_social_org where user_id = #{userId}
|
</select>
|
|
<select id="countFmsMember" resultType="integer">
|
SELECT COUNT(id) FROM com_fms_team_member
|
WHERE phone = #{phone} AND community_id = #{communityId}
|
</select>
|
|
<select id="selectStreetById" resultType="com.panzhihua.common.model.vos.community.ComStreetVO">
|
SELECT street_id, area_code FROM com_street WHERE street_id = #{streetId}
|
</select>
|
|
<select id="countSocialOrgMember" resultType="integer">
|
SELECT COUNT(id) FROM com_act_social_member
|
WHERE user_id = #{userId}
|
</select>
|
|
<select id="countOrgNum" resultType="integer">
|
SELECT COUNT(id)
|
FROM com_act_social_org
|
WHERE contact_phone = #{phone} AND is_society = 1
|
</select>
|
|
<select id="selectCountDpc" resultType="integer">
|
SELECT COUNT(id)
|
FROM com_act_dpc
|
WHERE phone = #{phone} AND community_id = #{userCommunityId} AND is_del = 0
|
</select>
|
|
<select id="countEasyPhotoMember" resultType="Integer">
|
SELECT COUNT(id) FROM com_act_easy_photo_member
|
WHERE phone = #{phone} AND community_id = #{communityId}
|
</select>
|
|
<select id="selectAcidMemberByPhone" resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO">
|
SELECT id, relation_name FROM com_act_acid_member WHERE phone = #{phone}
|
</select>
|
|
<select id="selectAreaTownCommunity" resultType="com.panzhihua.common.model.vos.community.ComAreaTownCommunityVO">
|
SELECT * FROM com_area_town_community WHERE community = #{relationName}
|
</select>
|
|
<select id="selectAreaCodeByStreetId" resultType="String">
|
select t.district_name from com_mng_struct_area_district t left join com_street t1 on t.district_adcode = t1.area_code where t1.street_id =#{streetId}
|
</select>
|
|
<select id="selectOrgAdmin" resultType="Integer">
|
select count(*) from com_pb_check_unit where admin_phone like concat('%',#{phone},'%')
|
</select>
|
|
<select id="selectOrgAdminId" resultType="Long">
|
select id from com_pb_check_unit where admin_phone like concat('%',#{phone},'%')
|
</select>
|
|
<select id="selectCheckUnitId" resultType="Long">
|
select check_unit_id from com_pb_member where phone = #{phone} limit 1
|
</select>
|
<select id="userAnalysis" resultType="com.panzhihua.common.model.vos.user.UserProportion">
|
select cs.area_code,cs.name as streetName,ac.name as communityName,count(su.user_id) as user,su.community_id as communityId from sys_user as su
|
left join com_act as ac on su.community_id=ac.community_id
|
left join com_street as cs on ac.street_id=cs.street_id
|
where su.community_id<>''
|
and cs.area_code<>''
|
<if test="range != null and range != ''">
|
and su.create_at >= #{range}
|
</if>
|
<if test="appId!=null and appId!=''">
|
and su.app_id = #{appId}
|
</if>
|
<if test="type == 5">
|
<if test="areaCode != null">
|
and ac.area_code=#{areaCode}
|
group by cs.street_id
|
</if>
|
</if>
|
<if test="type == 4">
|
<if test="streetId != null">
|
and cs.street_id=#{streetId}
|
and su.community_id<>11
|
group by su.community_id
|
</if>
|
</if>
|
<if test="type == 1">
|
group by cs.area_code
|
</if>
|
<if test="type == 2">
|
group by cs.street_id
|
</if>
|
<if test="type == 3">
|
and su.community_id<>11
|
group by su.community_id
|
</if>
|
order by user desc
|
limit 10
|
</select>
|
<select id="realUserCount" resultType="com.panzhihua.common.model.vos.user.RealUser">
|
select cs.area_code as areaCode,cs.street_id,ac.name as communityName,su.community_id as communityId,
|
cs.name as StreetName,count(su.user_id) as count from sys_user as su
|
left join com_act as ac on su.community_id=ac.community_id
|
left join com_street as cs on ac.street_id=cs.street_id
|
where su.community_id<>''
|
and cs.area_code<>''
|
and su.id_card<>''
|
<if test="range != null and range != ''">
|
and su.create_at >= #{range}
|
</if>
|
<if test="appId!=null and appId!=''">
|
and su.app_id = #{appId}
|
</if>
|
<if test="type == 5">
|
<if test="areaCode != null">
|
and ac.area_code=#{areaCode}
|
group by cs.street_id
|
</if>
|
</if>
|
<if test="type == 4">
|
and cs.street_id=#{streetId}
|
group by su.community_id
|
</if>
|
<if test="type == 1">
|
group by cs.area_code
|
</if>
|
<if test="type == 2">
|
group by cs.street_id
|
</if>
|
<if test="type == 3">
|
group by su.community_id
|
</if>
|
order by count desc
|
limit 11
|
</select>
|
<select id="streetUserCount" resultType="Integer">
|
select count(user_id) from sys_user as su
|
left join com_act as ac on su.community_id=ac.community_id
|
left join com_street as cs on ac.street_id=cs.street_id
|
where su.community_id<>''
|
and cs.area_code<>''
|
and cs.street_id=#{id}
|
<if test="areaCode != null">
|
and ac.area_code=#{areaCode}
|
</if>
|
</select>
|
<select id="dataKanBanStreet" resultType="com.panzhihua.common.model.vos.IndexDataKanbanVO">
|
SELECT
|
COUNT(user_id)allUser,
|
COUNT(case WHEN DATE_FORMAT(t.create_at,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )addUser,
|
COUNT(case WHEN DATE_FORMAT(last_login_time,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )activeDayUser,
|
(SELECT count(user_id) FROM sys_user t left join com_act t1 on t.community_id = t1.community_id WHERE t.type = 1 AND last_login_time > date_sub(SYSDATE(), INTERVAL 7 DAY))activeWeekUser
|
FROM
|
sys_user t LEFT JOIN com_act t1 on t.community_id = t1.community_id
|
where t.type=1 and t.community_id is not null
|
<if test="streetId != null">
|
and t1.street_id=#{streetId}
|
</if>
|
<if test="areaCode != null">
|
and t1.area_code=#{areaCode}
|
</if>
|
<if test="range != null and range != ''">
|
and t.create_at >= #{range}
|
and t.community_id<>11
|
</if>
|
</select>
|
<select id="getDailyAddAndActive" resultType="java.util.Map">
|
select COUNT(case WHEN DATE_FORMAT(su.last_login_time,'%m-%d-%Y')=DATE_FORMAT(#{date},'%m-%d-%Y') then user_id else null end) as activeUser,
|
count(case WHEN DATE_FORMAT(su.create_at,'%m-%d-%Y')=DATE_FORMAT(#{date},'%m-%d-%Y') then user_id else null end ) as addUser
|
from sys_user as su
|
left join com_act as ac on su.community_id=ac.community_id
|
left join com_street as cs on ac.street_id=cs.street_id
|
where su.community_id<>''
|
and cs.area_code<>''
|
and su.type = 1
|
<if test="appId != null and appId != """>
|
and su.app_id = #{appId}
|
</if>
|
<if test="id != null">
|
and cs.street_id=#{id}
|
</if>
|
<if test="areaCode != null">
|
and cs.area_code=#{areaCode}
|
</if>
|
</select>
|
|
<select id="getDailyAdd" resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
|
SELECT DATE_FORMAT( su.create_at, '%Y-%m-%d' ) as specificDate ,count(su.user_id) as total FROM
|
sys_user AS su
|
LEFT JOIN com_act AS ac ON su.community_id = ac.community_id
|
LEFT JOIN com_street AS cs ON ac.street_id = cs.street_id
|
where su.community_id<>''
|
and cs.area_code<>''
|
and su.type = 1
|
<if test="appId != null and appId != """>
|
and su.app_id = #{appId}
|
</if>
|
<if test="id != null">
|
and cs.street_id=#{id}
|
</if>
|
<if test="areaCode != null">
|
and cs.area_code=#{areaCode}
|
</if>
|
AND su.create_at > #{createAt} GROUP BY specificDate
|
</select>
|
<select id="getActive" resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
|
SELECT DATE_FORMAT( su.last_login_time, '%Y-%m-%d' ) as specificDate ,count(su.user_id) as total FROM
|
sys_user AS su
|
LEFT JOIN com_act AS ac ON su.community_id = ac.community_id
|
LEFT JOIN com_street AS cs ON ac.street_id = cs.street_id
|
where su.community_id<>''
|
and cs.area_code<>''
|
and su.type = 1
|
<if test="appId != null and appId != """>
|
and su.app_id = #{appId}
|
</if>
|
<if test="id != null">
|
and cs.street_id=#{id}
|
</if>
|
<if test="areaCode != null">
|
and cs.area_code=#{areaCode}
|
</if>
|
AND su.last_login_time > #{lastLoginTime} GROUP BY specificDate
|
</select>
|
|
<select id="selectStreetByAreaCode" resultType="com.panzhihua.common.model.vos.user.StreetVOS">
|
select street_id as id,name as name from com_street where area_code=#{code} and app_id ='wx118de8a734d269f0'
|
</select>
|
<select id="selectStreetsByAreaCode" resultType="com.panzhihua.common.model.vos.user.StreetVO">
|
select street_id as id,name as name from com_street where area_code=#{code}
|
</select>
|
<select id="selectComActAcidCheckRecordById"
|
resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidCheckRecordVO">
|
select * from com_act_acid_check_record where id = #{id}
|
</select>
|
<select id="selectComActAcidRecord" resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidRecordVO">
|
select * from com_act_acid_record where id = #{id}
|
</select>
|
<select id="selectComActAcidMember" resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO">
|
select * from com_act_acid_member where id = #{id}
|
</select>
|
<select id="getMonthUsers" resultType="java.lang.Integer">
|
SELECT count(user_id)
|
FROM
|
sys_user t LEFT JOIN com_act t1 on t.community_id = t1.community_id
|
where t.type=1 and t.community_id is not null
|
and t.community_id<>11
|
<if test="streetId != null">
|
and t1.street_id=#{streetId}
|
</if>
|
<if test="areaCode != null">
|
and t1.area_code=#{areaCode}
|
</if>
|
<if test="range != null and range != ''">
|
and t.create_at >= #{range}
|
</if>
|
<if test="appId!=null and appId!=''">
|
and t.app_id = #{appId}
|
</if>
|
</select>
|
<select id="selectCommunityByStreetId" resultType="com.panzhihua.common.model.vos.user.CommunityVO">
|
select community_id as id,name from com_act where street_id =#{id} and app_id = 'wx118de8a734d269f0'
|
<if test="type == 1">
|
and name like concat('%','社区')
|
</if>
|
<if test="type == 2">
|
and name like concat('%','村')
|
</if>
|
</select>
|
|
<select id="selectIdsByAccount" resultType="java.lang.Integer">
|
select user_id from sys_user where account in
|
<foreach collection="array" item="name" separator="," open="(" close=")" >
|
#{name}
|
</foreach>
|
</select>
|
<select id="selectCommunityByStreetName" resultType="com.panzhihua.common.model.vos.user.CommunityVO">
|
select ca.community_id as id,ca.name as name
|
from sys_user as su
|
left join com_street as cs on cs.name=su.name
|
left join com_act as ca on ca.street_id=cs.street_id
|
where su.account=#{name}
|
</select>
|
<select id="selectStreetByName" resultType="com.panzhihua.common.model.vos.user.StreetVOS">
|
select cs.street_id as id,cs.name as name
|
from sys_user as su
|
left join com_street as cs on su.name=cs.name
|
where su.account=#{name}
|
limit 1
|
</select>
|
<select id="isExpert" resultType="com.panzhihua.common.model.vos.sanshuo.ComSanshuoExpertVO">
|
select * from com_sanshuo_expert where phone=#{phone}
|
</select>
|
|
<select id="isIndustryCenterAccount" resultType="Integer">
|
select count(id) from com_sanshuo_industry_center where account=#{account}
|
</select>
|
|
<select id="isExpertAccount" resultType="Integer">
|
select count(id) from com_sanshuo_expert where account=#{account}
|
</select>
|
|
<select id="isDpcMember" resultType="Integer">
|
select count(id) from com_act_dpc where name =#{name} and phone=#{phone}
|
</select>
|
<select id="isPropertyAccount" resultType="java.lang.Long">
|
select id from com_property where phone=#{phone}
|
</select>
|
<select id="getCommunityAppId" resultType="java.lang.String">
|
select app_id from com_act where community_id=#{communityId}
|
</select>
|
</mapper>
|