<?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.mofangchuxing.aska.dao.mapper.NotifyRecordMapper">

    <resultMap id="BaseResultMap" type="com.mofangchuxing.aska.dao.domain.NotifyRecord">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="orderSn" column="order_sn" jdbcType="VARCHAR"/>
            <result property="mchId" column="mch_id" jdbcType="VARCHAR"/>
            <result property="openId" column="open_id" jdbcType="VARCHAR"/>
            <result property="totalFee" column="total_fee" jdbcType="VARCHAR"/>
            <result property="notifyUrl" column="notify_url" jdbcType="VARCHAR"/>
            <result property="notifyTimes" column="notify_times" jdbcType="INTEGER"/>
            <result property="status" column="status" jdbcType="INTEGER"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="modifiedTime" column="modified_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,order_sn,mch_id,
        open_id,total_fee,notify_url,
        notify_times,status,create_time,
        modified_time
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from notify_record
        where  id = #{id,jdbcType=INTEGER} 
    </select>
    <select id="selectByOrderSn" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from notify_record
        where order_sn = #{orderSn} limit 1
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from notify_record
        where  id = #{id,jdbcType=INTEGER} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.mofangchuxing.aska.dao.domain.NotifyRecord" useGeneratedKeys="true">
        insert into notify_record
        ( id,order_sn,mch_id
        ,open_id,total_fee,notify_url
        ,notify_times,status,create_time
        ,modified_time)
        values (#{id,jdbcType=INTEGER},#{orderSn,jdbcType=VARCHAR},#{mchId,jdbcType=VARCHAR}
        ,#{openId,jdbcType=VARCHAR},#{totalFee,jdbcType=VARCHAR},#{notifyUrl,jdbcType=VARCHAR}
        ,#{notifyTimes,jdbcType=INTEGER},#{status,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP}
        ,#{modifiedTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.mofangchuxing.aska.dao.domain.NotifyRecord" useGeneratedKeys="true">
        insert into notify_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="orderSn != null">order_sn,</if>
                <if test="mchId != null">mch_id,</if>
                <if test="openId != null">open_id,</if>
                <if test="totalFee != null">total_fee,</if>
                <if test="notifyUrl != null">notify_url,</if>
                <if test="notifyTimes != null">notify_times,</if>
                <if test="status != null">status,</if>
                <if test="createTime != null">create_time,</if>
                <if test="modifiedTime != null">modified_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=INTEGER},</if>
                <if test="orderSn != null">#{orderSn,jdbcType=VARCHAR},</if>
                <if test="mchId != null">#{mchId,jdbcType=VARCHAR},</if>
                <if test="openId != null">#{openId,jdbcType=VARCHAR},</if>
                <if test="totalFee != null">#{totalFee,jdbcType=VARCHAR},</if>
                <if test="notifyUrl != null">#{notifyUrl,jdbcType=VARCHAR},</if>
                <if test="notifyTimes != null">#{notifyTimes,jdbcType=INTEGER},</if>
                <if test="status != null">#{status,jdbcType=INTEGER},</if>
                <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
                <if test="modifiedTime != null">#{modifiedTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.mofangchuxing.aska.dao.domain.NotifyRecord">
        update notify_record
        <set>
                <if test="orderSn != null">
                    order_sn = #{orderSn,jdbcType=VARCHAR},
                </if>
                <if test="mchId != null">
                    mch_id = #{mchId,jdbcType=VARCHAR},
                </if>
                <if test="openId != null">
                    open_id = #{openId,jdbcType=VARCHAR},
                </if>
                <if test="totalFee != null">
                    total_fee = #{totalFee,jdbcType=VARCHAR},
                </if>
                <if test="notifyUrl != null">
                    notify_url = #{notifyUrl,jdbcType=VARCHAR},
                </if>
                <if test="notifyTimes != null">
                    notify_times = #{notifyTimes,jdbcType=INTEGER},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=INTEGER},
                </if>
                <if test="createTime != null">
                    create_time = #{createTime,jdbcType=TIMESTAMP},
                </if>
                <if test="modifiedTime != null">
                    modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   id = #{id,jdbcType=INTEGER} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.mofangchuxing.aska.dao.domain.NotifyRecord">
        update notify_record
        set 
            order_sn =  #{orderSn,jdbcType=VARCHAR},
            mch_id =  #{mchId,jdbcType=VARCHAR},
            open_id =  #{openId,jdbcType=VARCHAR},
            total_fee =  #{totalFee,jdbcType=VARCHAR},
            notify_url =  #{notifyUrl,jdbcType=VARCHAR},
            notify_times =  #{notifyTimes,jdbcType=INTEGER},
            status =  #{status,jdbcType=INTEGER},
            create_time =  #{createTime,jdbcType=TIMESTAMP},
            modified_time =  #{modifiedTime,jdbcType=TIMESTAMP}
        where   id = #{id,jdbcType=INTEGER} 
    </update>
</mapper>