<?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.ycwl.basic.mapper.RefundMapper">
    <insert id="addGetId" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
        INSERT INTO refund(member_id,order_id,out_refund_no,refund_price,reason,create_time)
        VALUES (#{memberId},#{orderId},#{outRefundNo},#{refundPrice},#{reason},now())
    </insert>
    <update id="update">
        UPDATE refund
        <set>
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="outRefundNo != null">out_refund_no = #{outRefundNo},</if>
            <if test="refundPrice != null">refund_price = #{refundPrice},</if>
            <if test="reason != null">reason = #{reason},</if>
        </set>
        WHERE id = #{id}
    </update>
    <update id="setRefundNo">
        UPDATE refund SET out_refund_no = #{outRefundNo} WHERE id = #{id}
    </update>
    <update id="setRefunded">
        UPDATE refund SET refund_time = now() WHERE id = #{id}
    </update>
    <select id="findByOutRefundNo" resultType="com.ycwl.basic.model.pc.refund.entity.RefundEntity">
        SELECT * FROM refund WHERE out_refund_no = #{outRefundNo}
    </select>
</mapper>