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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*,
      b.merchant_name,b.merchant_code
        FROM apps_equipment_goods a
      LEFT JOIN shop_merchant b ON a.merchant_code = b.merchant_code
        <where>
            <if test="param.goodsId != null">
                AND a.goods_id = #{param.goodsId}
            </if>
            <if test="param.equipmentCategory != null">
                AND a.equipment_category LIKE CONCAT('%', #{param.equipment_category}, '%')
            </if>
            <if test="param.image != null">
                AND a.image LIKE CONCAT('%', #{param.image}, '%')
            </if>
          <if test="param.goodsName != null">
            AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
          </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.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.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>
          <if test="param.merchantCode != null">
            AND a.merchant_code &lt;= #{param.merchantCode}
          </if>
          <if test="param.merchantName != null">
            AND b.merchant_name &lt;= #{param.merchantName}
          </if>
        </where>
    </sql>

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

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

</mapper>
