<?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.yami.shop.dao.RefundOrderSettlementMapper">

    <resultMap id="refundOrderSettlementMap" type="com.yami.shop.bean.model.RefundOrderSettlement">
        <id column="settlement_id" property="settlementId" />
        <result column="order_number" property="orderNumber"/>
        <result column="order_pay_no" property="orderPayNo"/>
        <result column="refund_sn" property="refundSn"/>
        <result column="pay_refund_id" property="payRefundId"/>
        <result column="refund_status" property="refundStatus"/>
        <result column="pay_type_name" property="payTypeName"/>
        <result column="refund_amount" property="refundAmount"/>
        <result column="order_total_amount" property="orderTotalAmount"/>
        <result column="user_id" property="userId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="version" property="version"/>
        <result column="refund_status" property="refundStatus"/>
    </resultMap>
    <update id="refundSuccess">
        UPDATE tz_refund_order_settlement
        SET pay_status = 2,is_clearing=1,clear_time=NOW(), version = version + 1
        WHERE  refund_pay_no=#{refundPayNo} AND version=#{version}
    </update>

    <update id="refundFail">
        UPDATE tz_refund_order_settlement
        SET pay_status = -1, version = version + 1
        WHERE  refund_pay_no=#{refundPayNo} and version=#{version}
    </update>

</mapper>
