wuxw
2022-07-19 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54
java110-db/src/main/resources/mapper/user/UserServiceDaoImplMapper.xml
old mode 100644 new mode 100755
@@ -40,67 +40,78 @@
    <!--保存数据至过程表 bo_cust 中 -->
    <insert id="saveDataToBoCust" parameterType="com.java110.entity.user.BoCust">
        <![CDATA[
            insert into bo_cust(boId,custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,state)
            values(#{boId},#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{state})
                    insert into bo_cust(boId,custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,state)
                    values(#{boId},#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{state})
        ]]>
    </insert>
    <!-- 保存数据至过程表bo_cust_attr 中-->
    <insert id="saveDataToBoCustAttr" parameterType="com.java110.entity.user.BoCustAttr">
        <![CDATA[
            insert into bo_cust_attr(boId,custId,attrCd,value,state)
            values(#{boId},#{custId},#{attrCd},#{value},#{state})
                    insert into bo_cust_attr(boId,custId,attrCd,value,state)
                    values(#{boId},#{custId},#{attrCd},#{value},#{state})
        ]]>
    </insert>
    <!-- 保存 实例客户信息 cust -->
    <insert id="saveDataToCust" parameterType="com.java110.entity.user.Cust">
        <![CDATA[
            insert into cust(custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,status_cd)
            values(#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{status_cd})
                    insert into cust(custId,name,email,cellphone,realName,sex,password,lanId,custAdress,custType,openId,status_cd)
                    values(#{custId},#{name},#{email},#{cellphone},#{realName},#{sex},#{password},#{lanId},#{custAdress},#{custType},#{openId},#{status_cd})
        ]]>
    </insert>
    <!-- 删除实例客户信息 cust -->
    <insert id="deleteDataToCust" parameterType="com.java110.entity.user.Cust">
        <![CDATA[
           delete * from cust c where c.custId = #{custId}
                   delete * from cust c where c.custId = #{custId}
        ]]>
    </insert>
    <!-- 保存 实例客户属性信息 cust_attr -->
    <insert id="saveDataToCustAttr" parameterType="com.java110.entity.user.CustAttr">
        <![CDATA[
            insert into cust_attr(custId,attrCd,value,status_cd)
            values(#{custId},#{attrCd},#{value},#{status_cd})
                    insert into cust_attr(custId,attrCd,value,status_cd)
                    values(#{custId},#{attrCd},#{value},#{status_cd})
        ]]>
    </insert>
    <!-- 删除实例客户信息 cust -->
    <update id="deleteDataToCustAttr" parameterType="com.java110.entity.user.CustAttr">
           delete * from cust_attr ct where 1=1
           <if test="custId != null and custId != ''">
               and ct.custId = #{custId}
           </if>
            <if test="attrCd != null and attrCd != ''">
                and ct.attrCd = #{attrCd}
            </if>
        delete * from cust_attr ct where 1=1
        <if test="custId != null and custId != ''">
            and ct.custId = #{custId}
        </if>
        <if test="attrCd != null and attrCd != ''">
            and ct.attrCd = #{attrCd}
        </if>
    </update>
    <!--根据客户ID 查询客户信息,其中包括 cust 和custAttr 数据-->
    <select id="queryDataToCust" parameterType="com.java110.entity.user.Cust" resultMap="custMap">
            select c.custId,c.name,c.email,c.cellphone,c.realName,c.sex,c.password,c.lanId,c.custAdress,c.custType,c.openId,
            ca.custId,ca.attrCd,ca.value
             from cust c, cust_attr ca where c.custId= ca.custId
        select c.custId,c.name,c.email,c.cellphone,c.realName,c.sex,c.password,c.lanId,c.custAdress,c.custType,c.openId,
        ca.custId,ca.attrCd,ca.value
        from cust c, cust_attr ca where c.custId= ca.custId
        <if test="custId != null and custId != ''">
            and c.custId = #{custId}
        </if>
        <if test="versionId != null and versionId != ''">
            and c.versionId = #{versionId}
        </if>
            and c.status_cd = '0'
        and c.status_cd = '0'
    </select>
    <!-- 查询客户过程数据 -->
    <select id="queryBoCust" parameterType="com.java110.entity.user.BoCust" resultType="com.java110.entity.user.BoCust">
        select bc.boId,bc.custId,bc.name,bc.email,bc.cellphone,bc.realName,bc.sex,bc.password,bc.lanId,bc.custAdress,bc.custType,bc.openId,bc.create_dt
        select
        bc.boId,bc.custId,bc.name,bc.email,bc.cellphone,bc.realName,bc.sex,bc.password,bc.lanId,bc.custAdress,bc.custType,bc.openId,bc.create_dt
        from bo_cust bc where 1=1
        <if test="boId != null and boId != ''">
            and bc.boId = #{boId}
@@ -117,7 +128,8 @@
        </if>
    </select>
    <!-- 查询客户属性过程表-->
    <select id="queryBoCustAttr" parameterType="com.java110.entity.user.BoCustAttr" resultType="com.java110.entity.user.BoCustAttr">
    <select id="queryBoCustAttr" parameterType="com.java110.entity.user.BoCustAttr"
            resultType="com.java110.entity.user.BoCustAttr">
        select bca.boId,bca.custId,bca.attrCd,bca.value,bca.state,bca.create_dt from bo_cust_attr bca where 1=1
        <if test="boId !=null and boId != ''">
            and bca.boId = #{boId}
@@ -134,7 +146,8 @@
    </select>
    <!-- 查询客户属性信息 -->
    <select id="queryDataToCustAttr" parameterType="com.java110.entity.user.CustAttr" resultType="com.java110.entity.user.CustAttr">
    <select id="queryDataToCustAttr" parameterType="com.java110.entity.user.CustAttr"
            resultType="com.java110.entity.user.CustAttr">
        select * from cust_attr ca where 1=1
        <if test="custId != null and custId != ''">
            and ca.custId = #{custId}
@@ -162,12 +175,15 @@
    <!-- 实例数据 -->
    <insert id="saveUserInfoInstance" parameterType="map">
        insert into u_user(user_id,name,email,address,password,location_cd,age,sex,tel,level_cd,b_id,status_cd)
        select bu.user_id,bu.name,bu.email,bu.address,bu.password,bu.location_cd,bu.age,bu.sex,bu.tel,bu.level_cd,bu.b_id,'0' from business_user bu where bu.operate = 'ADD' and bu.b_id=#{b_id}
        select
        bu.user_id,bu.name,bu.email,bu.address,bu.password,bu.location_cd,bu.age,bu.sex,bu.tel,bu.level_cd,bu.b_id,'0'
        from business_user bu where bu.operate = 'ADD' and bu.b_id=#{b_id}
    </insert>
    <insert id="saveUserAttrInstance" parameterType="map">
        insert into u_user_attr(attr_id,user_id,spec_cd,value,b_id,status_cd)
        select bua.attr_id,bua.user_id,bua.spec_cd,bua.value,bua.b_id,'0' from business_user_attr bua where bua.operate='ADD' and bua.b_id=#{b_id}
        select bua.attr_id,bua.user_id,bua.spec_cd,bua.value,bua.b_id,'0' from business_user_attr bua where
        bua.operate='ADD' and bua.b_id=#{b_id}
    </insert>
    <update id="updateUserInfoInstance" parameterType="map">
@@ -199,6 +215,9 @@
        <if test="tel !=null and tel != ''">
            ,u.tel= #{tel}
        </if>
        <if test="score !=null and score != ''">
            ,u.score= #{score}
        </if>
        where 1 = 1
        <if test="bId != null and bId != ''">
            and u.b_id = #{bId}
@@ -222,14 +241,13 @@
    </update>
    <!-- 查询用户信息 Business -->
    <select id="queryBusinessUserInfo" parameterType="map" resultType="map">
        select u.user_id,u.name,u.email,u.address,u.password,u.location_cd,
        u.age,u.sex,u.tel,u.level_cd,u.b_id,u.operate
        from business_user u where 1 = 1
        <if test="operate != null and operate != ''">
           and u.operate = #{operate}
            and u.operate = #{operate}
        </if>
        <if test="bId != null and bId !=''">
            and u.b_id = #{bId}
@@ -259,7 +277,8 @@
    <!-- 查询用户信息 -->
    <select id="queryUserInfo" parameterType="map" resultType="map">
        select u.user_id, u.user_id userId,u.name,u.name userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
        select u.user_id, u.user_id userId,u.name,u.name
        userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
        u.age,u.sex,u.tel,u.level_cd,u.b_id
        from u_user u where 1= 1
        <if test="bId != null and bId !=''">
@@ -273,17 +292,17 @@
        </if>
        <if test="userIds != null and userIds != null">
            and u.user_id in
                <foreach collection="userIds" item="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            <foreach collection="userIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
    </select>
    <!-- 查询用户属性信息 -->
    <select id="queryUserInfoAttrs" parameterType="map" resultType="map">
        select u.attr_id,u.user_id,u.spec_cd,u.value,u.b_id
        select u.attr_id,u.user_id,u.spec_cd,u.value,u.b_id,
        u.attr_id attrId,u.user_id userId,u.spec_cd specCd,u.b_id bId
        from u_user_attr u where u.status_cd = '0'
        <if test="bId != null and bId !=''">
            and u.b_id = #{bId}
@@ -293,6 +312,9 @@
        </if>
        <if test="attrId != null and attrId != ''">
            and u.attr_id = #{attrId}
        </if>
        <if test="specCd != null and specCd != ''">
            and u.spec_cd = #{specCd}
        </if>
    </select>
@@ -387,7 +409,6 @@
    </update>
    <!--保存用户证件信息 add by wuxw 2018-06-29 -->
    <insert id="saveBusinessUserCredentials" parameterType="map">
        insert into business_user_credentials(credentials_id,b_id,user_id,credentials_cd,value,operate)
@@ -436,56 +457,273 @@
    <select id="getStaffCount" parameterType="Map" resultType="Map">
        select count(1) count
        from
             u_user a
            ,u_org uo
            ,u_org_staff_rel uosr
        u_user a
        ,u_org uo
        ,u_org_staff_rel uosr
        ,u_org puo
        where a.level_cd = '01'
            and a.user_id = uosr.staff_id
        and a.user_id = uosr.staff_id
        <if test="storeId !=null and storeId != ''">
            and uosr.store_id = #{storeId}
            and uosr.org_id = uo.org_id
        </if>
        and uosr.org_id = uo.org_id
        and uo.parent_org_id = puo.org_id
        <if test="parentOrgId !=null and parentOrgId != ''">
            and uo.parent_org_id = #{parentOrgId}
            and uo.status_cd = '0'
            and uosr.status_cd = '0'
        </if>
        <if test="departmentOrgId !=null and departmentOrgId != ''">
            and uosr.org_id = #{departmentOrgId}
        </if>
        and a.status_cd = '0'
        and uo.status_cd = '0'
        and uosr.status_cd = '0'
        and puo.status_cd = '0'
        <if test="tel !=null and tel != ''">
            and a.tel= #{tel}
        </if>
        <if test="name !=null and name != ''">
            and a.name like contact('%',#{name},'%')
            and a.name like concat('%',#{name},'%')
        </if>
        <if test="staffName !=null and staffName != ''">
            and a.name like concat('%',#{staffName},'%')
        </if>
        <if test="staffId != null and staffId !=''">
            and uosr.staff_id = #{staffId}
        </if>
        <if test="orgId !=null and orgId != ''">
            and uo.org_id = #{orgId}
        </if>
        <if test="bId != null and bId !=''">
            and u.b_id = #{bId}
        </if>
    </select>
    <!-- 查询员工总量 -->
    <select id="getStaffs" parameterType="Map" resultType="Map">
        select uo.org_name,uo.org_name orgName,u.user_id, u.user_id userId,u.name,u.name userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
        u.age,u.sex,u.tel,u.level_cd,u.b_id
        select uo.org_id orgId,uo.org_name,uo.org_name orgName,u.user_id, u.user_id userId,u.name,u.name
        userName,u.email,u.address,u.location_cd,u.location_cd locationCd,
        u.age,u.sex,u.tel,u.level_cd levelCd,u.b_id,puo.org_id parentOrgId,puo.org_name
        parentOrgName,puo.belong_community_id belongCommunityId,
        uosr.store_id storeId,uosr.rel_cd relCd
        from
        u_user a
        u_user u
        ,u_org uo
        ,u_org_staff_rel uosr
        where a.level_cd = '01'
        and a.user_id = uosr.staff_id
        and uosr.store_id = #{storeId}
        ,u_org puo
        where u.level_cd = '01'
        and u.user_id = uosr.staff_id
        <if test="storeId !=null and storeId != ''">
            and uosr.store_id = #{storeId}
        </if>
        and uosr.org_id = uo.org_id
        and uo.parent_org_id = #{parentOrgId}
        and a.status_cd = '0'
        and uo.parent_org_id = puo.org_id
        <if test="parentOrgId !=null and parentOrgId != ''">
            and uo.parent_org_id = #{parentOrgId}
        </if>
        <if test="departmentOrgId !=null and departmentOrgId != ''">
            and uosr.org_id = #{departmentOrgId}
        </if>
        and u.status_cd = '0'
        and uo.status_cd = '0'
        and uosr.status_cd = '0'
        and puo.status_cd = '0'
        <if test="tel !=null and tel != ''">
            and a.tel= #{tel}
            and u.tel= #{tel}
        </if>
        <if test="name !=null and name != ''">
            and a.name like contact('%',#{name},'%')
            and u.name like concat('%',#{name},'%')
        </if>
        <if test="staffName !=null and staffName != ''">
            and u.name like concat('%',#{staffName},'%')
        </if>
        <if test="staffId != null and staffId !=''">
            and uosr.staff_id = #{staffId}
        </if>
        order by desc
        <if test="orgId !=null and orgId != ''">
            and uo.org_id = #{orgId}
        </if>
        <if test="bId != null and bId !=''">
            and u.b_id = #{bId}
        </if>
        <if test="userIds != null and userIds != null">
            and u.user_id in
            <foreach collection="userIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        order by u.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <!-- 查询用户 -->
    <select id="getUsers" parameterType="Map" resultType="Map">
        select u.user_id, u.user_id userId,u.name,u.name
        userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
        u.age,u.sex,u.tel,u.level_cd,u.b_id,u.level_cd levelCd,u.score
        from u_user u
        <if test="openId != null and openId !=''">
            ,u_user_attr ua
        </if>
        <if test="key != null and key !=''">
            ,u_user_attr ub
        </if>
        <if test="unionId != null and unionId !=''">
            ,u_user_attr ua
        </if>
        where 1= 1
        <if test="openId != null and openId != ''">
            and u.user_id = ua.user_id
            and ua.spec_cd = '100201911001'
            and ua.value = #{openId}
            and ua.status_cd = '0'
        </if>
        <if test="unionId != null and unionId != ''">
            and u.user_id = ua.user_id
            and ua.spec_cd = '100201911002'
            and ua.value = #{unionId}
            and ua.status_cd = '0'
        </if>
        <if test="key != null and key != ''">
            and u.user_id = ub.user_id
            and ub.spec_cd = '100202061602'
            and ub.value = #{key}
            and ub.status_cd = '0'
        </if>
        <if test="bId != null and bId !=''">
            and u.b_id = #{bId}
        </if>
        <if test="userId != null and userId != ''">
            and u.user_id = #{userId}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and u.status_cd = #{statusCd}
        </if>
        <if test="userIds != null and userIds != null">
            and u.user_id in
            <foreach collection="userIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="name !=null and name != ''">
            and u.name= #{name}
        </if>
        <if test="userName !=null and userName != ''">
            and u.name= #{userName}
        </if>
        <if test="email !=null and email != ''">
            and u.email= #{email}
        </if>
        <if test="password !=null and password != ''">
            and u.password= #{password}
        </if>
        <if test="locationCd !=null and locationCd != ''">
            and u.location_cd= #{locationCd}
        </if>
        <if test="age !=null and age != ''">
            and u.age= #{age}
        </if>
        <if test="sex !=null and sex != ''">
            and u.sex= #{sex}
        </if>
        <if test="tel !=null and tel != ''">
            and u.tel= #{tel}
        </if>
        <if test="levelCd !=null and levelCd != ''">
            and u.level_cd= #{levelCd}
        </if>
        <if test="levelCds != null">
            and u.level_cd in
            <foreach collection="levelCds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test='userFlag !=null and userFlag =="1"'>
            and u.level_cd != '02'
        </if>
        order by u.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <select id="getUserCount" parameterType="Map" resultType="Map">
        select count(1) count
        from u_user u
        <if test="openId != null and openId !=''">
            ,u_user_attr ua
        </if>
        <if test="unionId != null and unionId !=''">
            ,u_user_attr ua
        </if>
        where 1= 1
        <if test="openId != null and openId != ''">
            and u.user_id = ua.user_id
            and ua.spec_cd = '100201911001'
            and ua.value = #{openId}
            and ua.status_cd = '0'
        </if>
        <if test="unionId != null and unionId != ''">
            and u.user_id = ua.user_id
            and ua.spec_cd = '100201911002'
            and ua.value = #{unionId}
            and ua.status_cd = '0'
        </if>
        <if test="bId != null and bId !=''">
            and u.b_id = #{bId}
        </if>
        <if test="userId != null and userId != ''">
            and u.user_id = #{userId}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and u.status_cd = #{statusCd}
        </if>
        <if test="userIds != null and userIds != null">
            and u.user_id in
            <foreach collection="userIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
    </select>
    <!-- 查询用户密码 -->
    <select id="getUserHasPwd" parameterType="Map" resultType="Map">
        select u.user_id, u.user_id userId,u.name,u.name
        userName,u.email,u.address,u.password,u.location_cd,u.location_cd locationCd,
        u.age,u.sex,u.tel,u.level_cd levelCd,u.b_id,u.password
        from u_user u
        <if test="openId != null and openId !=''">
            ,u_user_attr ua
        </if>
        <if test="unionId != null and unionId !=''">
            ,u_user_attr ua
        </if>
        where 1= 1
        <if test="openId != null and openId != ''">
            and u.user_id = ua.user_id
            and ua.spec_cd = '100201911001'
            and ua.value = #{openId}
            and ua.status_cd = '0'
        </if>
        <if test="unionId != null and unionId != ''">
            and u.user_id = ua.user_id
            and ua.spec_cd = '100201911002'
            and ua.value = #{unionId}
            and ua.status_cd = '0'
        </if>
        <if test="bId != null and bId !=''">
            and u.b_id = #{bId}
        </if>
        <if test="userId != null and userId != ''">
            and u.user_id = #{userId}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and u.status_cd = #{statusCd}
        </if>
    </select>
</mapper>