<?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.pine.admin.modules.business.dao.OfflinePaymentsDao">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.pine.admin.modules.business.entity.OfflinePayments" id="entityMap">
        <result property="id" column="id"/>
        <result property="carOrderId" column="car_order_id"/>
        <result property="downPaymentStatus" column="down_payment_status"/>
        <result property="invoicePath" column="invoice_path"/>
        <result property="paytype" column="payType"/>
        <result property="tailStatus" column="tail_status"/>
        <result property="deliveryPath" column="delivery_path"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="Base_Column_List">
                 id,
                     car_order_id,
                     down_payment_status,
                     invoice_path,
                     payType,
                     tail_status,
                     delivery_path,
                     create_time,
                     update_time
                            </sql>
    <!-- 根据Id查询-->
    <select id="selectByPrimaryKey" resultMap="entityMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from ls_offline_payments
        where id = #{id}
    </select>

    <!-- 根据Id删除-->
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
		delete from ls_offline_payments
		where id = #{id}
	</delete>

    <!-- 插入数据-->
    <insert id="insertSelective" parameterType="com.pine.admin.modules.business.entity.OfflinePayments"
            useGeneratedKeys="true" keyProperty="id">
        insert into ls_offline_payments
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="carOrderId != null">car_order_id,</if>
            <if test="downPaymentStatus != null">down_payment_status,</if>
            <if test="invoicePath != null">invoice_path,</if>
            <if test="paytype != null">payType,</if>
            <if test="tailStatus != null">tail_status,</if>
            <if test="deliveryPath != null">delivery_path,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="carOrderId != null">#{carOrderId},</if>
            <if test="downPaymentStatus != null">#{downPaymentStatus},</if>
            <if test="invoicePath != null">#{invoicePath},</if>
            <if test="paytype != null">#{paytype},</if>
            <if test="tailStatus != null">#{tailStatus},</if>
            <if test="deliveryPath != null">#{deliveryPath},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <!-- 更新数据-->
    <update id="updateByPrimaryKeySelective"
            parameterType="com.pine.admin.modules.business.entity.OfflinePayments">
        update ls_offline_payments
        <set>
            <if test="id != null">id = #{id},</if>
            <if test="carOrderId != null">car_order_id = #{carOrderId},</if>
            <if test="downPaymentStatus != null">down_payment_status = #{downPaymentStatus},</if>
            <if test="invoicePath != null">invoice_path = #{invoicePath},</if>
            <if test="paytype != null">payType = #{paytype},</if>
            <if test="tailStatus != null">tail_status = #{tailStatus},</if>
            <if test="deliveryPath != null">delivery_path = #{deliveryPath},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <!-- 分页查询-->
    <select id="queryByPage" parameterType="java.util.Map"
            resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_offline_payments
        <where>

            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
                and id = #{record.id}
            </if>
            <if test="record.carOrderId != null and !&quot;&quot;.equals(record.carOrderId)">
                and car_order_id = #{record.carOrderId}
            </if>
            <if test="record.downPaymentStatus != null and !&quot;&quot;.equals(record.downPaymentStatus)">
                and down_payment_status = #{record.downPaymentStatus}
            </if>
            <if test="record.invoicePath != null and !&quot;&quot;.equals(record.invoicePath)">
                and invoice_path = #{record.invoicePath}
            </if>
            <if test="record.paytype != null and !&quot;&quot;.equals(record.paytype)">
                and payType = #{record.paytype}
            </if>
            <if test="record.tailStatus != null and !&quot;&quot;.equals(record.tailStatus)">
                and tail_status = #{record.tailStatus}
            </if>
            <if test="record.deliveryPath != null and !&quot;&quot;.equals(record.deliveryPath)">
                and delivery_path = #{record.deliveryPath}
            </if>
            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
                and create_time = #{record.createTime}
            </if>
            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
                and update_time = #{record.updateTime}
            </if>
        </where>
        order by id desc
    </select>

    <!-- 全部查询 -->
    <select id="queryAll" parameterType="java.util.Map"
            resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_offline_payments
        <where>
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="carOrderId != null and !&quot;&quot;.equals(carOrderId)">
                and car_order_id = #{carOrderId}
            </if>
            <if test="downPaymentStatus != null and !&quot;&quot;.equals(downPaymentStatus)">
                and down_payment_status = #{downPaymentStatus}
            </if>
            <if test="invoicePath != null and !&quot;&quot;.equals(invoicePath)">
                and invoice_path = #{invoicePath}
            </if>
            <if test="paytype != null and !&quot;&quot;.equals(paytype)">
                and payType = #{paytype}
            </if>
            <if test="tailStatus != null and !&quot;&quot;.equals(tailStatus)">
                and tail_status = #{tailStatus}
            </if>
            <if test="deliveryPath != null and !&quot;&quot;.equals(deliveryPath)">
                and delivery_path = #{deliveryPath}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
        </where>
        order by id desc
    </select>

    <!-- 根据条件查询一个 -->
    <select id="queryOne" parameterType="java.util.Map"
            resultMap="entityMap">
        select
        <include refid="Base_Column_List"/>
        from ls_offline_payments
        <where>
            <if test="id != null and !&quot;&quot;.equals(id)">
                and id = #{id}
            </if>
            <if test="carOrderId != null and !&quot;&quot;.equals(carOrderId)">
                and car_order_id = #{carOrderId}
            </if>
            <if test="downPaymentStatus != null and !&quot;&quot;.equals(downPaymentStatus)">
                and down_payment_status = #{downPaymentStatus}
            </if>
            <if test="invoicePath != null and !&quot;&quot;.equals(invoicePath)">
                and invoice_path = #{invoicePath}
            </if>
            <if test="paytype != null and !&quot;&quot;.equals(paytype)">
                and payType = #{paytype}
            </if>
            <if test="tailStatus != null and !&quot;&quot;.equals(tailStatus)">
                and tail_status = #{tailStatus}
            </if>
            <if test="deliveryPath != null and !&quot;&quot;.equals(deliveryPath)">
                and delivery_path = #{deliveryPath}
            </if>
            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
                and update_time = #{updateTime}
            </if>
        </where>
        LIMIT 1
    </select>

    <update id="delete">
        UPDATE ls_offline_payments SET del_flag = 'Y'
        <where>
            AND id = #{id}
        </where>
    </update>

    <update id="deleteIds" parameterType="java.util.ArrayList">
        UPDATE ls_offline_payments SET del_flag = 'Y'
        WHERE id IN
        <foreach item='ids' collection="array" index="index" open="(" separator="," close=")">
            #{ids}
        </foreach>
    </update>

</mapper>
