<?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.younike.system.mapper.OrderPaymentMapper">

    <resultMap type="OrderPayment" id="OrderPaymentResult">
        <result property="orderId"    column="order_id"    />
        <result property="wxPayStr"    column="wx_pay_str"    />
        <result property="wxAddPayStr"    column="wx_add_pay_str"    />
        <result property="aliAddPayStr"    column="ali_add_pay_str"    />
        <result property="aliPayStr"    column="ali_pay_str"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="column1"    column="column1"    />
        <result property="column2"    column="column2"    />
        <result property="column3"    column="column3"    />
        <result property="addCountIndex"    column="add_count_index"    />

    </resultMap>

    <sql id="selectOrderPaymentVo">
        select order_id, wx_pay_str, wx_add_pay_str, ali_add_pay_str, ali_pay_str, create_by, create_time, update_by, update_time, column1, column2, column3,add_count_index from order_payment
    </sql>

    <select id="selectOrderPaymentList" parameterType="OrderPayment" resultMap="OrderPaymentResult">
        <include refid="selectOrderPaymentVo"/>
        <where>
            <if test="wxPayStr != null  and wxPayStr != ''"> and wx_pay_str = #{wxPayStr}</if>
            <if test="wxAddPayStr != null  and wxAddPayStr != ''"> and wx_add_pay_str = #{wxAddPayStr}</if>
            <if test="aliAddPayStr != null  and aliAddPayStr != ''"> and ali_add_pay_str = #{aliAddPayStr}</if>
            <if test="aliPayStr != null  and aliPayStr != ''"> and ali_pay_str = #{aliPayStr}</if>
            <if test="column1 != null  and column1 != ''"> and column1 = #{column1}</if>
            <if test="column2 != null  and column2 != ''"> and column2 = #{column2}</if>
            <if test="column3 != null  and column3 != ''"> and column3 = #{column3}</if>
            <if test="addCountIndex != null  and addCountIndex != ''"> and add_count_index = #{addCountIndex}</if>

        </where>
    </select>

    <select id="selectOrderPaymentByOrderId" parameterType="Long" resultMap="OrderPaymentResult">
        <include refid="selectOrderPaymentVo"/>
        where order_id = #{orderId}
    </select>

    <insert id="insertOrderPayment" parameterType="OrderPayment">
        insert into order_payment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="wxPayStr != null">wx_pay_str,</if>
            <if test="wxAddPayStr != null">wx_add_pay_str,</if>
            <if test="aliAddPayStr != null">ali_add_pay_str,</if>
            <if test="aliPayStr != null">ali_pay_str,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="column1 != null">column1,</if>
            <if test="column2 != null">column2,</if>
            <if test="column3 != null">column3,</if>
            <if test="addCountIndex != null">add_count_index,</if>

         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="wxPayStr != null">#{wxPayStr},</if>
            <if test="wxAddPayStr != null">#{wxAddPayStr},</if>
            <if test="aliAddPayStr != null">#{aliAddPayStr},</if>
            <if test="aliPayStr != null">#{aliPayStr},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="column1 != null">#{column1},</if>
            <if test="column2 != null">#{column2},</if>
            <if test="column3 != null">#{column3},</if>
            <if test="addCountIndex != null">#{addCountIndex},</if>

         </trim>
    </insert>

    <update id="updateOrderPayment" parameterType="OrderPayment">
        update order_payment
        <trim prefix="SET" suffixOverrides=",">
            <if test="wxPayStr != null">wx_pay_str = #{wxPayStr},</if>
            <if test="wxAddPayStr != null">wx_add_pay_str = #{wxAddPayStr},</if>
            <if test="aliAddPayStr != null">ali_add_pay_str = #{aliAddPayStr},</if>
            <if test="aliPayStr != null">ali_pay_str = #{aliPayStr},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="column1 != null">column1 = #{column1},</if>
            <if test="column2 != null">column2 = #{column2},</if>
            <if test="column3 != null">column3 = #{column3},</if>
            <if test="addCountIndex != null">add_count_index = #{addCountIndex},</if>
        </trim>
        where order_id = #{orderId}
    </update>

    <delete id="deleteOrderPaymentByOrderId" parameterType="Long">
        delete from order_payment where order_id = #{orderId}
    </delete>

    <delete id="deleteOrderPaymentByOrderIds" parameterType="String">
        delete from order_payment where order_id in
        <foreach item="orderId" collection="array" open="(" separator="," close=")">
            #{orderId}
        </foreach>
    </delete>
</mapper>
