cgf
2025-09-11 03dcc05067d46487eac0c65b9fdeb6436c6e7311
java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
@@ -1,30 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="communityServiceDaoImpl">
    <!-- 保存小区信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessCommunityInfo" parameterType="Map">
        insert into business_community(community_id,b_id,name,address,city_code,
        nearby_landmarks,map_x,map_y,month,state,operate,community_area,tel)
        values(#{communityId},#{bId},#{name},#{address},#{cityCode},
        #{nearbyLandmarks},#{mapX},#{mapY},#{month},#{state},#{operate},#{communityArea},#{tel})
        insert into business_community(community_id, b_id, name, address, city_code,
                                       nearby_landmarks, map_x, map_y, month, state, operate, community_area, tel)
        values (#{communityId}, #{bId}, #{name}, #{address}, #{cityCode},
                #{nearbyLandmarks}, #{mapX}, #{mapY}, #{month}, #{state}, #{operate}, #{communityArea}, #{tel})
    </insert>
    <!-- 保存小区属性信息  add by wuxw 2018-07-03 -->
    <insert id="saveCommunityAttr" parameterType="Map">
        insert into s_community_attr(b_id, attr_id, community_id, spec_cd, value, month, status_cd)
        values (#{bId}, #{attrId}, #{communityId}, #{specCd}, #{value}, #{month}, #{statusCd})
    </insert>
    <!-- 保存小区属性信息  add by wuxw 2018-07-03 -->
    <insert id="saveBusinessCommunityAttr" parameterType="Map">
        insert into business_community_attr(b_id,attr_id,community_id,spec_cd,value,month,operate)
        values(#{bId},#{attrId},#{communityId},#{specCd},#{value},#{month},#{operate})
        insert into business_community_attr(b_id, attr_id, community_id, spec_cd, value, month, operate)
        values (#{bId}, #{attrId}, #{communityId}, #{specCd}, #{value}, #{month}, #{operate})
    </insert>
    <!-- 保存小区照片信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessCommunityPhoto" parameterType="Map">
        insert into
        business_community_photo(community_photo_id,b_id,community_id,community_photo_type_cd,photo,month,operate)
        values(#{communityPhotoId},#{bId},#{communityId},#{communityPhotoTypeCd},#{photo},#{month},#{operate})
        insert into business_community_photo(community_photo_id, b_id, community_id, community_photo_type_cd, photo,
                                             month, operate)
        values (#{communityPhotoId}, #{bId}, #{communityId}, #{communityPhotoTypeCd}, #{photo}, #{month}, #{operate})
    </insert>
    <!-- 查询小区信息(Business) add by wuxw 2018-07-03 -->
@@ -78,9 +81,10 @@
    <!-- 保存小区信息至 instance表中 add by wuxw 2018-07-03 -->
    <insert id="saveCommunityInfoInstance" parameterType="Map">
        insert into
        s_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,status_cd,state,community_area,tel)
        values(#{community_id},#{b_id},#{name},#{address},#{city_code},#{nearby_landmarks},#{map_x},#{map_y},'0',#{state},#{communityArea},#{tel})
        insert into s_community(community_id, b_id, name, address, city_code, nearby_landmarks, map_x, map_y, status_cd,
                                state, community_area, tel, take_time)
        values (#{community_id}, #{b_id}, #{name}, #{address}, #{city_code}, #{nearby_landmarks}, #{map_x}, #{map_y},
                '0', #{state}, #{communityArea}, #{tel}, #{takeTime})
    </insert>
    <!-- 保存小区属性信息到 instance add by wuxw 2018-07-03 -->
@@ -107,7 +111,7 @@
    <!-- 查询小区信息 add by wuxw 2018-07-03 -->
    <select id="getCommunityInfo" parameterType="Map" resultType="Map">
        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd,s.state
        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd,s.state, s.take_time
        from s_community s
        where 1=1
        <if test="statusCd != null and statusCd != ''">
@@ -130,8 +134,8 @@
        s.list_show listShow
        from s_community_attr sa
        left join attr_spec s on sa.spec_cd = s.spec_cd and s.status_cd = '0' and s.table_name =
        'building_community_attr'
        left join attr_value v on sa.`value` = v.`value` and sa.spec_cd = v.spec_cd and v.status_cd = '0'
        'building_community_attr' and sa.spec_cd = s.spec_cd
        left join attr_value v on sa.`value` = v.`value` and s.spec_id = v.spec_id and v.status_cd = '0'
        where
        1=1
        <if test="statusCd != null and statusCd != ''">
@@ -142,6 +146,12 @@
        </if>
        <if test="communityId != null and communityId !=''">
            and sa.community_id = #{communityId}
        </if>
        <if test="specCd != null and specCd !=''">
            and sa.spec_cd = #{specCd}
        </if>
        <if test="value != null and value !=''">
            and sa.value = #{value}
        </if>
        <if test="communityIds != null ">
            and sa.community_id in
@@ -199,6 +209,9 @@
        </if>
        <if test="tel != null and tel != ''">
            ,s.tel = #{tel}
        </if>
        <if test="takeTime !=null and takeTime != ''">
            , t.take_time= #{takeTime}
        </if>
        <if test="communityArea != null and communityArea != ''">
            ,s.community_area = #{communityArea}
@@ -260,19 +273,20 @@
        </if>
    </update>
    <!--小区成员加入 add by wuxw 2018-10-27 saveBusinessCommunityMember-->
    <insert id="saveBusinessCommunityMember" parameterType="Map">
        insert into
        business_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,month,operate,audit_status_cd)
        values(#{communityMemberId},#{bId},#{communityId},#{memberId},#{memberTypeCd},#{month},#{operate},#{auditStatusCd})
        insert into business_community_member(community_member_id, b_id, community_id, member_id, member_type_cd, month,
                                              operate, audit_status_cd, start_time, end_time)
        values (#{communityMemberId}, #{bId}, #{communityId}, #{memberId}, #{memberTypeCd}, #{month}, #{operate},
                #{auditStatusCd}, #{startTime}, #{endTime})
    </insert>
    <!-- 小区成员加入 instance表中 add by wuxw 2018-10-27 -->
    <insert id="saveCommunityMemberInstance" parameterType="Map">
        insert into
        s_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,status_cd,audit_status_cd)
        select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,'0',ms.audit_status_cd
        s_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,status_cd,audit_status_cd,start_time,end_time)
        select
        ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,'0',ms.audit_status_cd,ms.start_time,ms.end_time
        from business_community_member ms where
        ms.operate = 'ADD' and ms.b_id=#{bId}
        <if test="communityId != null and communityId != ''">
@@ -283,7 +297,7 @@
    <!-- 查询小区成员 add by wuxw 2018-10-27 getBusinessCommunityMember-->
    <select id="getBusinessCommunityMember" parameterType="Map" resultType="Map">
        select
        ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.operate,ms.audit_status_cd
        ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.operate,ms.audit_status_cd,ms.start_time,ms.end_time
        from business_community_member ms where 1 = 1
        <if test="operate != null and operate != ''">
            and ms.operate = #{operate}
@@ -296,7 +310,6 @@
        </if>
    </select>
    <!-- 查询小区成员  add by wuxw 2018-07-03 -->
    <select id="getCommunityMember" parameterType="Map" resultType="Map">
        select ms.community_member_id ,
@@ -304,6 +317,8 @@
        ms.community_member_id communityMemberId ,ms.b_id bId,ms.community_id communityId,ms.member_id
        memberId,ms.member_type_cd memberTypeCd,ms.status_cd statusCd,
        ms.audit_status_cd auditStatusCd,
        ms.start_time,ms.end_time,ms.start_time startTime,ms.end_time endTime,
        ms.create_time createTime,
        (CASE
        WHEN ms.audit_status_cd='1000'
        THEN '待审核'
@@ -317,8 +332,7 @@
        </if>
        from s_community_member ms
        <if test="needCommunityInfo == true">
            ,s_community sc,
            s_community_member msc
            ,s_community sc
        </if>
        where 1=1
        <if test="needCommunityInfo == true">
@@ -363,9 +377,9 @@
        <if test="communityName != null and communityName != '' and needCommunityInfo == true">
            and sc.name like concat('%',#{communityName},'%')
        </if>
        <if test="needCommunityInfo == true">
        <!--<if test="needCommunityInfo == true">
            group by ms.community_id
        </if>
        </if>-->
        order by ms.create_time desc
        <if test="page != -1 and page != null">
            limit #{page},#{row}
@@ -381,6 +395,12 @@
        <if test="auditStatusCd !=null and auditStatusCd !=''">
            ,ms.audit_status_cd = #{auditStatusCd}
        </if>
        <if test="startTime !=null ">
            ,ms.start_time = #{startTime}
        </if>
        <if test="endTime !=null ">
            ,ms.end_time = #{endTime}
        </if>
        where 1=1
        <if test="bId != null and bId !=''">
            and ms.b_id = #{bId}
@@ -390,14 +410,12 @@
        </if>
    </update>
    <!-- 查询小区成员  add by wuxw 2018-07-03 -->
    <select id="getCommunityMemberCount" parameterType="Map" resultType="Map">
        select ms.community_id,count(1) count
        from s_community_member ms
        <if test="needCommunityInfo == true">
            ,s_community sc,
            s_community_member msc
            ,s_community sc
        </if>
        where 1=1
        <if test="needCommunityInfo == true">
@@ -408,7 +426,6 @@
        <if test="statusCd != null and statusCd != ''">
            and ms.status_cd = #{statusCd}
        </if>
        <if test="bId != null and bId !=''">
            and ms.b_id = #{bId}
        </if>
@@ -423,22 +440,18 @@
        <if test="memberId != null and memberId != '' and needCommunityInfo == false">
            and ms.member_id = #{memberId}
        </if>
        <if test="subMemberId != null and subMemberId != ''">
            and ms.member_id = #{subMemberId}
        </if>
        <if test="noAuditEnterCommunity == true">
            and ms.member_type_cd not in ('390001200003','390001200005','390001200000')
        </if>
        <if test="memberTypeCd != null and memberTypeCd != ''">
            and ms.member_type_cd = #{memberTypeCd}
        </if>
        <if test="auditStatusCd != null and auditStatusCd != ''">
            and ms.audit_status_cd = #{auditStatusCd}
        </if>
        <if test="auditStatusCds != null and auditStatusCds != null">
            and ms.audit_status_cd in
            <foreach collection="auditStatusCds" item="item" open="(" close=")" separator=",">
@@ -451,10 +464,9 @@
        <if test="communityName != null and communityName != '' and needCommunityInfo == true">
            and sc.name like concat('%',#{communityName},'%')
        </if>
        <if test="needCommunityInfo == true">
        <!--<if test="needCommunityInfo == true">
            group by ms.community_id
        </if>
        </if>-->
    </select>
    <!-- 查询小区信息 add by wuxw 2018-07-03 -->
@@ -462,23 +474,16 @@
        select t.address,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,
        t.city_code,t.city_code cityCode,t.name,t.status_cd,t.status_cd statusCd,t.tel,
        t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.map_y,t.map_y mapY,
        t.map_x,t.map_x mapX,t.state,(CASE
        WHEN t.state='1000'
        THEN '待审核'
        WHEN t.state = '1100'
        THEN '审核完成'
        ELSE
        '审核拒绝'
        END) stateName,ca.area_code areaCode,ca.area_name areaName,
        t.map_x,t.map_x mapX,t.state,td.name stateName,ca.area_code areaCode,ca.area_name areaName,
        ca.parent_area_code parentAreaCode,ca.parent_area_name parentAreaName,
        t.community_area communityArea
        from s_community t,city_area ca
        <if test="memberId !=null and memberId !=''">
            ,s_community_member cm
        </if>
        t.community_area communityArea,t.pay_fee_month,t.pay_fee_month payFeeMonth,t.fee_price,t.fee_price
        feePrice,t.qr_code qrCode,t.create_time createTime,s.name storeName,s.store_id storeId, t.take_time, t.take_time takeTime
        from s_community t
        left join city_area ca on t.city_code = ca.area_code and ca.status_cd = '0'
        left join s_community_member cm on t.community_id = cm.community_id and cm.member_type_cd = '390001200002' and cm.status_cd = '0'
        left join s_store s on cm.member_id = s.store_id and s.status_cd = '0'
        left join t_dict td on t.state = td.status_cd and td.table_name = 's_community' and td.table_columns = 'state'
        where t.status_cd = '0'
        and t.city_code = ca.area_code
        and ca.status_cd = '0'
        <if test="address !=null and address != ''">
            and t.address= #{address}
        </if>
@@ -491,6 +496,9 @@
        <if test="name !=null and name != ''">
            and t.name like concat('%',#{name},'%')
        </if>
        <!--<if test="nameLike !=null and nameLike != ''">
            and t.name like concat('%',#{nameLike},'%')
        </if>-->
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
@@ -529,25 +537,22 @@
                #{item}
            </foreach>
        </if>
        group by t.community_id
        order by t.create_time ASC
        <!--group by t.community_id-->
        order by t.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <!-- 查询小区数量 add by wuxw 2018-07-03 -->
    <select id="queryCommunitysCount" parameterType="Map" resultType="Map">
        select count(DISTINCT(t.community_id)) count
        from s_community t,city_area ca
        <if test="memberId !=null and memberId !=''">
            ,s_community_member cm
        </if>
        where 1 =1
        and t.city_code = ca.area_code
        and ca.status_cd = '0'
        select count(1) count
        from s_community t
        left join city_area ca on t.city_code = ca.area_code and ca.status_cd = '0'
        left join s_community_member cm on t.community_id = cm.community_id and cm.member_type_cd = '390001200002' and cm.status_cd = '0'
        left join s_store s on cm.member_id = s.store_id and s.status_cd = '0'
        left join t_dict td on t.state = td.status_cd and td.table_name = 's_community' and td.table_columns = 'state'
        where t.status_cd = '0'
        <if test="address !=null and address != ''">
            and t.address= #{address}
        </if>
@@ -598,9 +603,8 @@
                #{item}
            </foreach>
        </if>
    </select>
    <!-- 查询商户小区 -->
    <select id="getStoreCommunitys" parameterType="Map" resultType="Map">
        SELECT
@@ -617,10 +621,14 @@
        scm.`member_type_cd` memberTypeCd,
        scm.audit_status_cd auditStatusCd,
        scm.`status_cd` statusCd,
        scm.`start_time` startTime,
        scm.`end_time` endTime,
        ca.area_name areaName,
        ca.parent_area_name cityName,
        ca1.parent_area_name provName,
        sc.community_area communityArea
        sc.community_area communityArea,
        sc.qr_code qrCode,
        sc.take_time takeTime
        FROM
        s_community sc,
        s_community_member scm,
@@ -640,6 +648,11 @@
        <if test="auditStatusCd !=null and auditStatusCd !=''">
            and scm.audit_status_cd = #{auditStatusCd}
        </if>
        group by sc.community_id
        <if test="communityId != null and communityId != ''">
            and sc.community_id = #{communityId}
        </if>
    </select>
    <select id="getCommunitys" resultType="com.java110.dto.community.CommunityDto">
        select `name` from s_community where status_cd = 0
    </select>
</mapper>