wuxw
2022-07-19 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54
java110-db/src/main/resources/mapper/store/StoreServiceDaoImplMapper.xml
old mode 100644 new mode 100755
@@ -3,31 +3,36 @@
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="storeServiceDaoImpl">
    <!-- 保存商户信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreInfo" parameterType="Map">
        insert into business_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,month,operate)
        values(#{storeId},#{bId},#{userId},#{name},#{address},#{tel},#{storeTypeCd},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate})
        insert into business_store(store_id, b_id, user_id, name, address, tel, store_type_cd, nearby_landmarks, map_x,
                                   map_y, month, operate)
        values (#{storeId}, #{bId}, #{userId}, #{name}, #{address}, #{tel}, #{storeTypeCd}, #{nearByLandmarks}, #{mapX},
                #{mapY}, #{month}, #{operate})
    </insert>
    <!-- 保存商户属性信息  add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreAttr" parameterType="Map">
        insert into business_store_attr(b_id,attr_id,store_id,spec_cd,value,month,operate)
        values(#{bId},#{attrId},#{storeId},#{specCd},#{value},#{month},#{operate})
        insert into business_store_attr(b_id, attr_id, store_id, spec_cd, value, month, operate)
        values (#{bId}, #{attrId}, #{storeId}, #{specCd}, #{value}, #{month}, #{operate})
    </insert>
    <!-- 保存商户照片信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStorePhoto" parameterType="Map">
        insert into business_store_photo(store_photo_id,b_id,store_id,store_photo_type_cd,photo,month,operate)
        values(#{storePhotoId},#{bId},#{storeId},#{storePhotoTypeCd},#{photo},#{month},#{operate})
        insert into business_store_photo(store_photo_id, b_id, store_id, store_photo_type_cd, photo, month, operate)
        values (#{storePhotoId}, #{bId}, #{storeId}, #{storePhotoTypeCd}, #{photo}, #{month}, #{operate})
    </insert>
    <!-- 保存商户证件信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreCerdentials" parameterType="Map">
        insert into business_store_cerdentials(store_cerdentials_id,b_id,store_id,credentials_cd,value,validity_period,positive_photo,negative_photo,month,operate)
        values(#{storeCerdentialsId},#{bId},#{storeId},#{credentialsCd},#{value},#{validityPeriod},#{positivePhoto},#{negativePhoto},#{month},#{operate})
        insert into business_store_cerdentials(store_cerdentials_id, b_id, store_id, credentials_cd, value,
                                               validity_period, positive_photo, negative_photo, month, operate)
        values (#{storeCerdentialsId}, #{bId}, #{storeId}, #{credentialsCd}, #{value}, #{validityPeriod},
                #{positivePhoto}, #{negativePhoto}, #{month}, #{operate})
    </insert>
    <!-- 查询商户信息(Business) add by wuxw 2018-07-03 -->
    <select id="getBusinessStoreInfo" parameterType="Map" resultType="Map">
        select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.operate
        select
        s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.operate
        from business_store s where 1 = 1
        <if test="operate != null and operate != ''">
            and s.operate = #{operate}
@@ -76,7 +81,8 @@
    <!-- 查询商户 证件信息 add by wuxw 2018-07-03 -->
    <select id="getBusinessStoreCerdentials" parameterType="Map" resultType="Map">
        select sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.operate
        select
        sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.operate
        from business_store_cerdentials sc where 1 = 1
        <if test="bId != null and bId !=''">
            and sc.b_id = #{bId}
@@ -91,47 +97,71 @@
    <!-- 保存商户信息至 instance表中 add by wuxw 2018-07-03 -->
    <insert id="saveStoreInfoInstance" parameterType="Map">
        insert into s_store(store_id,b_id,user_id,name,address,tel,store_type_cd,nearby_landmarks,map_x,map_y,status_cd)
        select s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,'0'
        from business_store s where
        s.operate = 'ADD' and s.b_id=#{bId}
        insert into s_store(store_id, b_id, user_id, name, address, tel, store_type_cd, nearby_landmarks, map_x, map_y,
                            status_cd)
        select s.store_id,
               s.b_id,
               s.user_id,
               s.name,
               s.address,
               s.tel,
               s.store_type_cd,
               s.nearby_landmarks,
               s.map_x,
               s.map_y,
               '0'
        from business_store s
        where s.operate = 'ADD'
          and s.b_id = #{bId}
    </insert>
    <!-- 保存商户属性信息到 instance add by wuxw 2018-07-03 -->
    <insert id="saveStoreAttrsInstance" parameterType="Map">
        insert into s_store_attr(b_id,attr_id,store_id,spec_cd,value,status_cd)
        select sa.b_id,sa.attr_id,sa.store_id,sa.spec_cd,sa.value,'0'
        insert into s_store_attr(b_id, attr_id, store_id, spec_cd, value, status_cd)
        select sa.b_id, sa.attr_id, sa.store_id, sa.spec_cd, sa.value, '0'
        from business_store_attr sa
        where sa.operate = 'ADD' and sa.b_id=#{bId}
        where sa.operate = 'ADD'
          and sa.b_id = #{bId}
    </insert>
    <!-- 保存 商户照片信息 instance add by wuxw 2018-07-03 -->
    <insert id="saveStorePhotoInstance" parameterType="Map">
        insert into s_store_photo(store_photo_id,b_id,store_id,store_photo_type_cd,photo,status_cd)
        select sp.store_photo_id,sp.b_id,sp.store_id,sp.store_photo_type_cd,sp.photo,'0'
        insert into s_store_photo(store_photo_id, b_id, store_id, store_photo_type_cd, photo, status_cd)
        select sp.store_photo_id, sp.b_id, sp.store_id, sp.store_photo_type_cd, sp.photo, '0'
        from business_store_photo sp
        where  sp.operate = 'ADD' and sp.b_id=#{bId}
        where sp.operate = 'ADD'
          and sp.b_id = #{bId}
    </insert>
    <!-- 保存 商户证件信息 instance add by wuxw 2018-07-03 -->
    <insert id="saveStoreCerdentialsInstance" parameterType="Map">
        insert into s_store_cerdentials(store_cerdentials_id,b_id,store_id,credentials_cd,value,validity_period,positive_photo,negative_photo,status_cd)
        select sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,'0'
        insert into s_store_cerdentials(store_cerdentials_id, b_id, store_id, credentials_cd, value, validity_period,
                                        positive_photo, negative_photo, status_cd)
        select sc.store_cerdentials_id,
               sc.b_id,
               sc.store_id,
               sc.credentials_cd,
               sc.value,
               sc.validity_period,
               sc.positive_photo,
               sc.negative_photo,
               '0'
        from business_store_cerdentials sc
        where sc.operate = 'ADD' and sc.b_id=#{bId}
        where sc.operate = 'ADD'
          and sc.b_id = #{bId}
    </insert>
    <!-- 查询商户信息 add by wuxw 2018-07-03 -->
    <select id="getStoreInfo" parameterType="Map" resultType="Map">
        select s.store_id,s.store_id storeId,
            s.b_id,
            s.user_id,
            s.name,
            s.address,
            s.tel,
            s.store_type_cd,
            s.nearby_landmarks,
            s.map_x,s.map_y,
            s.status_cd
        s.b_id,
        s.user_id,
        s.name,
        s.address,
        s.tel,
        s.store_type_cd,
        s.nearby_landmarks,
        s.map_x,s.map_y,
        s.status_cd
        from s_store s
        where 1=1
        <if test="statusCd != null and statusCd != ''">
@@ -148,8 +178,11 @@
    <!-- 查询商户属性信息 add by wuxw 2018-07-03 -->
    <select id="getStoreAttrs" parameterType="Map" resultType="Map">
        select sa.b_id,sa.attr_id,sa.store_id,sa.spec_cd,sa.value,sa.status_cd
        from s_store_attr sa
        select
        sa.b_id,sa.attr_id,sa.attr_id attrId,
        sa.store_id, sa.store_id storeId,sa.spec_cd,sa.spec_cd specCd,sa.value,sa.status_cd,
        c.name
        from s_store_attr sa inner join spec c on sa.spec_cd = c.spec_cd
        where
        1=1
        <if test="statusCd != null and statusCd != ''">
@@ -160,6 +193,16 @@
        </if>
        <if test="storeId != null and storeId !=''">
            and sa.store_id = #{storeId}
        </if>
        <if test="storeIds != null">
            and sa.store_id in
            <foreach collection="storeIds" open="(" close=")"
                     separator="," item="item">
                #{item}
            </foreach>
        </if>
        <if test="specCd != null and specCd !=''">
            and sa.spec_cd = #{specCd}
        </if>
        <if test="attrId != null and attrId != ''">
            and sa.attr_id = #{attrId}
@@ -184,7 +227,8 @@
    <!-- 查询商户证件信息 add by wuxw 2018-07-03 -->
    <select id="getStoreCerdentials" parameterType="Map" resultType="Map">
        select sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.status_cd
        select
        sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.status_cd
        from s_store_cerdentials sc
        where 1=1
        <if test="statusCd != null and statusCd != ''">
@@ -321,16 +365,17 @@
    <!--商户成员加入 add by wuxw 2018-10-27 saveBusinessMemberStore-->
    <insert id="saveBusinessMemberStore" parameterType="Map">
        insert into business_member_store(member_store_id,b_id,store_id,member_id,month,operate)
        values(#{memberStoreId},#{bId},#{storeId},#{memberId},#{month},#{operate})
        insert into business_member_store(member_store_id, b_id, store_id, member_id, month, operate)
        values (#{memberStoreId}, #{bId}, #{storeId}, #{memberId}, #{month}, #{operate})
    </insert>
    <!-- 商户成员加入 instance表中 add by wuxw 2018-10-27 -->
    <insert id="saveMemberStoreInstance" parameterType="Map">
        insert into s_member_store(member_store_id,b_id,store_id,member_id,status_cd)
        select ms.member_store_id,ms.b_id,ms.store_id,ms.member_id,'0'
        from business_member_store ms where
        ms.operate = 'ADD' and ms.b_id=#{bId}
        insert into s_member_store(member_store_id, b_id, store_id, member_id, status_cd)
        select ms.member_store_id, ms.b_id, ms.store_id, ms.member_id, '0'
        from business_member_store ms
        where ms.operate = 'ADD'
          and ms.b_id = #{bId}
    </insert>
    <!-- 查询商户成员 add by wuxw 2018-10-27 getBusinessMemberStore-->
@@ -384,8 +429,8 @@
    <!-- 保存物业用户信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreUser" parameterType="Map">
        insert into business_store_user(store_user_id,b_id,store_id,user_id,rel_cd,month,operate)
        values(#{storeUserId},#{bId},#{storeId},#{userId},#{relCd},#{month},#{operate})
        insert into business_store_user(store_user_id, b_id, store_id, user_id, rel_cd, month, operate)
        values (#{storeUserId}, #{bId}, #{storeId}, #{userId}, #{relCd}, #{month}, #{operate})
    </insert>
    <!-- 查询物业 用户信息 add by wuxw 2018-07-03 -->
@@ -405,10 +450,11 @@
    <!-- 保存 商户用户信息 instance add by wuxw 2018-07-03 -->
    <insert id="saveStoreUserInstance" parameterType="Map">
        insert into s_store_user(store_user_id,b_id,store_id,user_id,rel_cd,status_cd)
        select sc.store_user_id,sc.b_id,sc.store_id,sc.user_id,sc.rel_cd,'0'
        insert into s_store_user(store_user_id, b_id, store_id, user_id, rel_cd, status_cd)
        select sc.store_user_id, sc.b_id, sc.store_id, sc.user_id, sc.rel_cd, '0'
        from business_store_user sc
        where sc.operate = 'ADD' and sc.b_id=#{bId}
        where sc.operate = 'ADD'
          and sc.b_id = #{bId}
    </insert>
    <!-- 查询商户证件信息 add by wuxw 2018-07-03 -->
@@ -453,13 +499,23 @@
    <!-- 查询商户 -->
    <select id="getStores" parameterType="Map" resultType="Map">
        select s.store_id,s.b_id,s.user_id,s.name,s.name storeName,s.address,s.tel,s.store_id storeId,
        s.store_type_cd,s.store_type_cd storeTypeCd, s.nearby_landmarks,s.map_x,s.map_y,s.status_cd,
        select
        s.store_id,
        s.b_id,
        s.user_id,
        s.name,s.name storeName,
        s.address,
        s.tel,
        s.store_id storeId,
        s.store_type_cd,s.store_type_cd storeTypeCd,
        s.nearby_landmarks,s.nearby_landmarks nearByLandmarks,
        s.map_x,s.map_x mapX,
        s.map_y,s.map_y mapY,
        s.status_cd,
        st.name storeTypeName
        from s_store s,store_type st
        where s.status_cd = '0'
        and s.store_type_cd = st.store_type_cd
        <if test="userId != null and userId != ''">
            and s.user_id = #{userId}
        </if>
@@ -482,7 +538,7 @@
            and s.store_id = #{storeId}
        </if>
        <if test="storeIds !=null">
            and t.store_id in
            and s.store_id in
            <foreach collection="storeIds" open="(" close=")"
                     separator="," item="item">
                #{item}
@@ -494,4 +550,137 @@
        </if>
    </select>
    <!-- 查询商户 -->
    <select id="getStoreCount" parameterType="Map" resultType="Map">
        select count(1) count
        from s_store s,store_type st
        where s.status_cd = '0'
        and s.store_type_cd = st.store_type_cd
        <if test="userId != null and userId != ''">
            and s.user_id = #{userId}
        </if>
        <if test="name != null and name !=''">
            and s.name like concat('%',#{name},'%')
        </if>
        <if test="address != null and address != ''">
            and s.address like concat('%',#{address},'%')
        </if>
        <if test="tel != null and tel != ''">
            and s.tel = #{tel}
        </if>
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and s.store_type_cd = #{storeTypeCd}
        </if>
        <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
            and s.nearby_landmarks = #{nearbyLandmarks}
        </if>
        <if test="storeId != null and storeId !=''">
            and s.store_id = #{storeId}
        </if>
        <if test="storeIds !=null">
            and s.store_id in
            <foreach collection="storeIds" open="(" close=")"
                     separator="," item="item">
                #{item}
            </foreach>
        </if>
    </select>
    <!--查询员工和商户信息-->
    <select id="getStoreUserInfo" parameterType="Map" resultType="Map">
        select s.store_id,s.store_id storeId,s.b_id,s.user_id,s.user_id
        userId,s.name,s.address,s.tel,s.store_type_cd,s.store_type_cd storeTypeCd,
        s.nearby_landmarks,s.map_x,s.map_y,s.create_time,su.store_user_id,su.rel_cd,s.state
        from s_store s
        left join s_store_user su on s.store_id=su.store_id and su.status_cd = '0'
        where
        s.status_cd = '0'
        <if test="userId != null and userId != ''">
            and su.user_id = #{userId}
        </if>
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and s.store_type_cd = #{storeTypeCd}
        </if>
        <if test="storeId != null and storeId != ''">
            and s.store_id = #{storeId}
        </if>
    </select>
    <select id="getStoreStaffs" parameterType="Map" resultType="Map">
        select t.name storeName,t.address,su.user_id staffId , t.store_id storeId,t.create_time createTime,t.state
        from s_store t
        inner join s_store_user su on t.store_id = su.store_id and su.status_cd = '0'
        <if test="relCd != null and relCd != ''">
            and su.rel_cd = #{relCd}
        </if>
        where
        1=1
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and t.store_type_cd = #{storeTypeCd}
        </if>
        <if test="storeId != null and storeId != ''">
            and t.store_id = #{storeId}
        </if>
        and t.status_cd = '0'
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <select id="getStoreStaffCount" parameterType="Map" resultType="Map">
        select count(1) count
        from s_store t
        inner join s_store_user su on t.store_id = su.store_id and su.status_cd = '0'
        <if test="relCd != null and relCd != ''">
            and su.rel_cd = #{relCd}
        </if>
        where
        1=1
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and t.store_type_cd = #{storeTypeCd}
        </if>
        <if test="storeId != null and storeId != ''">
            and t.store_id = #{storeId}
        </if>
        and t.status_cd = '0'
    </select>
    <!-- 修改商户信息 add by wuxw 2018-07-03 -->
    <update id="updateStore" parameterType="Map">
        update s_store s
        <set>
            <if test="userId != null and userId != ''">
                s.user_id = #{userId},
            </if>
            <if test="name != null and name != ''">
                s.name = #{name},
            </if>
            <if test="address != null and address != ''">
                s.address = #{address},
            </if>
            <if test="tel != null and tel != ''">
                s.tel = #{tel},
            </if>
            <if test="storeTypeCd != null and storeTypeCd != ''">
                s.store_type_cd = #{storeTypeCd},
            </if>
            <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
                s.nearby_landmarks = #{nearbyLandmarks},
            </if>
            <if test="mapX != null and mapX != ''">
                s.map_x = #{mapX},
            </if>
            <if test="mapY != null and mapY != ''">
                s.map_y = #{mapY},
            </if>
            <if test="state != null and state != ''">
                s.state = #{state},
            </if>
        </set>
        where 1=1
        and s.store_id = #{storeId}
        and s.status_cd = '0'
    </update>
</mapper>