<?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.shop.mapper.ShopStoreRiderMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM shop_store_rider a
        <where>
            <if test="param.id != null">
                AND a.id = #{param.id}
            </if>
            <if test="param.dealerId != null">
                AND a.dealer_id = #{param.dealerId}
            </if>
            <if test="param.riderNo != null">
                AND a.rider_no LIKE CONCAT('%', #{param.riderNo}, '%')
            </if>
            <if test="param.realName != null">
                AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
            </if>
            <if test="param.mobile != null">
                AND a.mobile LIKE CONCAT('%', #{param.mobile}, '%')
            </if>
            <if test="param.avatar != null">
                AND a.avatar LIKE CONCAT('%', #{param.avatar}, '%')
            </if>
            <if test="param.idCardNo != null">
                AND a.id_card_no LIKE CONCAT('%', #{param.idCardNo}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.workStatus != null">
                AND a.work_status = #{param.workStatus}
            </if>
            <if test="param.autoDispatchEnabled != null">
                AND a.auto_dispatch_enabled = #{param.autoDispatchEnabled}
            </if>
            <if test="param.dispatchPriority != null">
                AND a.dispatch_priority = #{param.dispatchPriority}
            </if>
            <if test="param.maxOnhandOrders != null">
                AND a.max_onhand_orders = #{param.maxOnhandOrders}
            </if>
            <if test="param.commissionCalcEnabled != null">
                AND a.commission_calc_enabled = #{param.commissionCalcEnabled}
            </if>
            <if test="param.waterBucketUnitFee != null">
                AND a.water_bucket_unit_fee = #{param.waterBucketUnitFee}
            </if>
            <if test="param.otherGoodsCommissionType != null">
                AND a.other_goods_commission_type = #{param.otherGoodsCommissionType}
            </if>
            <if test="param.otherGoodsCommissionValue != null">
                AND a.other_goods_commission_value = #{param.otherGoodsCommissionValue}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.isDelete != null">
                AND a.is_delete = #{param.isDelete}
            </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.keywords != null">
                AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
                )
              </if>
        </where>
    </sql>

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

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

</mapper>
