<?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.IVirtualOrderMapper">

    <select id="getChargeListByParam" resultType="com.fdkankan.platform.user.vo.ResponseVirtualOrder">
        SELECT o.id, o.order_sn, o.points, c.child_name, o.pay_type, o.body, o.trade_time, o.status from t_virtual_order o
        LEFT JOIN t_camera c on o.camera_id = c.id  WHERE o.rec_status = 'A' and o.pay_status = 1   and o.pay_type = 0
        <if test=" userId != null and userId !='' " >
            and o.user_id = ${userId}
        </if>
        <if test=" status != null and status !='' " >
            and o.status = ${status}
        </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="getChargeCountByParam" resultType="integer">
        SELECT count (*) from t_virtual_order o WHERE o.rec_status = 'A' and o.pay_status = 1   and o.pay_type = 0
        <if test=" userId != null and userId !='' " >
            and o.user_id = ${userId}
        </if>
        <if test=" status != null and status !='' " >
            and o.status = ${status}
        </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>
