<?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.ms.dal.mapper.RefundPurchaseOrderMapper">

    <resultMap id="BaseResultMap" type="com.ms.dal.entity.RefundPurchaseOrder">
            <id property="refundPurchaseOrderId" column="refund_purchase_order_id" jdbcType="BIGINT"/>
            <result property="refundId" column="refund_id" jdbcType="VARCHAR"/>
            <result property="purOrderId" column="pur_order_id" jdbcType="VARCHAR"/>
            <result property="orderId" column="order_id" jdbcType="VARCHAR"/>
            <result property="shopId" column="shop_id" jdbcType="BIGINT"/>
            <result property="rejectReason" column="reject_reason" jdbcType="VARCHAR"/>
            <result property="onlyRefund" column="only_refund" jdbcType="TINYINT"/>
            <result property="refundGoods" column="refund_goods" jdbcType="TINYINT"/>
            <result property="goodsReceived" column="goods_received" jdbcType="TINYINT"/>
            <result property="goodsStatus" column="goods_status" jdbcType="TINYINT"/>
            <result property="sellerMobile" column="seller_mobile" jdbcType="VARCHAR"/>
            <result property="sellerTel" column="seller_tel" jdbcType="VARCHAR"/>
            <result property="sellerRealName" column="seller_real_name" jdbcType="VARCHAR"/>
            <result property="sellerReceiveAddress" column="seller_receive_address" jdbcType="VARCHAR"/>
            <result property="gmtTimeOut" column="gmt_time_out" jdbcType="TIMESTAMP"/>
            <result property="status" column="status" jdbcType="VARCHAR"/>
            <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
            <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        refund_purchase_order_id,refund_id,pur_order_id,
        order_id,shop_id,reject_reason,
        only_refund,refund_goods,goods_received,
        goods_status,seller_mobile,seller_tel,
        seller_real_name,seller_receive_address,gmt_time_out,
        status,gmt_create,gmt_modified
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from refund_purchase_order
        where  refund_purchase_order_id = #{refundPurchaseOrderId,jdbcType=BIGINT} 
    </select>
    <select id="getByRefundId" resultType="com.ms.dal.entity.RefundPurchaseOrder">
        select
        <include refid="Base_Column_List" />
        from refund_purchase_order
        where  refund_id = #{refundId,jdbcType=VARCHAR}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from refund_purchase_order
        where  refund_purchase_order_id = #{refundPurchaseOrderId,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="refund_purchase_order_id" keyProperty="refundPurchaseOrderId" parameterType="com.ms.dal.entity.RefundPurchaseOrder" useGeneratedKeys="true">
        insert into refund_purchase_order
        ( refund_purchase_order_id,refund_id,pur_order_id
        ,order_id,shop_id,reject_reason
        ,only_refund,refund_goods,goods_received
        ,goods_status,seller_mobile,seller_tel
        ,seller_real_name,seller_receive_address,gmt_time_out
        ,status,gmt_create,gmt_modified
        )
        values (#{refundPurchaseOrderId,jdbcType=BIGINT},#{refundId,jdbcType=VARCHAR},#{purOrderId,jdbcType=VARCHAR}
        ,#{orderId,jdbcType=VARCHAR},#{shopId,jdbcType=BIGINT},#{rejectReason,jdbcType=VARCHAR}
        ,#{onlyRefund,jdbcType=TINYINT},#{refundGoods,jdbcType=TINYINT},#{goodsReceived,jdbcType=TINYINT}
        ,#{goodsStatus,jdbcType=TINYINT},#{sellerMobile,jdbcType=VARCHAR},#{sellerTel,jdbcType=VARCHAR}
        ,#{sellerRealName,jdbcType=VARCHAR},#{sellerReceiveAddress,jdbcType=VARCHAR},#{gmtTimeOut,jdbcType=TIMESTAMP}
        ,#{status,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP}
        )
    </insert>
    <update id="insertOrUpdate"  keyColumn="refund_purchase_order_id" keyProperty="refundPurchaseOrderId" parameterType="com.ms.dal.entity.RefundPurchaseOrder"
        useGeneratedKeys="true">
        insert into refund_purchase_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="refundPurchaseOrderId != null">refund_purchase_order_id,</if>
                <if test="refundId != null">refund_id,</if>
                <if test="purOrderId != null">pur_order_id,</if>
                <if test="orderId != null">order_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="rejectReason != null">reject_reason,</if>
                <if test="onlyRefund != null">only_refund,</if>
                <if test="refundGoods != null">refund_goods,</if>
                <if test="goodsReceived != null">goods_received,</if>
                <if test="goodsStatus != null">goods_status,</if>
                <if test="sellerMobile != null">seller_mobile,</if>
                <if test="sellerTel != null">seller_tel,</if>
                <if test="sellerRealName != null">seller_real_name,</if>
                <if test="sellerReceiveAddress != null">seller_receive_address,</if>
                <if test="gmtTimeOut != null">gmt_time_out,</if>
                <if test="status != null">status,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="refundPurchaseOrderId != null">#{refundPurchaseOrderId,jdbcType=BIGINT},</if>
                <if test="refundId != null">#{refundId,jdbcType=VARCHAR},</if>
                <if test="purOrderId != null">#{purOrderId,jdbcType=VARCHAR},</if>
                <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="rejectReason != null">#{rejectReason,jdbcType=VARCHAR},</if>
                <if test="onlyRefund != null">#{onlyRefund,jdbcType=TINYINT},</if>
                <if test="refundGoods != null">#{refundGoods,jdbcType=TINYINT},</if>
                <if test="goodsReceived != null">#{goodsReceived,jdbcType=TINYINT},</if>
                <if test="goodsStatus != null">#{goodsStatus,jdbcType=TINYINT},</if>
                <if test="sellerMobile != null">#{sellerMobile,jdbcType=VARCHAR},</if>
                <if test="sellerTel != null">#{sellerTel,jdbcType=VARCHAR},</if>
                <if test="sellerRealName != null">#{sellerRealName,jdbcType=VARCHAR},</if>
                <if test="sellerReceiveAddress != null">#{sellerReceiveAddress,jdbcType=VARCHAR},</if>
                <if test="gmtTimeOut != null">#{gmtTimeOut,jdbcType=TIMESTAMP},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
        ON DUPLICATE KEY UPDATE
        <trim  suffixOverrides=",">
                <if test="refundId != null">
                    refund_id = #{refundId,jdbcType=VARCHAR},
                </if>
                <if test="purOrderId != null">
                    pur_order_id = #{purOrderId,jdbcType=VARCHAR},
                </if>
                <if test="orderId != null">
                    order_id = #{orderId,jdbcType=VARCHAR},
                </if>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="rejectReason != null">
                    reject_reason = #{rejectReason,jdbcType=VARCHAR},
                </if>
                <if test="onlyRefund != null">
                    only_refund = #{onlyRefund,jdbcType=TINYINT},
                </if>
                <if test="refundGoods != null">
                    refund_goods = #{refundGoods,jdbcType=TINYINT},
                </if>
                <if test="goodsReceived != null">
                    goods_received = #{goodsReceived,jdbcType=TINYINT},
                </if>
                <if test="goodsStatus != null">
                    goods_status = #{goodsStatus,jdbcType=TINYINT},
                </if>
                <if test="sellerMobile != null">
                    seller_mobile = #{sellerMobile,jdbcType=VARCHAR},
                </if>
                <if test="sellerTel != null">
                    seller_tel = #{sellerTel,jdbcType=VARCHAR},
                </if>
                <if test="sellerRealName != null">
                    seller_real_name = #{sellerRealName,jdbcType=VARCHAR},
                </if>
                <if test="sellerReceiveAddress != null">
                    seller_receive_address = #{sellerReceiveAddress,jdbcType=VARCHAR},
                </if>
                <if test="gmtTimeOut != null">
                    gmt_time_out = #{gmtTimeOut,jdbcType=TIMESTAMP},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </trim>
    </update>
    <insert id="insertSelective" keyColumn="refund_purchase_order_id" keyProperty="refundPurchaseOrderId" parameterType="com.ms.dal.entity.RefundPurchaseOrder" useGeneratedKeys="true">
        insert into refund_purchase_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="refundPurchaseOrderId != null">refund_purchase_order_id,</if>
                <if test="refundId != null">refund_id,</if>
                <if test="purOrderId != null">pur_order_id,</if>
                <if test="orderId != null">order_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="rejectReason != null">reject_reason,</if>
                <if test="onlyRefund != null">only_refund,</if>
                <if test="refundGoods != null">refund_goods,</if>
                <if test="goodsReceived != null">goods_received,</if>
                <if test="goodsStatus != null">goods_status,</if>
                <if test="sellerMobile != null">seller_mobile,</if>
                <if test="sellerTel != null">seller_tel,</if>
                <if test="sellerRealName != null">seller_real_name,</if>
                <if test="sellerReceiveAddress != null">seller_receive_address,</if>
                <if test="gmtTimeOut != null">gmt_time_out,</if>
                <if test="status != null">status,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="refundPurchaseOrderId != null">#{refundPurchaseOrderId,jdbcType=BIGINT},</if>
                <if test="refundId != null">#{refundId,jdbcType=VARCHAR},</if>
                <if test="purOrderId != null">#{purOrderId,jdbcType=VARCHAR},</if>
                <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="rejectReason != null">#{rejectReason,jdbcType=VARCHAR},</if>
                <if test="onlyRefund != null">#{onlyRefund,jdbcType=TINYINT},</if>
                <if test="refundGoods != null">#{refundGoods,jdbcType=TINYINT},</if>
                <if test="goodsReceived != null">#{goodsReceived,jdbcType=TINYINT},</if>
                <if test="goodsStatus != null">#{goodsStatus,jdbcType=TINYINT},</if>
                <if test="sellerMobile != null">#{sellerMobile,jdbcType=VARCHAR},</if>
                <if test="sellerTel != null">#{sellerTel,jdbcType=VARCHAR},</if>
                <if test="sellerRealName != null">#{sellerRealName,jdbcType=VARCHAR},</if>
                <if test="sellerReceiveAddress != null">#{sellerReceiveAddress,jdbcType=VARCHAR},</if>
                <if test="gmtTimeOut != null">#{gmtTimeOut,jdbcType=TIMESTAMP},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.RefundPurchaseOrder">
        update refund_purchase_order
        <set>
                <if test="refundId != null">
                    refund_id = #{refundId,jdbcType=VARCHAR},
                </if>
                <if test="purOrderId != null">
                    pur_order_id = #{purOrderId,jdbcType=VARCHAR},
                </if>
                <if test="orderId != null">
                    order_id = #{orderId,jdbcType=VARCHAR},
                </if>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="rejectReason != null">
                    reject_reason = #{rejectReason,jdbcType=VARCHAR},
                </if>
                <if test="onlyRefund != null">
                    only_refund = #{onlyRefund,jdbcType=TINYINT},
                </if>
                <if test="refundGoods != null">
                    refund_goods = #{refundGoods,jdbcType=TINYINT},
                </if>
                <if test="goodsReceived != null">
                    goods_received = #{goodsReceived,jdbcType=TINYINT},
                </if>
                <if test="goodsStatus != null">
                    goods_status = #{goodsStatus,jdbcType=TINYINT},
                </if>
                <if test="sellerMobile != null">
                    seller_mobile = #{sellerMobile,jdbcType=VARCHAR},
                </if>
                <if test="sellerTel != null">
                    seller_tel = #{sellerTel,jdbcType=VARCHAR},
                </if>
                <if test="sellerRealName != null">
                    seller_real_name = #{sellerRealName,jdbcType=VARCHAR},
                </if>
                <if test="sellerReceiveAddress != null">
                    seller_receive_address = #{sellerReceiveAddress,jdbcType=VARCHAR},
                </if>
                <if test="gmtTimeOut != null">
                    gmt_time_out = #{gmtTimeOut,jdbcType=TIMESTAMP},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   refund_purchase_order_id = #{refundPurchaseOrderId,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.RefundPurchaseOrder">
        update refund_purchase_order
        set 
            refund_id =  #{refundId,jdbcType=VARCHAR},
            pur_order_id =  #{purOrderId,jdbcType=VARCHAR},
            order_id =  #{orderId,jdbcType=VARCHAR},
            shop_id =  #{shopId,jdbcType=BIGINT},
            reject_reason =  #{rejectReason,jdbcType=VARCHAR},
            only_refund =  #{onlyRefund,jdbcType=TINYINT},
            refund_goods =  #{refundGoods,jdbcType=TINYINT},
            goods_received =  #{goodsReceived,jdbcType=TINYINT},
            goods_status =  #{goodsStatus,jdbcType=TINYINT},
            seller_mobile =  #{sellerMobile,jdbcType=VARCHAR},
            seller_tel =  #{sellerTel,jdbcType=VARCHAR},
            seller_real_name =  #{sellerRealName,jdbcType=VARCHAR},
            seller_receive_address =  #{sellerReceiveAddress,jdbcType=VARCHAR},
            gmt_time_out =  #{gmtTimeOut,jdbcType=TIMESTAMP},
            status =  #{status,jdbcType=VARCHAR},
            gmt_create =  #{gmtCreate,jdbcType=TIMESTAMP},
            gmt_modified =  #{gmtModified,jdbcType=TIMESTAMP}
        where   refund_purchase_order_id = #{refundPurchaseOrderId,jdbcType=BIGINT} 
    </update>
</mapper>
