<?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.api.manage.dao.shoppingCenter.RefundDao">

    <select id="list" parameterType="com.api.model.shoppingCenter.RefundSearch" resultType="com.api.vo.shoppingCenter.RefundVo">
        select sga.id,sga.code,sg.id as goods_id,sg.title as goods_name,sga.back_type,sga.status,sga.num,ur.name as user_name,
        ur.tel as user_tel,sga.back_date,sga.back_reason
        from shop_goods_appointment as sga,shop_goods as sg,user_resident as ur
        <where>
            sga.goods_id = sg.id
            and sga.create_id = ur.id
            and sga.status  <![CDATA[ >= ]]> 8
            <if test="code != null and code != ''">
                and sga.code like concat('%',#{code},'%')
            </if>
            <if test="backType != null">
                and sga.back_type = #{backType}
            </if>
            <if test="userTel != null and userTel != ''">
                and ur.tel like concat('%',#{userTel},'%')
            </if>
            <if test="status != null">
                and sga.status = #{status}
            </if>
        </where>
        order by sga.create_date desc
    </select>

    <update id="examine" parameterType="com.api.model.shoppingCenter.Order">
        update shop_goods_appointment
        <set>
            <if test="status != null">
                status = #{status},
            </if>
            reviewer = #{reviewer},
            audit_date = #{auditDate},
            <if test="reason != null and reason != ''">
                reason = #{reason}
            </if>
        </set>
        where id = #{id}
    </update>

</mapper>