<?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.jsowell.pile.mapper.OrderPileOccupyMapper">
    <resultMap id="BaseResultMap" type="com.jsowell.pile.domain.OrderPileOccupy">
        <!--@mbg.generated-->
        <!--@Table order_pile_occupy-->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="occupy_code" jdbcType="VARCHAR" property="occupyCode"/>
        <result column="status" jdbcType="CHAR" property="status"/>
        <result column="member_id" jdbcType="VARCHAR" property="memberId"/>
        <result column="station_id" jdbcType="VARCHAR" property="stationId"/>
        <result column="plate_number" jdbcType="VARCHAR" property="plateNumber"/>
        <result column="order_code" jdbcType="VARCHAR" property="orderCode"/>
        <result column="transaction_code" jdbcType="VARCHAR" property="transactionCode"/>
        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <result column="pay_status" jdbcType="VARCHAR" property="payStatus"/>
        <result column="order_amount" jdbcType="DECIMAL" property="orderAmount"/>
        <result column="pile_sn" jdbcType="VARCHAR" property="pileSn"/>
        <result column="connector_code" jdbcType="VARCHAR" property="connectorCode"/>
        <result column="pile_connector_code" jdbcType="VARCHAR" property="pileConnectorCode"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
        <result column="del_flag" jdbcType="CHAR" property="delFlag"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id,
        occupy_code,
        `status`,
        member_id,
        station_id,
        plate_number,
        order_code,
        transaction_code,
        start_time,
        end_time,
        pay_status,
        order_amount,
        pile_sn,
        connector_code,
        pile_connector_code,
        create_time,
        create_by,
        update_time,
        update_by,
        del_flag
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from order_pile_occupy
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--@mbg.generated-->
        delete
        from order_pile_occupy
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderPileOccupy"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into order_pile_occupy (occupy_code, `status`, member_id,
                                       station_id, plate_number, order_code, transaction_code,
                                       start_time, end_time, pay_status,
                                       order_amount, pile_sn, connector_code,
                                       pile_connector_code, create_time, create_by,
                                       update_time, update_by, del_flag)
        values (#{occupyCode,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, #{memberId,jdbcType=VARCHAR},
                #{stationId,jdbcType=VARCHAR}, #{plateNumber,jdbcType=VARCHAR}, #{orderCode,jdbcType=VARCHAR}, #{transactionCode,jdbcType=VARCHAR},
                #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{payStatus,jdbcType=VARCHAR},
                #{orderAmount,jdbcType=DECIMAL}, #{pileSn,jdbcType=VARCHAR}, #{connectorCode,jdbcType=VARCHAR},
                #{pileConnectorCode,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR},
                #{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{delFlag,jdbcType=CHAR})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderPileOccupy"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into order_pile_occupy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="occupyCode != null">
                occupy_code,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="memberId != null">
                member_id,
            </if>
            <if test="stationId != null">
                station_id,
            </if>
            <if test="plateNumber != null">
                plate_number,
            </if>
            <if test="orderCode != null">
                order_code,
            </if>
            <if test="transactionCode != null">
                transaction_code,
            </if>
            <if test="startTime != null">
                start_time,
            </if>
            <if test="endTime != null">
                end_time,
            </if>
            <if test="payStatus != null">
                pay_status,
            </if>
            <if test="orderAmount != null">
                order_amount,
            </if>
            <if test="pileSn != null">
                pile_sn,
            </if>
            <if test="connectorCode != null">
                connector_code,
            </if>
            <if test="pileConnectorCode != null">
                pile_connector_code,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createBy != null">
                create_by,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="updateBy != null">
                update_by,
            </if>
            <if test="delFlag != null">
                del_flag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="occupyCode != null">
                #{occupyCode,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=CHAR},
            </if>
            <if test="memberId != null">
                #{memberId,jdbcType=VARCHAR},
            </if>
            <if test="stationId != null">
                #{stationId,jdbcType=VARCHAR},
            </if>
            <if test="plateNumber != null">
                #{plateNumber,jdbcType=VARCHAR},
            </if>
            <if test="orderCode != null">
                #{orderCode,jdbcType=VARCHAR},
            </if>
            <if test="transactionCode != null">
                #{transactionCode,jdbcType=VARCHAR},
            </if>
            <if test="startTime != null">
                #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="payStatus != null">
                #{payStatus,jdbcType=VARCHAR},
            </if>
            <if test="orderAmount != null">
                #{orderAmount,jdbcType=DECIMAL},
            </if>
            <if test="pileSn != null">
                #{pileSn,jdbcType=VARCHAR},
            </if>
            <if test="connectorCode != null">
                #{connectorCode,jdbcType=VARCHAR},
            </if>
            <if test="pileConnectorCode != null">
                #{pileConnectorCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.OrderPileOccupy">
        <!--@mbg.generated-->
        update order_pile_occupy
        <set>
            <if test="occupyCode != null">
                occupy_code = #{occupyCode,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=CHAR},
            </if>
            <if test="memberId != null">
                member_id = #{memberId,jdbcType=VARCHAR},
            </if>
            <if test="stationId != null">
                station_id = #{stationId,jdbcType=VARCHAR},
            </if>
            <if test="plateNumber != null">
                plate_number = #{plateNumber,jdbcType=VARCHAR},
            </if>
            <if test="orderCode != null">
                order_code = #{orderCode,jdbcType=VARCHAR},
            </if>
            <if test="transactionCode != null">
                transaction_code = #{transactionCode,jdbcType=VARCHAR},
            </if>
            <if test="startTime != null">
                start_time = #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                end_time = #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="payStatus != null">
                pay_status = #{payStatus,jdbcType=VARCHAR},
            </if>
            <if test="orderAmount != null">
                order_amount = #{orderAmount,jdbcType=DECIMAL},
            </if>
            <if test="pileSn != null">
                pile_sn = #{pileSn,jdbcType=VARCHAR},
            </if>
            <if test="connectorCode != null">
                connector_code = #{connectorCode,jdbcType=VARCHAR},
            </if>
            <if test="pileConnectorCode != null">
                pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                create_by = #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                update_by = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag,jdbcType=CHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.jsowell.pile.domain.OrderPileOccupy">
        <!--@mbg.generated-->
        update order_pile_occupy
        set occupy_code         = #{occupyCode,jdbcType=VARCHAR},
            `status`            = #{status,jdbcType=CHAR},
            member_id           = #{memberId,jdbcType=VARCHAR},
            station_id          = #{stationId,jdbcType=VARCHAR},
            plate_number        = #{plateNumber,jdbcType=VARCHAR},
            order_code          = #{orderCode,jdbcType=VARCHAR},
            transaction_code    = #{transactionCode,jdbcType=VARCHAR},
            start_time          = #{startTime,jdbcType=TIMESTAMP},
            end_time            = #{endTime,jdbcType=TIMESTAMP},
            pay_status          = #{payStatus,jdbcType=VARCHAR},
            order_amount        = #{orderAmount,jdbcType=DECIMAL},
            pile_sn             = #{pileSn,jdbcType=VARCHAR},
            connector_code      = #{connectorCode,jdbcType=VARCHAR},
            pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
            create_time         = #{createTime,jdbcType=TIMESTAMP},
            create_by           = #{createBy,jdbcType=VARCHAR},
            update_time         = #{updateTime,jdbcType=TIMESTAMP},
            update_by           = #{updateBy,jdbcType=VARCHAR},
            del_flag            = #{delFlag,jdbcType=CHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update order_pile_occupy
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="occupy_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.occupyCode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="`status` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=CHAR}
                </foreach>
            </trim>
            <trim prefix="member_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.memberId,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="station_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.stationId,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="plate_number = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.plateNumber,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="order_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.orderCode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="transaction_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.transactionCode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="start_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
            <trim prefix="end_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
            <trim prefix="pay_status = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.payStatus,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="order_amount = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.orderAmount,jdbcType=DECIMAL}
                </foreach>
            </trim>
            <trim prefix="pile_sn = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.pileSn,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="connector_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.connectorCode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="pile_connector_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.pileConnectorCode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="create_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
            <trim prefix="create_by = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="update_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
            <trim prefix="update_by = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="del_flag = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.delFlag,jdbcType=CHAR}
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>
    <update id="updateBatchSelective" parameterType="java.util.List">
        <!--@mbg.generated-->
        update order_pile_occupy
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="occupy_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.occupyCode != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.occupyCode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="`status` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.status != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.status,jdbcType=CHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="member_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.memberId != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.memberId,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="station_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.stationId != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.stationId,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="plate_number = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.plateNumber != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.plateNumber,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="order_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.orderCode != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.orderCode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="transaction_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.transactionCode != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.transactionCode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="start_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.startTime != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.startTime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
            <trim prefix="end_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.endTime != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.endTime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
            <trim prefix="pay_status = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.payStatus != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.payStatus,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="order_amount = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.orderAmount != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.orderAmount,jdbcType=DECIMAL}
                    </if>
                </foreach>
            </trim>
            <trim prefix="pile_sn = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.pileSn != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.pileSn,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="connector_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.connectorCode != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.connectorCode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="pile_connector_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.pileConnectorCode != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.pileConnectorCode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="create_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.createTime != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
            <trim prefix="create_by = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.createBy != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="update_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.updateTime != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.updateTime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
            <trim prefix="update_by = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.updateBy != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.updateBy,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="del_flag = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.delFlag != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.delFlag,jdbcType=CHAR}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>
    <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into order_pile_occupy
        (occupy_code, `status`, member_id, station_id, plate_number, order_code, transaction_code, start_time,
         end_time, pay_status, order_amount, pile_sn, connector_code, pile_connector_code,
         create_time, create_by, update_time, update_by, del_flag)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.occupyCode,jdbcType=VARCHAR}, #{item.status,jdbcType=CHAR}, #{item.memberId,jdbcType=VARCHAR},
             #{item.stationId,jdbcType=VARCHAR}, #{item.plateNumber,jdbcType=VARCHAR}, #{item.orderCode,jdbcType=VARCHAR},
             #{item.transactionCode,jdbcType=VARCHAR},
             #{item.startTime,jdbcType=TIMESTAMP}, #{item.endTime,jdbcType=TIMESTAMP},
             #{item.payStatus,jdbcType=VARCHAR},
             #{item.orderAmount,jdbcType=DECIMAL}, #{item.pileSn,jdbcType=VARCHAR},
             #{item.connectorCode,jdbcType=VARCHAR},
             #{item.pileConnectorCode,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP},
             #{item.createBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP},
             #{item.updateBy,jdbcType=VARCHAR},
             #{item.delFlag,jdbcType=CHAR})
        </foreach>
    </insert>
    <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderPileOccupy"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into order_pile_occupy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            occupy_code,
            `status`,
            member_id,
            station_id,
            plate_number,
            order_code,
            transaction_code,
            start_time,
            end_time,
            pay_status,
            order_amount,
            pile_sn,
            connector_code,
            pile_connector_code,
            create_time,
            create_by,
            update_time,
            update_by,
            del_flag,
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            #{occupyCode,jdbcType=VARCHAR},
            #{status,jdbcType=CHAR},
            #{memberId,jdbcType=VARCHAR},
            #{stationId,jdbcType=VARCHAR},
            #{plateNumber,jdbcType=VARCHAR},
            #{orderCode,jdbcType=VARCHAR},
            #{transactionCode,jdbcType=VARCHAR},
            #{startTime,jdbcType=TIMESTAMP},
            #{endTime,jdbcType=TIMESTAMP},
            #{payStatus,jdbcType=VARCHAR},
            #{orderAmount,jdbcType=DECIMAL},
            #{pileSn,jdbcType=VARCHAR},
            #{connectorCode,jdbcType=VARCHAR},
            #{pileConnectorCode,jdbcType=VARCHAR},
            #{createTime,jdbcType=TIMESTAMP},
            #{createBy,jdbcType=VARCHAR},
            #{updateTime,jdbcType=TIMESTAMP},
            #{updateBy,jdbcType=VARCHAR},
            #{delFlag,jdbcType=CHAR},
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            occupy_code         = #{occupyCode,jdbcType=VARCHAR},
            `status`            = #{status,jdbcType=CHAR},
            member_id           = #{memberId,jdbcType=VARCHAR},
            station_id          = #{stationId,jdbcType=VARCHAR},
            plate_number        = #{plateNumber,jdbcType=VARCHAR},
            order_code          = #{orderCode,jdbcType=VARCHAR},
            transaction_code    = #{transactionCode,jdbcType=VARCHAR},
            start_time          = #{startTime,jdbcType=TIMESTAMP},
            end_time            = #{endTime,jdbcType=TIMESTAMP},
            pay_status          = #{payStatus,jdbcType=VARCHAR},
            order_amount        = #{orderAmount,jdbcType=DECIMAL},
            pile_sn             = #{pileSn,jdbcType=VARCHAR},
            connector_code      = #{connectorCode,jdbcType=VARCHAR},
            pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
            create_time         = #{createTime,jdbcType=TIMESTAMP},
            create_by           = #{createBy,jdbcType=VARCHAR},
            update_time         = #{updateTime,jdbcType=TIMESTAMP},
            update_by           = #{updateBy,jdbcType=VARCHAR},
            del_flag            = #{delFlag,jdbcType=CHAR},
        </trim>
    </insert>
    <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
            parameterType="com.jsowell.pile.domain.OrderPileOccupy" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into order_pile_occupy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="occupyCode != null">
                occupy_code,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="memberId != null">
                member_id,
            </if>
            <if test="stationId != null">
                station_id,
            </if>
            <if test="plateNumber != null">
                plate_number,
            </if>
            <if test="orderCode != null">
                order_code,
            </if>
            <if test="transactionCode != null">
                transaction_code,
            </if>
            <if test="startTime != null">
                start_time,
            </if>
            <if test="endTime != null">
                end_time,
            </if>
            <if test="payStatus != null">
                pay_status,
            </if>
            <if test="orderAmount != null">
                order_amount,
            </if>
            <if test="pileSn != null">
                pile_sn,
            </if>
            <if test="connectorCode != null">
                connector_code,
            </if>
            <if test="pileConnectorCode != null">
                pile_connector_code,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createBy != null">
                create_by,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="updateBy != null">
                update_by,
            </if>
            <if test="delFlag != null">
                del_flag,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="occupyCode != null">
                #{occupyCode,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=CHAR},
            </if>
            <if test="memberId != null">
                #{memberId,jdbcType=VARCHAR},
            </if>
            <if test="stationId != null">
                #{stationId,jdbcType=VARCHAR},
            </if>
            <if test="plateNumber != null">
                #{plateNumber,jdbcType=VARCHAR},
            </if>
            <if test="orderCode != null">
                #{orderCode,jdbcType=VARCHAR},
            </if>
            <if test="transactionCode != null">
                #{transactionCode,jdbcType=VARCHAR},
            </if>
            <if test="startTime != null">
                #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="payStatus != null">
                #{payStatus,jdbcType=VARCHAR},
            </if>
            <if test="orderAmount != null">
                #{orderAmount,jdbcType=DECIMAL},
            </if>
            <if test="pileSn != null">
                #{pileSn,jdbcType=VARCHAR},
            </if>
            <if test="connectorCode != null">
                #{connectorCode,jdbcType=VARCHAR},
            </if>
            <if test="pileConnectorCode != null">
                #{pileConnectorCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=CHAR},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="occupyCode != null">
                occupy_code = #{occupyCode,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=CHAR},
            </if>
            <if test="memberId != null">
                member_id = #{memberId,jdbcType=VARCHAR},
            </if>
            <if test="stationId != null">
                station_id = #{stationId,jdbcType=VARCHAR},
            </if>
            <if test="plateNumber != null">
                plate_number = #{plateNumber,jdbcType=VARCHAR},
            </if>
            <if test="orderCode != null">
                order_code = #{orderCode,jdbcType=VARCHAR},
            </if>
            <if test="transactionCode != null">
                transaction_code = #{transactionCode,jdbcType=VARCHAR},
            </if>
            <if test="startTime != null">
                start_time = #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                end_time = #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="payStatus != null">
                pay_status = #{payStatus,jdbcType=VARCHAR},
            </if>
            <if test="orderAmount != null">
                order_amount = #{orderAmount,jdbcType=DECIMAL},
            </if>
            <if test="pileSn != null">
                pile_sn = #{pileSn,jdbcType=VARCHAR},
            </if>
            <if test="connectorCode != null">
                connector_code = #{connectorCode,jdbcType=VARCHAR},
            </if>
            <if test="pileConnectorCode != null">
                pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                create_by = #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                update_by = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag,jdbcType=CHAR},
            </if>
        </trim>
    </insert>

    <select id="queryByOccupyCode" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_pile_occupy
        where del_flag = '0'
          and occupy_code = #{occupyCode,jdbcType=VARCHAR}
    </select>

    <select id="queryOccupyOrderList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_pile_occupy
        where del_flag = '0'
        <if test="dto.memberId != null and dto.memberId != ''">
            and member_id = #{dto.memberId,jdbcType=VARCHAR}
        </if>
        <if test="dto.pileConnectorCode != null and dto.pileConnectorCode != ''">
            and pile_connector_code = #{dto.pileConnectorCode,jdbcType=VARCHAR}
        </if>
        <if test="dto.pileSn != null and dto.pileSn != ''">
            and pile_sn = #{dto.pileSn,jdbcType=VARCHAR}
        </if>
        <if test="dto.plateNumber != null and dto.plateNumber != ''">
            and plate_number = #{dto.plateNumber,jdbcType=VARCHAR}
        </if>
        <if test="dto.orderStatus != null and dto.orderStatus != ''">
            and status = #{dto.orderStatus,jdbcType=VARCHAR}
        </if>
        order by create_time DESC
    </select>

    <select id="queryHangUpOrderByMemberId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_pile_occupy
        where del_flag = '0'
          and status = '2'
          and member_id = #{memberId,jdbcType=VARCHAR}
    </select>



    <select id="queryOccupiedOrder" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from order_pile_occupy
        where del_flag = '0'
        and status = '0'
        and pile_sn = #{pileSn,jdbcType=VARCHAR}
        and connector_code = #{connectorCode,jdbcType=VARCHAR}
        order by create_time DESC
    </select>

    <select id="queryDraftOccupyOrder" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        order_pile_occupy
        where del_flag = '0'
        and status = '9'
        and pile_sn = #{pileSn,jdbcType=VARCHAR}
        and connector_code = #{connectorCode,jdbcType=VARCHAR}
        order by create_time DESC
    </select>

    <select id="getOccupyOrderDetail" resultType="com.jsowell.pile.vo.uniapp.customer.OccupyOrderDetailVO">
        SELECT
            t1.occupy_code AS occupyCode,
            t1.STATUS AS orderStatus,
            t1.station_id AS stationId,
            t2.station_name AS stationName,
            t2.merchant_id AS merchantId,
            t3.merchant_name AS merchantName,
            t1.start_time AS startTime,
            t1.end_time AS endTime,
            t1.pay_status AS payStatus,
            t1.order_amount AS orderAmount
        FROM
            order_pile_occupy t1
                LEFT JOIN pile_station_info t2 ON t1.station_id = t2.id
                LEFT JOIN pile_merchant_info t3 ON t2.merchant_id = t3.id
        WHERE
            t1.occupy_code = #{occupyCode,jdbcType=VARCHAR}
    </select>

    <select id="getOccupyOrderInfo" resultType="com.jsowell.pile.vo.uniapp.customer.OrderPileOccupyVO">
        select
        t1.occupy_code as occupyCode,
        t1.status,
        t1.station_id as stationId,
        t2.station_name as stationName,
        t1.start_time as startTime,
        t1.end_time as endTime,
        t1.pay_status as payStatus,
        t1.order_amount as orderAmount
        from
        order_pile_occupy t1
        left join pile_station_info t2 on t1.station_id = t2.id
        where
        t1.member_id = #{memberId,jdbcType=VARCHAR}
        and status != '9'
        order by t1.create_time desc
    </select>

    <select id="queryUnPayOrderByMemberId" resultMap="BaseResultMap">
        select
            <include refid="Base_Column_List"/>
        from
            order_pile_occupy
        where
            del_flag = '0'
        and
            pay_status = '0'
        and status = '2'
        and member_id = #{memberId,jdbcType=VARCHAR}
        order by create_time desc
        limit 1
    </select>

    <select id="selectOrderPileOccupyList" parameterType="com.jsowell.pile.domain.OrderPileOccupy" resultMap="BaseResultMap">
        select
            <include refid="Base_Column_List"/>
        from order_pile_occupy
        <where>
            <if test="occupyCode != null  and occupyCode != ''"> and occupy_code = #{occupyCode}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="memberId != null  and memberId != ''"> and member_id = #{memberId}</if>
            <if test="stationId != null  and stationId != ''"> and station_id = #{stationId}</if>
            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
            <if test="transactionCode != null  and transactionCode != ''"> and transaction_code = #{transactionCode}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="payStatus != null  and payStatus != ''"> and pay_status = #{payStatus}</if>
            <if test="orderAmount != null "> and order_amount = #{orderAmount}</if>
            <if test="pileSn != null  and pileSn != ''"> and pile_sn = #{pileSn}</if>
            <if test="connectorCode != null  and connectorCode != ''"> and connector_code = #{connectorCode}</if>
            <if test="pileConnectorCode != null  and pileConnectorCode != ''"> and pile_connector_code = #{pileConnectorCode}</if>
        </where>
    </select>

    <update id="makeOrderFree">
        update
            order_pile_occupy
        set
            status = '1', pay_status = '2'
        where occupy_code = #{occupyCode,jdbcType=VARCHAR}
    </update>

    <select id="getOrderPileOccupyList" resultType="com.jsowell.pile.vo.web.OccupyOrderVO">
        SELECT
            t1.id,
            t1.occupy_code AS occupyCode,
            t1.STATUS,
            t1.member_id AS memberId,
            t1.station_id AS stationId,
            t1.plate_number as plateNumber,
            t2.station_name AS stationName,
            t1.start_time AS startTime,
            t1.end_time AS endTime,
            t1.pay_status AS payStatus,
            t1.order_amount AS orderAmount,
            t1.pile_sn AS pileSn,
            t1.connector_code AS connectorCode
        FROM
            order_pile_occupy t1
                JOIN pile_station_info t2 ON t1.station_id = t2.id
                AND t1.del_flag = '0'
                JOIN pile_merchant_info t3 on t2.merchant_id = t3.id and t2.del_flag = '0'
        <where>
            <!-- 数据范围过滤 -->
            <if test="dto.merchantDeptIds != null and dto.merchantDeptIds.size() != 0">
                and t3.dept_id in
                <foreach collection="dto.merchantDeptIds" item="merchantDeptId" open="(" separator="," close=")">
                    #{merchantDeptId}
                </foreach>
            </if>
            <if test="dto.stationDeptIds != null and dto.stationDeptIds.size() != 0">
                and t2.dept_id in
                <foreach collection="dto.stationDeptIds" item="stationDeptId" open="(" separator="," close=")">
                    #{stationDeptId}
                </foreach>
            </if>
            <if test="dto.occupyCode != null  and dto.occupyCode != ''"> and t1.occupy_code = #{dto.occupyCode}</if>
            <if test="dto.memberId != null  and dto.memberId != ''"> and t1.member_id = #{dto.memberId}</if>
            <if test="dto.stationId != null  and dto.stationId != ''"> and t1.station_id = #{dto.stationId}</if>
            <if test="dto.plateNumber != null  and dto.plateNumber != ''"> and t1.plate_number = #{dto.plateNumber}</if>
            <if test="dto.status != null  and dto.status != ''"> and t1.status = #{dto.status}</if>
            <if test="dto.startTime != null "> and t1.start_time = #{dto.startTime}</if>
            <if test="dto.orderAmount != null "> and t1.order_amount = #{dto.orderAmount}</if>
            <if test="dto.pileSn != null  and dto.pileSn != ''"> and t1.pile_sn = #{dto.pileSn}</if>
            <if test="dto.pileConnectorCode != null  and dto.pileConnectorCode != ''"> and t1.pile_connector_code = #{dto.pileConnectorCode}</if>
        </where>
        order by t1.create_time desc
    </select>
</mapper>