<?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.xy.mapper.DeviceAlgorithmChargingMapper">

    <!-- 扣费查询 -->
    <select id="chargingQuery" resultType="com.xy.entity.DeviceAlgorithmCharging">
        <foreach collection="list" item="item" separator="UNION">
            select *
            from device_algorithm_charging
            where device_id = #{item.deviceId}
            and algorithm_id = #{item.algorithmId}
            and unused_size > 0
            and ((begin_time &lt;= #{item.beginTime} and timeout >= #{item.beginTime}) or timeout = -1)
            and merc_id = #{item.mercId}
        </foreach>
    </select>
</mapper>
