<?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.custom.dao.mapper.GoldenOrderMapper">

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.model.entity.golden.order.GoldenOrderSearchEntity">
        select count(*) from golden_order der
        <where>
            <if test="customId!=null">
                and der.`custom_id` = #{customId}
            </if>
            <if test="serial!=null and serial!=''">
                and der.serial = #{serial}
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.model.pojo.table.GoldenOrderTable"
            parameterType="com.crm.rely.backend.model.entity.golden.order.GoldenOrderSearchEntity">
        select * from golden_order der
        <where>
            <if test="customId!=null">
                and der.`custom_id` = #{customId}
            </if>
            <if test="serial!=null and serial!=''">
                and der.serial = #{serial}
            </if>
        </where>
        order by id desc
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>

    <select id="getListBySerial" resultType="com.crm.rely.backend.model.dto.golden.order.GoldenOrderDetailsDto">
        SELECT *
        FROM golden_order_details
        where serial in
        <foreach collection="serialList" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

</mapper>