PublicPoolMapper.xml 7.35 KB
<?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="cn.fw.valhalla.dao.mapper.PublicPoolMapper">
    <select
            id="publicList"
            resultType="cn.fw.valhalla.domain.dto.PublicPoolDTO"
            parameterType="cn.fw.valhalla.domain.query.PublicPoolQueryVO"
    >
        SELECT t1.id id,
        t1.customer_id customer_id,
        t1.customer_name customer_name,
        t1.frame_no frame_no,
        t1.plate_no plate_no,
        t1.brand_id brand_id,
        t1.brand_name brand_name,
        t1.series_id series_id,
        t1.series_name series_name,
        t1.spec_id spec_id,
        t1.spec_name spec_name,
        t1.address address,
        t1.company company,
        t1.type type,
        t1.shop_id shop_id,
        t1.shop_name shop_name,
        t1.times times,
        t1.reason reason,
        t1.group_id group_id,
        t2.tags tags
        FROM public_pool t1
        left join customer t2 on t1.customer_id = t2.id
        <where>
            t1.id > 0
            <if test="condition.groupId !=null">
                and t1.group_id = #{condition.groupId}
            </if>
            <if test="condition.plateNo != null and condition.plateNo !=''">
                and t1.plate_no like concat('%', #{condition.plateNo}, '%')
            </if>
            <if test="condition.frameNo != null and condition.frameNo !=''">
                and t1.frame_no like concat('%', #{condition.frameNo}, '%')
            </if>
            <if test="condition.brandId !=null">
                and t2.brand_id = #{condition.brandId}
            </if>
            <if test="condition.seriesId !=null">
                and t2.series_id = #{condition.seriesId}
            </if>
            <if test="condition.specId !=null">
                and t2.spec_id = #{condition.specId}
            </if>
            <if test="condition.type !=null">
                and t1.type = #{condition.type}
            </if>
            <if test="condition.shopIds !=null">
                and t1.shop_id in
                <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="condition.shopName != null and condition.shopName !=''">
                and t1.shop_name like concat('%', #{condition.shopName}, '%')
            </if>
            <if test="condition.ignoreCustIds !=null">
                and t1.customer_id not in
                <foreach collection="condition.ignoreCustIds" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="condition.warrantyCard !=null and condition.warrantyCard == true">
                and FIND_IN_SET('qua_ass_card', t2.tags) != 0
            </if>
            <if test="condition.warrantyCard !=null and condition.warrantyCard == false">
                and FIND_IN_SET('qua_ass_card', t2.tags) = 0
            </if>
            <if test="condition.maintainCard !=null and condition.maintainCard == true">
                and FIND_IN_SET('maintain_card', t2.tags) != 0
            </if>
            <if test="condition.maintainCard !=null and condition.maintainCard == false">
                and FIND_IN_SET('maintain_card', t2.tags) = 0
            </if>
        </where>
        <if test="condition.order != null and condition.order == 1 ">
            order by t1.times asc
        </if>
        <if test="condition.order != null and condition.order == 0 ">
            order by t1.times desc
        </if>
        limit #{startIndex},#{pageSize};
    </select>


    <select
            id="publicListCount"
            resultType="java.lang.Long"
            parameterType="cn.fw.valhalla.domain.query.PublicCluePoolQueryVO"
    >
        SELECT count(t1.id)
        FROM public_pool t1
        left join customer t2 on t1.customer_id = t2.id
        <where>
            t1.id > 0
            <if test="condition.groupId !=null">
                and t1.group_id = #{condition.groupId}
            </if>
            <if test="condition.plateNo != null and condition.plateNo !=''">
                and t1.plate_no like concat('%', #{condition.plateNo}, '%')
            </if>
            <if test="condition.frameNo != null and condition.frameNo !=''">
                and t1.frame_no like concat('%', #{condition.frameNo}, '%')
            </if>
            <if test="condition.brandId !=null">
                and t2.brand_id = #{condition.brandId}
            </if>
            <if test="condition.seriesId !=null">
                and t2.series_id = #{condition.seriesId}
            </if>
            <if test="condition.specId !=null">
                and t2.spec_id = #{condition.specId}
            </if>
            <if test="condition.type !=null">
                and t1.type = #{condition.type}
            </if>
            <if test="condition.shopIds !=null">
                and t1.shop_id in
                <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="condition.shopName != null and condition.shopName !=''">
                and t1.shop_name like concat('%', #{condition.shopName}, '%')
            </if>
            <if test="condition.ignoreCustIds !=null">
                and t1.customer_id not in
                <foreach collection="condition.ignoreCustIds" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="condition.warrantyCard !=null and condition.warrantyCard == true">
                and FIND_IN_SET('qua_ass_card', t2.tags) != 0
            </if>
            <if test="condition.warrantyCard !=null and condition.warrantyCard == false">
                and FIND_IN_SET('qua_ass_card', t2.tags) = 0
            </if>
            <if test="condition.maintainCard !=null and condition.maintainCard == true">
                and FIND_IN_SET('maintain_card', t2.tags) != 0
            </if>
            <if test="condition.maintainCard !=null and condition.maintainCard == false">
                and FIND_IN_SET('maintain_card', t2.tags) = 0
            </if>
        </where>
    </select>

    <select
            id="queryIdListByShops"
            resultType="java.lang.String"
    >
        SELECT frame_no
        FROM public_pool
        <where>
            <if test="shopIds !=null">
                shop_id in
                <foreach collection="shopIds" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>


    <select id="countPublicPoolList" resultType="cn.fw.valhalla.domain.dto.PublicPoolReportDTO" parameterType="cn.fw.valhalla.domain.dto.PublicPoolReportQueryDTO">
        SELECT
        `type`,
        shop_id,
        shop_name,
        COUNT(*) total
        FROM
        public_pool
        WHERE
            group_id = #{groupId}
        <if test="startDate != null">
            and create_time <![CDATA[ >= ]]> #{startDate}
        </if>
        <if test="endDate != null">
            and create_time <![CDATA[ <= ]]> #{endDate}
        </if>
        GROUP BY
        shop_id,`type`
    </select>


</mapper>