public Map countOrder(@Param("orderIds") List<Long> orderIds,@Param("map") Map map);
<select id="countOrder" resultType="java.util.HashMap" >
        select count(id) as orders,IFNULL(count(DISTINCT user_id),0) as buyers,IFNULL(sum(order_price),0) as price
        from wp_order
        <where>
        id in
        <foreach item="id"
                 collection="orderIds"
                 open="("
                 separator=","
                 close=")">
            #{id}
        </foreach>
            <if test="map.addTime != null and map.addTime != ''">
                AND date_format( add_time,'%y%m%d')= date_format(#{map.addTime},'%y%m%d')
            </if>
            <if test="map.beginTime != null and map.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format( add_time,'%y%m%d') >= date_format(#{map.beginTime},'%y%m%d')
            </if>
            <if test="map.endTime != null and map.endTime != ''"><!-- 结束时间检索 -->
                AND date_format( add_time,'%y%m%d') <= date_format(#{map.endTime},'%y%m%d')
            </if>
        </where>
</select>

指定日期或指定日期范围查询数据_List因为使用map传addTime、beginTime、endTime去查询,总是报错参数找不到,后来经过测试发现再取值的时候如果是map或对象需要使用map.xxx / obj.xxx的方式进行取值

指定日期或指定日期范围查询数据_java_02