中扬CRM客户关系管理系统
#
luxiaotao1123
2022-11-08 312ef16e8e6c3e985b19e4beb9c01972177133de
src/main/resources/mapper/OrderMapper.xml
@@ -30,4 +30,65 @@
    </resultMap>
    <select id="selectByUuid" resultMap="BaseResultMap">
        select * from man_order
        where 1=1
        and uuid = #{uuid}
        <if test="hostId != null">
            and host_id = #{hostId}
        </if>
    </select>
    <select id="selectOrderByNewestUuid" resultMap="BaseResultMap">
        select top 1 * from man_order
        where 1=1
        <if test="hostId != null">
            and host_id = #{hostId}
        </if>
        order by uuid + 0 desc
    </select>
    <select id="listByPage" resultMap="BaseResultMap">
        SELECT
        mo.*
        FROM man_order mo
        LEFT JOIN sys_dept sd ON mo.dept_id = sd.id
        WHERE 1=1
        <choose>
            <when test="deptId != null and deptId != ''">
                AND (CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
            </when>
            <otherwise>
                and
                (
                    user_id = #{userId}
                    or
                    mo.id in
                    (
                        select
                        order_id
                        from man_order_foll
                        where 1=1
                        and user_id = #{userId}
                    )
                )
            </otherwise>
        </choose>
        <if test="hostId != null">
            and mo.host_id = #{hostId}
        </if>
        <if test="condition != null and condition != ''">
            and (
            mo.uuid like concat('%',#{condition},'%')
            or mo.name like concat('%',#{condition},'%')
            or mo.tel like concat('%',#{condition},'%')
            or mo.contacts like concat('%',#{condition},'%')
            or mo.remarks like concat('%',#{condition},'%')
            or mo.director like concat('%',#{condition},'%')
            or mo.addr like concat('%',#{condition},'%')
            )
        </if>
        ORDER BY mo.create_time DESC
    </select>
</mapper>