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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*,b.nickname,b.avatar,c.equipment_code,d.merchant_name
        FROM shop_order_refund a
        LEFT JOIN sys_user b ON a.user_id = b.user_id
        LEFT JOIN apps_equipment c ON a.order_id = c.order_id
        LEFT JOIN shop_merchant d ON a.merchant_code = d.merchant_code
        <where>
            <if test="param.orderRefundId != null">
                AND a.order_refund_id = #{param.orderRefundId}
            </if>
            <if test="param.orderId != null">
                AND a.order_id = #{param.orderId}
            </if>
            <if test="param.orderGoodsId != null">
                AND a.order_goods_id = #{param.orderGoodsId}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.type != null">
                AND a.type = #{param.type}
            </if>
            <if test="param.applyDesc != null">
                AND a.apply_desc LIKE CONCAT('%', #{param.applyDesc}, '%')
            </if>
            <if test="param.auditStatus != null">
                AND a.audit_status = #{param.auditStatus}
            </if>
            <if test="param.refuseDesc != null">
                AND a.refuse_desc LIKE CONCAT('%', #{param.refuseDesc}, '%')
            </if>
            <if test="param.refundMoney != null">
                AND a.refund_money = #{param.refundMoney}
            </if>
            <if test="param.isUserSend != null">
                AND a.is_user_send = #{param.isUserSend}
            </if>
            <if test="param.sendTime != null">
                AND a.send_time = #{param.sendTime}
            </if>
            <if test="param.expressId != null">
                AND a.express_id LIKE CONCAT('%', #{param.expressId}, '%')
            </if>
            <if test="param.expressNo != null">
                AND a.express_no LIKE CONCAT('%', #{param.expressNo}, '%')
            </if>
            <if test="param.isReceipt != null">
                AND a.is_receipt = #{param.isReceipt}
            </if>
            <if test="param.shopId != null">
                AND a.shop_id = #{param.shopId}
            </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.shop.entity.OrderRefund">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
