<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.crm.manager.dao.mapper.MamPmPercentChangeMapper">

    <select id="countList"
            parameterType="com.crm.rely.backend.core.entity.mam.MamPmPercentChangeListEntity"
            resultType="Integer">
        select count(id)
        from mam_pm_percent_change
        <where>
            <if test="cId != null and cId > 0">
                and c_id = #{cId}
            </if>
            <if test="ibNo != null">
                and ib_no like concat('%',#{ibNo},'%')
            </if>
            <if test="status != null and status > 0">
                and status = #{status}
            </if>
            <if test="ownerId != null and ownerId > 0">
                and owner_id = #{ownerId}
            </if>
            <if test="accountId != null and accountId > 0">
                and account_id = #{accountId}
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[>=]]> #{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[<=]]> #{endDate}
            </if>
        </where>
    </select>

    <select id="getList"
            parameterType="com.crm.rely.backend.core.entity.mam.MamPmPercentChangeListEntity"
            resultType="com.crm.rely.backend.core.pojo.table.MamPmPercentChangeTable">
        select *
        from mam_pm_percent_change
        <where>
            <if test="cId != null and cId > 0">
                and c_id = #{cId}
            </if>
            <if test="ibNo != null">
                and ib_no like concat('%',#{ibNo},'%')
            </if>
            <if test="status != null and status > 0">
                and status = #{status}
            </if>
            <if test="ownerId != null and ownerId > 0">
                and owner_id = #{ownerId}
            </if>
            <if test="accountId != null and accountId > 0">
                and account_id = #{accountId}
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[>=]]> #{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[<=]]> #{endDate}
            </if>
        </where>
        order by add_time desc
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>

</mapper>