<?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="cn.iocoder.yudao.module.rescue.mapper.RescueOrderInfoMapper">

    <select id="selectRescueOrderInfoList" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueOrderInfo" resultType="cn.iocoder.yudao.module.rescue.domain.RescueOrderInfo">
            select * from rescue_order_detail
        <where>  
            <if test="orderNo != null  and orderNo != ''"> and order_no = #{orderNo}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="realName != null  and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
            <if test="phonenumber != null  and phonenumber != ''"> and phonenumber = #{phonenumber}</if>
            <if test="payMoney != null "> and pay_money = #{payMoney}</if>
            <if test="orderTime != null "> and order_time = #{orderTime}</if>
            <if test="reduceMoney != null "> and reduce_money = #{reduceMoney}</if>
            <if test="balance != null "> and balance = #{balance}</if>
            <if test="payTime != null "> and pay_time = #{payTime}</if>
            <if test="payType != null  and payType != ''"> and pay_type = #{payType}</if>
            <if test="payRemark != null  and payRemark != ''"> and pay_remark = #{payRemark}</if>
            <if test="isOnline != null  and isOnline != ''"> and is_online = #{isOnline}</if>
            <if test="receivablesAccount != null  and receivablesAccount != ''"> and receivables_account = #{receivablesAccount}</if>
            <if test="orderStatus != null  and orderStatus != ''"> and order_status = #{orderStatus}</if>
            <if test="commentDesc != null  and commentDesc != ''"> and comment_desc = #{commentDesc}</if>
            <if test="commentStar != null "> and comment_star = #{commentStar}</if>
            <if test="commentTime != null "> and comment_time = #{commentTime}</if>
            <if test="accessCode != null  and accessCode != ''"> and access_code = #{accessCode}</if>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="validationTime != null "> and validation_time = #{validationTime}</if>
            <if test="validationRealName != null  and validationRealName != ''"> and validation_real_name like concat('%', #{validationRealName}, '%')</if>
            <if test="validationUserId != null "> and validation_user_id = #{validationUserId}</if>
            <if test="isCoupon != null  and isCoupon != ''"> and is_coupon = #{isCoupon}</if>
            <if test="couponId != null "> and coupon_id = #{couponId}</if>
            <if test="couponCode != null  and couponCode != ''"> and coupon_code = #{couponCode}</if>
            <if test="couponDiscount != null "> and coupon_discount = #{couponDiscount}</if>
        </where>
    </select>
    
    <select id="selectRescueOrderInfoById" parameterType="java.lang.Long" resultType="cn.iocoder.yudao.module.rescue.domain.RescueOrderInfo">
         select * from rescue_order_detail
        where id = #{id}
    </select>
    <select id="avgPartnerScore" resultType="java.lang.Double">
        SELECT
            avg(comment_star)
        FROM
            rescue_order_info roi
            inner join rescue_info ri on roi.rescue_info_id = ri.id
        where ri.driver_id = #{driverId}
    </select>

</mapper>