<?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.fdkankan.platform.order.mapper.IExpansionOrderMapper">

    <select id="getExpansionListByParam" resultType="com.fdkankan.platform.order.vo.ResponseExpansionOrder">
        select o.id, t.child_name, o.unit, o.unit_size, c.space, o.pay_type, c.space_start_time, c.space_end_time, o.trade_time, o.pay_status, o.amount, o.order_sn, o.status, o.month from t_expansion_order o
        LEFT JOIN t_camera_space c on o.order_sn = c.order_sn
        LEFT JOIN t_camera t on o.camera_id = t.id
        WHERE o.pay_status = 1 AND o.rec_status = 'A'
        <if test=" userId != null and userId !='' " >
            and o.user_id = ${userId}
        </if>
        <if test=" childName != null and childName !='' " >
            and c.child_name like concat('%',#{childName},'%')
        </if>
        <if test=" cameraId != null and cameraId !='' " >
            and o.camera_id = ${cameraId}
        </if>
        <if test="orderBy != null">
            order by ${orderBy}
        </if>
        limit ${start}, ${pageSize}
    </select>

    <select id="getExpansionCountByParam" resultType="integer">
        select count (*) from t_expansion_order o
        WHERE o.pay_status = 1 AND o.rec_status = 'A'
        <if test=" userId != null and userId !='' " >
            and o.user_id = ${userId}
        </if>
        <if test=" childName != null and childName !='' " >
            and c.child_name like concat('%',#{childName},'%')
        </if>
        <if test=" cameraId != null and cameraId !='' " >
            and o.camera_id = ${cameraId}
        </if>
    </select>

</mapper>
