<?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.zfire.mall.manager.commonmapper.refund.RefundOrderReserveMapper">

    <select id="v2RetailListPage" resultType="com.zfire.mall.manager.bean.refund.v2.RetailRefundOrderVO">
        SELECT
            a.*,
            b.sale_type_id,
            b.sale_type_code,
            b.sale_type_name,
            b.material_id,
            b.material_old_number,
            b.material_code,
            b.material_name,
            b.k3_category_id,
            b.k3_category_number,
            b.k3_category_name,
            b.service_id,
            b.service_name,
            b.policy_id,
            b.policy_condition_id,
            b.policy_material_id,
            b.pop_type,
            b.org_price,
            b.price_type,
            b.specification,
            b.unit,
            b.rebate_rate,
            b.wallet_id1,
            b.wallet_id2,
            b.customer_wallet_id,
            b.customer_wallet_name,
            b.customer_wallet_number,
            b.customer_wallet_id2,
            b.customer_wallet_name2,
            b.is_direct_transfer,
            b.direct_transfer_status,
            b.direct_transfer_qty,
            b.price,
            b.qty,
            b.total_amount,
            b.disc_amount,
            b.single_rebate_amount,
            b.single_pay_price,
            b.pay_amount,
            b.pay_rebate_amount,
            b.old_qty,
            b.old_pay_amount,
            b.has_send_qty,
            b.tax,
            b.remark
        FROM
            refund_order a
            LEFT JOIN refund_order_item b ON a.refund_order_id = b.refund_order_id
        ${ex.query}
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.refund_time DESC
        </if>
        ${ex.orderBy}
    </select>

    <select id="v2RetailOtherListPage" resultType="com.zfire.mall.manager.bean.refund.v2.RetailOtherRefundOrderVO">
        SELECT
        a.*,
        b.sale_type_id,
        b.sale_type_code,
        b.sale_type_name,
        b.material_id,
        b.material_old_number,
        b.material_code,
        b.material_name,
        b.k3_category_id,
        b.k3_category_number,
        b.k3_category_name,
        b.service_id,
        b.service_name,
        b.policy_id,
        b.policy_condition_id,
        b.policy_material_id,
        b.pop_type,
        b.org_price,
        b.price_type,
        b.specification,
        b.unit,
        b.rebate_rate,
        b.wallet_id1,
        b.wallet_id2,
        b.customer_wallet_id,
        b.customer_wallet_name,
        b.customer_wallet_number,
        b.customer_wallet_id2,
        b.customer_wallet_name2,
        b.is_direct_transfer,
        b.direct_transfer_status,
        b.direct_transfer_qty,
        b.price,
        b.qty,
        b.total_amount,
        b.disc_amount,
        b.pay_amount,
        b.pay_rebate_amount,
        b.old_qty,
        b.old_pay_amount,
        b.has_send_qty,
        b.tax,
        b.remark,
        b.engin_num
        FROM
        refund_order a
        LEFT JOIN refund_order_item b ON a.refund_order_id = b.refund_order_id
        ${ex.query}
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.refund_time DESC
        </if>
        ${ex.orderBy}
    </select>

    <select id="v2TradeEListPage" resultType="com.zfire.mall.manager.bean.refund.v2.TradeERefundOrderVO">
        SELECT
        a.*,
        b.sale_type_id,
        b.sale_type_code,
        b.sale_type_name,
        b.material_id,
        b.material_old_number,
        b.material_code,
        b.material_name,
        b.k3_category_id,
        b.k3_category_number,
        b.k3_category_name,
        b.service_name AS itemServiceName,
        b.specification,
        b.unit,
        b.rebate_rate,
        b.customer_wallet_id,
        b.customer_wallet_name,
        b.customer_wallet_number,
        b.customer_wallet_id2,
        b.customer_wallet_name2,
        b.is_direct_transfer,
        b.direct_transfer_status,
        b.direct_transfer_qty,
        b.price,
        b.qty,
        b.total_amount,
        b.disc_amount,
        b.pay_amount,
        b.pay_rebate_amount,
        b.old_qty,
        b.old_pay_amount,
        b.has_send_qty,
        b.tax,
        b.remark
        FROM
        refund_order a
        LEFT JOIN refund_order_item b ON a.refund_order_id = b.refund_order_id
        ${ex.query}
        <if test="ex.orderBy == null or ex.orderBy ==''">
            ORDER BY a.refund_time DESC
        </if>
        ${ex.orderBy}
    </select>
</mapper>