<?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.sqx.modules.order.dao.EvaluateRiderDao">


    <select id="evaluateRiderPage" resultType="com.sqx.modules.order.entity.EvaluateRider">
        SELECT
        er.*,
        u1.phone as userPhone,
        u1.avatar,
        u2.user_name as riderName,
        u2.phone,
        gs.shop_name as shopName
        FROM
        `evaluate_rider` er
        LEFT JOIN tb_user u1 ON er.user_id = u1.user_id
        LEFT JOIN tb_user u2 ON er.rider_user_id = u2.user_id
        LEFT JOIN goods_shop gs ON er.shop_id = gs.shop_id
        where 1 = 1
        <if test="riderName!=null and riderName!=''">
            and u2.user_name like concat('%',#{riderName},'%')
        </if>
        <if test="phone!=null and phone!=''">
            and u2.phone like concat('%',#{phone},'%')
        </if>
        <if test="orderNumber!=null and orderNumber!=''">
            and er.order_number like concat('%',#{orderNumber},'%')
        </if>
        <if test="userPhone!=null and userPhone!=''">
            and u1.phone like concat('%',#{userPhone},'%')
        </if>
        <if test="shopName!=null and shopName!=''">
            and gs.shop_name like concat('%',#{shopName},'%')
        </if>
        <if test="riderScore!=null and riderScore!=''">
            and er.rider_score = #{riderScore}
        </if>
        <if test="start != null and start != ''and end != null and end != ''">
            and er.create_time >= #{start} and #{end} >= er.create_time
        </if>
    </select>
</mapper>