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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM apps_equipment_order_goods a
        <where>
            <if test="param.orderGoodsId != null">
                AND a.order_goods_id = #{param.orderGoodsId}
            </if>
            <if test="param.goodsName != null">
                AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
            </if>
            <if test="param.equipmentCategory != null">
                AND a.equipment_category LIKE CONCAT('%', #{param.equipmentCategory}, '%')
            </if>
            <if test="param.image != null">
                AND a.image LIKE CONCAT('%', #{param.image}, '%')
            </if>
            <if test="param.qrcode != null">
                AND a.qrcode LIKE CONCAT('%', #{param.qrcode}, '%')
            </if>
            <if test="param.categoryId != null">
                AND a.category_id = #{param.categoryId}
            </if>
            <if test="param.batteryModel != null">
                AND a.battery_model LIKE CONCAT('%', #{param.batteryModel}, '%')
            </if>
            <if test="param.sellingPoint != null">
                AND a.selling_point LIKE CONCAT('%', #{param.sellingPoint}, '%')
            </if>
            <if test="param.stockTotal != null">
                AND a.stock_total = #{param.stockTotal}
            </if>
            <if test="param.content != null">
                AND a.content LIKE CONCAT('%', #{param.content}, '%')
            </if>
            <if test="param.batteryRent != null">
                AND a.battery_rent = #{param.batteryRent}
            </if>
            <if test="param.batteryPrice != null">
                AND a.battery_price = #{param.batteryPrice}
            </if>
            <if test="param.batteryDeposit != null">
                AND a.battery_deposit = #{param.batteryDeposit}
            </if>
            <if test="param.batteryInsurance != null">
                AND a.battery_insurance = #{param.batteryInsurance}
            </if>
            <if test="param.downPayment != null">
                AND a.down_payment = #{param.downPayment}
            </if>
            <if test="param.periods != null">
                AND a.periods = #{param.periods}
            </if>
            <if test="param.repayment != null">
                AND a.repayment = #{param.repayment}
            </if>
            <if test="param.serviceCharges != null">
                AND a.service_charges = #{param.serviceCharges}
            </if>
            <if test="param.periodsType != null">
                AND a.periods_type = #{param.periodsType}
            </if>
            <if test="param.orderId != null">
                AND a.order_id = #{param.orderId}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </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.merchantCode != null">
                AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
            </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.EquipmentOrderGoods">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
