中扬CRM客户关系管理系统
#
LSH
2023-12-01 6702e8cd7fca6725c0cd35613ceefef7f812c90e
src/main/resources/mapper/CstmrMapper.xml
@@ -104,12 +104,9 @@
                and
                (
                    <if test="userId != null and userId != ''">
                        user_id = #{userId}
                        user_id = #{userId} or
                    </if>
                    <if test="userId == null or userId == ''">
                        user_id is not null
                    </if>
                    or
                    director = #{userId} or
                    mc.id in
                    (
                        select
@@ -170,9 +167,9 @@
                and
                (
                <if test="userId != null and userId != ''">
                    mc.mp.user_id = #{userId}
                    mc.user_id = #{userId}
                    or
                    mc.mp.director = #{userId}
                    mc.director = #{userId}
                    or
                </if>
                mc.id in
@@ -273,9 +270,9 @@
                and
                (
                <if test="userId != null and userId != ''">
                    mc.mp.user_id = #{userId}
                    mc.user_id = #{userId}
                    or
                    mc.mp.director = #{userId}
                    mc.director = #{userId}
                    or
                </if>
                mc.id in
@@ -445,9 +442,9 @@
                and
                (
                <if test="userId != null and userId != ''">
                    mc.mp.user_id = #{userId}
                    mc.user_id = #{userId}
                    or
                    mc.mp.director = #{userId}
                    mc.director = #{userId}
                    or
                </if>
                mc.id in
@@ -554,9 +551,9 @@
                and
                (
                <if test="userId != null and userId != ''">
                    mc.mp.user_id = #{userId}
                    mc.user_id = #{userId}
                    or
                    mc.mp.director = #{userId}
                    mc.director = #{userId}
                    or
                </if>
                mc.id in
@@ -640,59 +637,49 @@
        LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
        WHERE 1=1
        and director is null
        <choose>
            <when test="deptId != null and deptId != ''">
                AND ((CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
                or
                (
                user_id = #{userId}
                or
                mc.id in
                (
                select
                cstmr_id
                from man_cstmr_foll
                where 1=1
                and user_id = #{userId}
                )
                ))
            </when>
            <otherwise>
                and
                (
                <if test="userId != null and userId != ''">
                    user_id = #{userId}
                </if>
                <if test="userId == null or userId == ''">
                    user_id is not null
                </if>
                or
                mc.id in
                (
                select
                cstmr_id
                from man_cstmr_foll
                where 1=1
                and user_id = #{userId}
                )
                )
            </otherwise>
        </choose>
<!--        <choose>-->
<!--            <when test="deptId != null and deptId != ''">-->
<!--                AND ((CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})-->
<!--                or-->
<!--                (-->
<!--                user_id = #{userId}-->
<!--                or-->
<!--                mc.id in-->
<!--                (-->
<!--                select-->
<!--                cstmr_id-->
<!--                from man_cstmr_foll-->
<!--                where 1=1-->
<!--                and user_id = #{userId}-->
<!--                )-->
<!--                ))-->
<!--            </when>-->
<!--            <otherwise>-->
<!--                and-->
<!--                (-->
<!--                <if test="userId != null and userId != ''">-->
<!--                    user_id = #{userId}-->
<!--                </if>-->
<!--                <if test="userId == null or userId == ''">-->
<!--                    user_id is not null-->
<!--                </if>-->
<!--                or-->
<!--                mc.id in-->
<!--                (-->
<!--                select-->
<!--                cstmr_id-->
<!--                from man_cstmr_foll-->
<!--                where 1=1-->
<!--                and user_id = #{userId}-->
<!--                )-->
<!--                )-->
<!--            </otherwise>-->
<!--        </choose>-->
        <if test="hostId != null">
            and mc.host_id = #{hostId}
        </if>
        <if test="condition != null and condition != ''">
            and (
            mc.uuid like concat('%',#{condition},'%')
            or mc.name like concat('%',#{condition},'%')
            or mc.simple like concat('%',#{condition},'%')
            or mc.rela like concat('%',#{condition},'%')
            or mc.tel like concat('%',#{condition},'%')
            or mc.contacts like concat('%',#{condition},'%')
            or mc.remarks like concat('%',#{condition},'%')
            or mc.director like concat('%',#{condition},'%')
            or mc.addr like concat('%',#{condition},'%')
            )
            and mc.name like concat('%',#{condition},'%')
        </if>
        ORDER BY mc.create_time DESC
    </select>