<?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.gree.mall.manager.commonmapper.OrderRefundInfoMapper">


    <select id="getOrderRefundDetailList" resultType="com.gree.mall.manager.bean.order.OrderDetailListBean">
        SELECT
            ord.order_id as orderId,
            od.goods_name as goodsName,
            CONCAT(od.goods_spec_name,'(',od.goods_spec_value,')') as goodsSpecValue,
            od.num as num,
            od.price as price,
            od.pay_amount as payAmount,
            od.total_price as totalPrice,
            ord.rece_user_name as receUserName,
            ord.rece_phone as recePhone,
            CONCAT(ord.province,ord.city,ord.area,ord.street,ord.rece_address,ord.house_no) as address,
            ord.order_status as orderStatus,
            o.refund_flag as refundFlag,
            od.refund_amount as refundAmount,
            od.refund_num as refundNum,
            ord.remark as remark,
            o.create_time as createTime,
            ord.user_name as userName,
            ord.worker_name as workerName,
            o.buyer_msg as buyerMsg,
            ord.refund_message as refundMessage,
            ord.websit_name as websitName,
            CONCAT( ord.worker_name,'/',ord.websit_name) as workerNameWithWebsitName,
            od.share_amount as shareAmount ,
            u.nick_name as nickName,
            u.mobile as mobile,
            od.promotion_group_id as promotionGroupId,
            ord.refund_explain as refundExplain,
            ord.company_wechat_name
        from order_refund ord
        LEFT JOIN `user` u on u.user_id=ord.user_id
        LEFT JOIN order_info o on o.order_id=ord.order_id
        LEFT JOIN order_detail od  on ord.order_id=od.order_id
        <where>
            <if test="orderId != null and orderId != ''">
                and ord.order_id like CONCAT('%',#{orderId},'%')
            </if>
            <if test="orderRefundId != null and orderRefundId != ''">
                and ord.order_refund_id like CONCAT('%',#{orderRefundId},'%')
            </if>
            <if test="userName != null and userName != ''">
                and ord.user_name like CONCAT('%',#{userName},'%')
            </if>
            <if test="phone != null and phone != ''">
                and ord.phone like CONCAT('%',#{phone},'%')
            </if>
            <if test="orderStatus != null and orderStatus != ''">
                and ord.order_status=#{orderStatus}
            </if>
            <if test="startCreateTime != null and endCreateTime != null">
                and ord.create_time between #{startCreateTime} and #{endCreateTime}
            </if>
            <if test="startExamineTime != null and endExamineTime != null">
                and ord.examine_time between #{startExamineTime} and #{endExamineTime}
            </if>
            <if test="companyWechatIds != null and companyWechatIds.size > 0">
                and ord.company_wechat_id in
                <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        order by ord.create_time desc
    </select>

</mapper>