<?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.gxwebsoft.apps.mapper.BcExportMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM apps_bc_export a
        <where>
            <if test="param.exportId != null">
                AND a.export_id = #{param.exportId}
            </if>
            <if test="param.organizationName != null">
                AND a.organization_name LIKE CONCAT('%', #{param.organizationName}, '%')
            </if>
            <if test="param.expendMoney != null">
                AND a.expend_money = #{param.expendMoney}
            </if>
            <if test="param.breakfastPost != null">
                AND a.breakfast_post = #{param.breakfastPost}
            </if>
            <if test="param.breakfastSign != null">
                AND a.breakfast_sign = #{param.breakfastSign}
            </if>
            <if test="param.lunchPost != null">
                AND a.lunch_post = #{param.lunchPost}
            </if>
            <if test="param.lunchSign != null">
                AND a.lunch_sign = #{param.lunchSign}
            </if>
            <if test="param.dinnerPost != null">
                AND a.dinner_post = #{param.dinnerPost}
            </if>
            <if test="param.dinnerSign != null">
                AND a.dinner_sign = #{param.dinnerSign}
            </if>
            <if test="param.goodsPrice != null">
                AND a.goods_price = #{param.goodsPrice}
            </if>
            <if test="param.deliveryTime != null">
                AND a.delivery_time LIKE CONCAT('%', #{param.deliveryTime}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.orderId != null">
                AND a.order_id = #{param.orderId}
            </if>
            <if test="param.organizationId != null">
                AND a.organization_id = #{param.organizationId}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.apps.entity.BcExport">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.apps.entity.BcExport">
        <include refid="selectSql"></include>
    </select>

</mapper>
