<?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.PaymentMapper">
    <insert id="addGetId" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
        INSERT INTO payment(member_id,order_id,pay_price,create_time)
        VALUES (#{memberId},#{orderId},#{payPrice},now())
    </insert>
    <update id="setPaid">
        UPDATE payment SET pay_time = now() WHERE id = #{id}
    </update>
    <update id="setOutTradeNo">
        UPDATE payment SET out_order_no = #{outOrderNo} WHERE id = #{id}
    </update>
    <update id="update">
        UPDATE payment
        <set>
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="outOrderNo != null">out_order_no = #{outOrderNo},</if>
            <if test="payPrice != null">pay_price = #{payPrice},</if>
        </set>
        WHERE id = #{id}
    </update>
    <select id="findByOutTradeNo" resultType="com.ycwl.basic.model.pc.payment.entity.PaymentEntity">
        SELECT * FROM payment WHERE out_order_no = #{outOrderNo}
    </select>
</mapper>