<?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.OrderBasicInfoMapper">
  <resultMap id="BaseResultMap" type="com.jsowell.pile.domain.OrderBasicInfo">
    <!--@mbg.generated-->
    <!--@Table order_basic_info-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="order_code" jdbcType="VARCHAR" property="orderCode" />
    <result column="transaction_code" jdbcType="VARCHAR" property="transactionCode" />
    <result column="order_status" jdbcType="VARCHAR" property="orderStatus" />
    <result column="member_id" jdbcType="VARCHAR" property="memberId" />
    <result column="station_id" jdbcType="VARCHAR" property="stationId" />
    <result column="merchant_id" jdbcType="VARCHAR" property="merchantId" />
    <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="logic_card" jdbcType="VARCHAR" property="logicCard" />
    <result column="vin_code" jdbcType="VARCHAR" property="vinCode" />
    <result column="start_mode" jdbcType="VARCHAR" property="startMode" />
    <result column="third_party_type" jdbcType="VARCHAR" property="thirdPartyType" />
    <result column="pay_mode" jdbcType="VARCHAR" property="payMode" />
    <result column="pay_status" jdbcType="VARCHAR" property="payStatus" />
    <result column="pay_amount" jdbcType="DECIMAL" property="payAmount" />
    <result column="pay_time" jdbcType="TIMESTAMP" property="payTime" />
    <result column="plate_number" jdbcType="VARCHAR" property="plateNumber" />
    <result column="order_amount" jdbcType="DECIMAL" property="orderAmount" />
    <result column="virtual_amount" jdbcType="DECIMAL" property="virtualAmount" />
    <result column="group_code" jdbcType="VARCHAR" property="groupCode" />
    <result column="discount_amount" jdbcType="DECIMAL" property="discountAmount" />
    <result column="settle_amount" jdbcType="DECIMAL" property="settleAmount" />
    <result column="remedial_amount" jdbcType="DECIMAL" property="remedialAmount" />
    <result column="charge_start_time" jdbcType="TIMESTAMP" property="chargeStartTime" />
    <result column="charge_end_time" jdbcType="TIMESTAMP" property="chargeEndTime" />
    <result column="start_type" jdbcType="VARCHAR" property="startType" />
    <result column="reserved_start_time" jdbcType="TIMESTAMP" property="reservedStartTime" />
    <result column="reserved_end_time" jdbcType="TIMESTAMP" property="reservedEndTime" />
    <result column="start_soc" jdbcType="VARCHAR" property="startSoc" />
    <result column="end_soc" jdbcType="VARCHAR" property="endSoc" />
    <result column="reason" jdbcType="VARCHAR" property="reason" />
    <result column="settlement_time" jdbcType="TIMESTAMP" property="settlementTime" />
    <result column="refund_amount" jdbcType="DECIMAL" property="refundAmount" />
    <result column="refund_status" jdbcType="VARCHAR" property="refundStatus" />
    <result column="create_by" jdbcType="VARCHAR" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="del_flag" jdbcType="CHAR" property="delFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, order_code, transaction_code, order_status, member_id, station_id, merchant_id, 
    pile_sn, connector_code, pile_connector_code, logic_card, vin_code, start_mode, third_party_type, 
    pay_mode, pay_status, pay_amount, pay_time, plate_number, order_amount, virtual_amount, 
    group_code, discount_amount, settle_amount, remedial_amount, charge_start_time, charge_end_time, 
    start_type, reserved_start_time, reserved_end_time, start_soc, end_soc, reason, settlement_time, refund_amount,
    refund_status, create_by, create_time, update_by, update_time, del_flag
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from order_basic_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from order_basic_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderBasicInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_basic_info (order_code, transaction_code, order_status, 
      member_id, station_id, merchant_id, 
      pile_sn, connector_code, pile_connector_code, 
      logic_card, vin_code, start_mode, 
      third_party_type, pay_mode, pay_status, 
      pay_amount, pay_time, plate_number, 
      order_amount, virtual_amount, group_code, 
      discount_amount, settle_amount, remedial_amount, 
      charge_start_time, charge_end_time, start_type,
      reserved_start_time, reserved_end_time,
      start_soc, end_soc,
      reason, settlement_time, refund_amount, 
      refund_status, create_by, create_time, 
      update_by, update_time, del_flag
      )
    values (#{orderCode,jdbcType=VARCHAR}, #{transactionCode,jdbcType=VARCHAR}, #{orderStatus,jdbcType=VARCHAR}, 
      #{memberId,jdbcType=VARCHAR}, #{stationId,jdbcType=VARCHAR}, #{merchantId,jdbcType=VARCHAR}, 
      #{pileSn,jdbcType=VARCHAR}, #{connectorCode,jdbcType=VARCHAR}, #{pileConnectorCode,jdbcType=VARCHAR}, 
      #{logicCard,jdbcType=VARCHAR}, #{vinCode,jdbcType=VARCHAR}, #{startMode,jdbcType=VARCHAR}, 
      #{thirdPartyType,jdbcType=VARCHAR}, #{payMode,jdbcType=VARCHAR}, #{payStatus,jdbcType=VARCHAR}, 
      #{payAmount,jdbcType=DECIMAL}, #{payTime,jdbcType=TIMESTAMP}, #{plateNumber,jdbcType=VARCHAR}, 
      #{orderAmount,jdbcType=DECIMAL}, #{virtualAmount,jdbcType=DECIMAL}, #{groupCode,jdbcType=VARCHAR}, 
      #{discountAmount,jdbcType=DECIMAL}, #{settleAmount,jdbcType=DECIMAL}, #{remedialAmount,jdbcType=DECIMAL}, 
      #{chargeStartTime,jdbcType=TIMESTAMP}, #{chargeEndTime,jdbcType=TIMESTAMP}, #{startType,jdbcType=VARCHAR},
      #{reservedStartTime,jdbcType=TIMESTAMP},#{reservedEndTime,jdbcType=TIMESTAMP},
      #{startSoc,jdbcType=VARCHAR}, #{endSoc,jdbcType=VARCHAR},
      #{reason,jdbcType=VARCHAR}, #{settlementTime,jdbcType=TIMESTAMP}, #{refundAmount,jdbcType=DECIMAL}, 
      #{refundStatus,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=CHAR}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderBasicInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_basic_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderCode != null">
        order_code,
      </if>
      <if test="transactionCode != null">
        transaction_code,
      </if>
      <if test="orderStatus != null">
        order_status,
      </if>
      <if test="memberId != null">
        member_id,
      </if>
      <if test="stationId != null">
        station_id,
      </if>
      <if test="merchantId != null">
        merchant_id,
      </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="logicCard != null">
        logic_card,
      </if>
      <if test="vinCode != null">
        vin_code,
      </if>
      <if test="startMode != null">
        start_mode,
      </if>
      <if test="thirdPartyType != null">
        third_party_type,
      </if>
      <if test="payMode != null">
        pay_mode,
      </if>
      <if test="payStatus != null">
        pay_status,
      </if>
      <if test="payAmount != null">
        pay_amount,
      </if>
      <if test="payTime != null">
        pay_time,
      </if>
      <if test="plateNumber != null">
        plate_number,
      </if>
      <if test="orderAmount != null">
        order_amount,
      </if>
      <if test="virtualAmount != null">
        virtual_amount,
      </if>
      <if test="groupCode != null">
        group_code,
      </if>
      <if test="discountAmount != null">
        discount_amount,
      </if>
      <if test="settleAmount != null">
        settle_amount,
      </if>
      <if test="remedialAmount != null">
        remedial_amount,
      </if>
      <if test="chargeStartTime != null">
        charge_start_time,
      </if>
      <if test="chargeEndTime != null">
        charge_end_time,
      </if>
      <if test="startType != null">
        start_type,
      </if>
      <if test="reservedStartTime != null">
        reserved_start_time,
      </if>
      <if test="reservedEndTime != null">
        reserved_end_time,
      </if>
      <if test="startSoc != null">
        start_soc,
      </if>
      <if test="endSoc != null">
        end_soc,
      </if>
      <if test="reason != null">
        reason,
      </if>
      <if test="settlementTime != null">
        settlement_time,
      </if>
      <if test="refundAmount != null">
        refund_amount,
      </if>
      <if test="refundStatus != null">
        refund_status,
      </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="delFlag != null">
        del_flag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderCode != null">
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="transactionCode != null">
        #{transactionCode,jdbcType=VARCHAR},
      </if>
      <if test="orderStatus != null">
        #{orderStatus,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="stationId != null">
        #{stationId,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        #{merchantId,jdbcType=VARCHAR},
      </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="logicCard != null">
        #{logicCard,jdbcType=VARCHAR},
      </if>
      <if test="vinCode != null">
        #{vinCode,jdbcType=VARCHAR},
      </if>
      <if test="startMode != null">
        #{startMode,jdbcType=VARCHAR},
      </if>
      <if test="thirdPartyType != null">
        #{thirdPartyType,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payStatus != null">
        #{payStatus,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="payTime != null">
        #{payTime,jdbcType=TIMESTAMP},
      </if>
      <if test="plateNumber != null">
        #{plateNumber,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null">
        #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="virtualAmount != null">
        #{virtualAmount,jdbcType=DECIMAL},
      </if>
      <if test="groupCode != null">
        #{groupCode,jdbcType=VARCHAR},
      </if>
      <if test="discountAmount != null">
        #{discountAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAmount != null">
        #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="remedialAmount != null">
        #{remedialAmount,jdbcType=DECIMAL},
      </if>
      <if test="chargeStartTime != null">
        #{chargeStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="chargeEndTime != null">
        #{chargeEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startType != null">
        #{startType,jdbcType=VARCHAR},
      </if>
      <if test="reservedStartTime != null">
        #{reservedStartTime},
      </if>
      <if test="reservedEndTime != null">
        #{reservedEndTime},
      </if>
      <if test="startSoc != null">
        #{startSoc,jdbcType=VARCHAR},
      </if>
      <if test="endSoc != null">
        #{endSoc,jdbcType=VARCHAR},
      </if>
      <if test="reason != null">
        #{reason,jdbcType=VARCHAR},
      </if>
      <if test="settlementTime != null">
        #{settlementTime,jdbcType=TIMESTAMP},
      </if>
      <if test="refundAmount != null">
        #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="refundStatus != null">
        #{refundStatus,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.jsowell.pile.domain.OrderBasicInfo">
    <!--@mbg.generated-->
    update order_basic_info
    <set>
      <if test="orderCode != null">
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="transactionCode != null">
        transaction_code = #{transactionCode,jdbcType=VARCHAR},
      </if>
      <if test="orderStatus != null">
        order_status = #{orderStatus,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="stationId != null">
        station_id = #{stationId,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        merchant_id = #{merchantId,jdbcType=VARCHAR},
      </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="logicCard != null">
        logic_card = #{logicCard,jdbcType=VARCHAR},
      </if>
      <if test="vinCode != null">
        vin_code = #{vinCode,jdbcType=VARCHAR},
      </if>
      <if test="startMode != null">
        start_mode = #{startMode,jdbcType=VARCHAR},
      </if>
      <if test="thirdPartyType != null">
        third_party_type = #{thirdPartyType,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        pay_mode = #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payStatus != null">
        pay_status = #{payStatus,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        pay_amount = #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="payTime != null">
        pay_time = #{payTime,jdbcType=TIMESTAMP},
      </if>
      <if test="plateNumber != null">
        plate_number = #{plateNumber,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null">
        order_amount = #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="virtualAmount != null">
        virtual_amount = #{virtualAmount,jdbcType=DECIMAL},
      </if>
      <if test="groupCode != null">
        group_code = #{groupCode,jdbcType=VARCHAR},
      </if>
      <if test="discountAmount != null">
        discount_amount = #{discountAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAmount != null">
        settle_amount = #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="remedialAmount != null">
        remedial_amount = #{remedialAmount,jdbcType=DECIMAL},
      </if>
      <if test="chargeStartTime != null">
        charge_start_time = #{chargeStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="chargeEndTime != null">
        charge_end_time = #{chargeEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startType != null">
        start_type = #{startType,jdbcType=VARCHAR},
      </if>
      <if test="reservedStartTime != null">
        reserved_start_time = #{reservedStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="reservedEndTime != null">
        reserved_end_time = #{reservedEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startSoc != null">
        start_soc = #{startSoc,jdbcType=VARCHAR},
      </if>
      <if test="endSoc != null">
        end_soc = #{endSoc,jdbcType=VARCHAR},
      </if>
      <if test="reason != null">
        reason = #{reason,jdbcType=VARCHAR},
      </if>
      <if test="settlementTime != null">
        settlement_time = #{settlementTime,jdbcType=TIMESTAMP},
      </if>
      <if test="refundAmount != null">
        refund_amount = #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="refundStatus != null">
        refund_status = #{refundStatus,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </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.OrderBasicInfo">
    <!--@mbg.generated-->
    update order_basic_info
    set order_code = #{orderCode,jdbcType=VARCHAR},
      transaction_code = #{transactionCode,jdbcType=VARCHAR},
      order_status = #{orderStatus,jdbcType=VARCHAR},
      member_id = #{memberId,jdbcType=VARCHAR},
      station_id = #{stationId,jdbcType=VARCHAR},
      merchant_id = #{merchantId,jdbcType=VARCHAR},
      pile_sn = #{pileSn,jdbcType=VARCHAR},
      connector_code = #{connectorCode,jdbcType=VARCHAR},
      pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
      logic_card = #{logicCard,jdbcType=VARCHAR},
      vin_code = #{vinCode,jdbcType=VARCHAR},
      start_mode = #{startMode,jdbcType=VARCHAR},
      third_party_type = #{thirdPartyType,jdbcType=VARCHAR},
      pay_mode = #{payMode,jdbcType=VARCHAR},
      pay_status = #{payStatus,jdbcType=VARCHAR},
      pay_amount = #{payAmount,jdbcType=DECIMAL},
      pay_time = #{payTime,jdbcType=TIMESTAMP},
      plate_number = #{plateNumber,jdbcType=VARCHAR},
      order_amount = #{orderAmount,jdbcType=DECIMAL},
      virtual_amount = #{virtualAmount,jdbcType=DECIMAL},
      group_code = #{groupCode,jdbcType=VARCHAR},
      discount_amount = #{discountAmount,jdbcType=DECIMAL},
      settle_amount = #{settleAmount,jdbcType=DECIMAL},
      remedial_amount = #{remedialAmount,jdbcType=DECIMAL},
      charge_start_time = #{chargeStartTime,jdbcType=TIMESTAMP},
      charge_end_time = #{chargeEndTime,jdbcType=TIMESTAMP},
      start_type = #{startType,jdbcType=VARCHAR},
      reserved_start_time = #{reservedStartTime,jdbcType=TIMESTAMP},
      reserved_end_time = #{reservedEndTime,jdbcType=TIMESTAMP},
      start_soc = #{startSoc,jdbcType=VARCHAR},
      end_soc = #{endSoc,jdbcType=VARCHAR},
      reason = #{reason,jdbcType=VARCHAR},
      settlement_time = #{settlementTime,jdbcType=TIMESTAMP},
      refund_amount = #{refundAmount,jdbcType=DECIMAL},
      refund_status = #{refundStatus,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      del_flag = #{delFlag,jdbcType=CHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update order_basic_info
    <trim prefix="set" suffixOverrides=",">
      <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="order_status = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.orderStatus,jdbcType=VARCHAR}
        </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="merchant_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.merchantId,jdbcType=VARCHAR}
        </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="logic_card = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.logicCard,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="vin_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.vinCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="start_mode = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.startMode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="third_party_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.thirdPartyType,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="pay_mode = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.payMode,jdbcType=VARCHAR}
        </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="pay_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.payAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="pay_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.payTime,jdbcType=TIMESTAMP}
        </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_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="virtual_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.virtualAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="group_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.groupCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="discount_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.discountAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="settle_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.settleAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="remedial_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.remedialAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="charge_start_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.chargeStartTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="charge_end_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.chargeEndTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="start_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.startType,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="reserved_start_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.reservedStartTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="reserved_end_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.reservedEndTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="start_soc = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.startSoc,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="end_soc = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.endSoc,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="reason = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.reason,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="settlement_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.settlementTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="refund_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.refundAmount,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="refund_status = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=INTEGER} then #{item.refundStatus,jdbcType=VARCHAR}
        </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="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="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="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="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_basic_info
    <trim prefix="set" suffixOverrides=",">
      <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="order_status = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.orderStatus != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.orderStatus,jdbcType=VARCHAR}
          </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="merchant_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.merchantId != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.merchantId,jdbcType=VARCHAR}
          </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="logic_card = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.logicCard != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.logicCard,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="vin_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.vinCode != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.vinCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="start_mode = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.startMode != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.startMode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="third_party_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.thirdPartyType != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.thirdPartyType,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="pay_mode = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.payMode != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.payMode,jdbcType=VARCHAR}
          </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="pay_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.payAmount != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.payAmount,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="pay_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.payTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.payTime,jdbcType=TIMESTAMP}
          </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_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="virtual_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.virtualAmount != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.virtualAmount,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="group_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.groupCode != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.groupCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="discount_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.discountAmount != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.discountAmount,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="settle_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.settleAmount != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.settleAmount,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="remedial_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.remedialAmount != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.remedialAmount,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="charge_start_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.chargeStartTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.chargeStartTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="charge_end_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.chargeEndTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.chargeEndTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="start_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.startType != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.startType,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="reserved_start_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.reservedStartTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.reservedStartTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="reserved_end_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.reservedEndTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.reservedEndTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="start_soc = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.startSoc != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.startSoc,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="end_soc = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.endSoc != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.endSoc,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="reason = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.reason != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.reason,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="settlement_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.settlementTime != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.settlementTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="refund_amount = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.refundAmount != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.refundAmount,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="refund_status = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.refundStatus != null">
            when id = #{item.id,jdbcType=INTEGER} then #{item.refundStatus,jdbcType=VARCHAR}
          </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="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="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="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="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_basic_info
    (order_code, transaction_code, order_status, member_id, station_id, merchant_id, 
      pile_sn, connector_code, pile_connector_code, logic_card, vin_code, start_mode, 
      third_party_type, pay_mode, pay_status, pay_amount, pay_time, plate_number, order_amount, 
      virtual_amount, group_code, discount_amount, settle_amount, remedial_amount, charge_start_time, 
      charge_end_time, start_type, reserved_start_time, reserved_end_time, start_soc, end_soc, reason, settlement_time,
      refund_amount, refund_status, create_by, create_time, update_by, update_time, del_flag
      )
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.orderCode,jdbcType=VARCHAR}, #{item.transactionCode,jdbcType=VARCHAR}, #{item.orderStatus,jdbcType=VARCHAR}, 
        #{item.memberId,jdbcType=VARCHAR}, #{item.stationId,jdbcType=VARCHAR}, #{item.merchantId,jdbcType=VARCHAR}, 
        #{item.pileSn,jdbcType=VARCHAR}, #{item.connectorCode,jdbcType=VARCHAR}, #{item.pileConnectorCode,jdbcType=VARCHAR}, 
        #{item.logicCard,jdbcType=VARCHAR}, #{item.vinCode,jdbcType=VARCHAR}, #{item.startMode,jdbcType=VARCHAR}, 
        #{item.thirdPartyType,jdbcType=VARCHAR}, #{item.payMode,jdbcType=VARCHAR}, #{item.payStatus,jdbcType=VARCHAR}, 
        #{item.payAmount,jdbcType=DECIMAL}, #{item.payTime,jdbcType=TIMESTAMP}, #{item.plateNumber,jdbcType=VARCHAR}, 
        #{item.orderAmount,jdbcType=DECIMAL}, #{item.virtualAmount,jdbcType=DECIMAL}, #{item.groupCode,jdbcType=VARCHAR}, 
        #{item.discountAmount,jdbcType=DECIMAL}, #{item.settleAmount,jdbcType=DECIMAL}, 
        #{item.remedialAmount,jdbcType=DECIMAL}, #{item.chargeStartTime,jdbcType=TIMESTAMP}, 
        #{item.chargeEndTime,jdbcType=TIMESTAMP}, #{item.startType,jdbcType=VARCHAR}, #{item.reservedStartTime,jdbcType=TIMESTAMP},
      #{item.reservedEndTime,jdbcType=TIMESTAMP},
        #{item.startSoc,jdbcType=VARCHAR}, #{item.endSoc,jdbcType=VARCHAR}, #{item.reason,jdbcType=VARCHAR}, 
        #{item.settlementTime,jdbcType=TIMESTAMP}, #{item.refundAmount,jdbcType=DECIMAL}, 
        #{item.refundStatus,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
        #{item.updateBy,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.delFlag,jdbcType=CHAR}
        )
    </foreach>
  </insert>
  <insert id="insertOrUpdate" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderBasicInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_basic_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      order_code,
      transaction_code,
      order_status,
      member_id,
      station_id,
      merchant_id,
      pile_sn,
      connector_code,
      pile_connector_code,
      logic_card,
      vin_code,
      start_mode,
      third_party_type,
      pay_mode,
      pay_status,
      pay_amount,
      pay_time,
      plate_number,
      order_amount,
      virtual_amount,
      group_code,
      discount_amount,
      settle_amount,
      remedial_amount,
      charge_start_time,
      charge_end_time,
      start_type,
      reserved_start_time,
      reserved_end_time,
      start_soc,
      end_soc,
      reason,
      settlement_time,
      refund_amount,
      refund_status,
      create_by,
      create_time,
      update_by,
      update_time,
      del_flag,
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      #{orderCode,jdbcType=VARCHAR},
      #{transactionCode,jdbcType=VARCHAR},
      #{orderStatus,jdbcType=VARCHAR},
      #{memberId,jdbcType=VARCHAR},
      #{stationId,jdbcType=VARCHAR},
      #{merchantId,jdbcType=VARCHAR},
      #{pileSn,jdbcType=VARCHAR},
      #{connectorCode,jdbcType=VARCHAR},
      #{pileConnectorCode,jdbcType=VARCHAR},
      #{logicCard,jdbcType=VARCHAR},
      #{vinCode,jdbcType=VARCHAR},
      #{startMode,jdbcType=VARCHAR},
      #{thirdPartyType,jdbcType=VARCHAR},
      #{payMode,jdbcType=VARCHAR},
      #{payStatus,jdbcType=VARCHAR},
      #{payAmount,jdbcType=DECIMAL},
      #{payTime,jdbcType=TIMESTAMP},
      #{plateNumber,jdbcType=VARCHAR},
      #{orderAmount,jdbcType=DECIMAL},
      #{virtualAmount,jdbcType=DECIMAL},
      #{groupCode,jdbcType=VARCHAR},
      #{discountAmount,jdbcType=DECIMAL},
      #{settleAmount,jdbcType=DECIMAL},
      #{remedialAmount,jdbcType=DECIMAL},
      #{chargeStartTime,jdbcType=TIMESTAMP},
      #{chargeEndTime,jdbcType=TIMESTAMP},
      #{startType,jdbcType=VARCHAR},
      #{reservedStartTime,jdbcType=TIMESTAMP},
      #{reservedEndTime,jdbcType=TIMESTAMP},
      #{startSoc,jdbcType=VARCHAR},
      #{endSoc,jdbcType=VARCHAR},
      #{reason,jdbcType=VARCHAR},
      #{settlementTime,jdbcType=TIMESTAMP},
      #{refundAmount,jdbcType=DECIMAL},
      #{refundStatus,jdbcType=VARCHAR},
      #{createBy,jdbcType=VARCHAR},
      #{createTime,jdbcType=TIMESTAMP},
      #{updateBy,jdbcType=VARCHAR},
      #{updateTime,jdbcType=TIMESTAMP},
      #{delFlag,jdbcType=CHAR},
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="id != null">
        id = #{id,jdbcType=INTEGER},
      </if>
      order_code = #{orderCode,jdbcType=VARCHAR},
      transaction_code = #{transactionCode,jdbcType=VARCHAR},
      order_status = #{orderStatus,jdbcType=VARCHAR},
      member_id = #{memberId,jdbcType=VARCHAR},
      station_id = #{stationId,jdbcType=VARCHAR},
      merchant_id = #{merchantId,jdbcType=VARCHAR},
      pile_sn = #{pileSn,jdbcType=VARCHAR},
      connector_code = #{connectorCode,jdbcType=VARCHAR},
      pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR},
      logic_card = #{logicCard,jdbcType=VARCHAR},
      vin_code = #{vinCode,jdbcType=VARCHAR},
      start_mode = #{startMode,jdbcType=VARCHAR},
      third_party_type = #{thirdPartyType,jdbcType=VARCHAR},
      pay_mode = #{payMode,jdbcType=VARCHAR},
      pay_status = #{payStatus,jdbcType=VARCHAR},
      pay_amount = #{payAmount,jdbcType=DECIMAL},
      pay_time = #{payTime,jdbcType=TIMESTAMP},
      plate_number = #{plateNumber,jdbcType=VARCHAR},
      order_amount = #{orderAmount,jdbcType=DECIMAL},
      virtual_amount = #{virtualAmount,jdbcType=DECIMAL},
      group_code = #{groupCode,jdbcType=VARCHAR},
      discount_amount = #{discountAmount,jdbcType=DECIMAL},
      settle_amount = #{settleAmount,jdbcType=DECIMAL},
      remedial_amount = #{remedialAmount,jdbcType=DECIMAL},
      charge_start_time = #{chargeStartTime,jdbcType=TIMESTAMP},
      charge_end_time = #{chargeEndTime,jdbcType=TIMESTAMP},
      start_type = #{startType,jdbcType=VARCHAR},
      reserved_start_time = #{reservedStartTime,jdbcType=TIMESTAMP},
      reserved_end_time = #{reservedEndTime,jdbcType=TIMESTAMP},
      start_soc = #{startSoc,jdbcType=VARCHAR},
      end_soc = #{endSoc,jdbcType=VARCHAR},
      reason = #{reason,jdbcType=VARCHAR},
      settlement_time = #{settlementTime,jdbcType=TIMESTAMP},
      refund_amount = #{refundAmount,jdbcType=DECIMAL},
      refund_status = #{refundStatus,jdbcType=VARCHAR},
      create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=VARCHAR},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      del_flag = #{delFlag,jdbcType=CHAR},
    </trim>
  </insert>
  <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderBasicInfo" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into order_basic_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="orderCode != null">
        order_code,
      </if>
      <if test="transactionCode != null">
        transaction_code,
      </if>
      <if test="orderStatus != null">
        order_status,
      </if>
      <if test="memberId != null">
        member_id,
      </if>
      <if test="stationId != null">
        station_id,
      </if>
      <if test="merchantId != null">
        merchant_id,
      </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="logicCard != null">
        logic_card,
      </if>
      <if test="vinCode != null">
        vin_code,
      </if>
      <if test="startMode != null">
        start_mode,
      </if>
      <if test="thirdPartyType != null">
        third_party_type,
      </if>
      <if test="payMode != null">
        pay_mode,
      </if>
      <if test="payStatus != null">
        pay_status,
      </if>
      <if test="payAmount != null">
        pay_amount,
      </if>
      <if test="payTime != null">
        pay_time,
      </if>
      <if test="plateNumber != null">
        plate_number,
      </if>
      <if test="orderAmount != null">
        order_amount,
      </if>
      <if test="virtualAmount != null">
        virtual_amount,
      </if>
      <if test="groupCode != null">
        group_code,
      </if>
      <if test="discountAmount != null">
        discount_amount,
      </if>
      <if test="settleAmount != null">
        settle_amount,
      </if>
      <if test="remedialAmount != null">
        remedial_amount,
      </if>
      <if test="chargeStartTime != null">
        charge_start_time,
      </if>
      <if test="chargeEndTime != null">
        charge_end_time,
      </if>
      <if test="startType != null">
        start_type,
      </if>
      <if test="reservedStartTime != null">
        reserved_start_time,
      </if>
      <if test="reservedEndTime != null">
        reserved_end_time,
      </if>
      <if test="startSoc != null">
        start_soc,
      </if>
      <if test="endSoc != null">
        end_soc,
      </if>
      <if test="reason != null">
        reason,
      </if>
      <if test="settlementTime != null">
        settlement_time,
      </if>
      <if test="refundAmount != null">
        refund_amount,
      </if>
      <if test="refundStatus != null">
        refund_status,
      </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="delFlag != null">
        del_flag,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="orderCode != null">
        #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="transactionCode != null">
        #{transactionCode,jdbcType=VARCHAR},
      </if>
      <if test="orderStatus != null">
        #{orderStatus,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="stationId != null">
        #{stationId,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        #{merchantId,jdbcType=VARCHAR},
      </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="logicCard != null">
        #{logicCard,jdbcType=VARCHAR},
      </if>
      <if test="vinCode != null">
        #{vinCode,jdbcType=VARCHAR},
      </if>
      <if test="startMode != null">
        #{startMode,jdbcType=VARCHAR},
      </if>
      <if test="thirdPartyType != null">
        #{thirdPartyType,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payStatus != null">
        #{payStatus,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="payTime != null">
        #{payTime,jdbcType=TIMESTAMP},
      </if>
      <if test="plateNumber != null">
        #{plateNumber,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null">
        #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="virtualAmount != null">
        #{virtualAmount,jdbcType=DECIMAL},
      </if>
      <if test="groupCode != null">
        #{groupCode,jdbcType=VARCHAR},
      </if>
      <if test="discountAmount != null">
        #{discountAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAmount != null">
        #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="remedialAmount != null">
        #{remedialAmount,jdbcType=DECIMAL},
      </if>
      <if test="chargeStartTime != null">
        #{chargeStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="chargeEndTime != null">
        #{chargeEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startType != null">
        #{startType,jdbcType=VARCHAR},
      </if>
      <if test="reservedStartTime != null">
        #{reservedStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="reservedEndTime != null">
        #{reservedEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startSoc != null">
        #{startSoc,jdbcType=VARCHAR},
      </if>
      <if test="endSoc != null">
        #{endSoc,jdbcType=VARCHAR},
      </if>
      <if test="reason != null">
        #{reason,jdbcType=VARCHAR},
      </if>
      <if test="settlementTime != null">
        #{settlementTime,jdbcType=TIMESTAMP},
      </if>
      <if test="refundAmount != null">
        #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="refundStatus != null">
        #{refundStatus,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </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="orderCode != null">
        order_code = #{orderCode,jdbcType=VARCHAR},
      </if>
      <if test="transactionCode != null">
        transaction_code = #{transactionCode,jdbcType=VARCHAR},
      </if>
      <if test="orderStatus != null">
        order_status = #{orderStatus,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="stationId != null">
        station_id = #{stationId,jdbcType=VARCHAR},
      </if>
      <if test="merchantId != null">
        merchant_id = #{merchantId,jdbcType=VARCHAR},
      </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="logicCard != null">
        logic_card = #{logicCard,jdbcType=VARCHAR},
      </if>
      <if test="vinCode != null">
        vin_code = #{vinCode,jdbcType=VARCHAR},
      </if>
      <if test="startMode != null">
        start_mode = #{startMode,jdbcType=VARCHAR},
      </if>
      <if test="thirdPartyType != null">
        third_party_type = #{thirdPartyType,jdbcType=VARCHAR},
      </if>
      <if test="payMode != null">
        pay_mode = #{payMode,jdbcType=VARCHAR},
      </if>
      <if test="payStatus != null">
        pay_status = #{payStatus,jdbcType=VARCHAR},
      </if>
      <if test="payAmount != null">
        pay_amount = #{payAmount,jdbcType=DECIMAL},
      </if>
      <if test="payTime != null">
        pay_time = #{payTime,jdbcType=TIMESTAMP},
      </if>
      <if test="plateNumber != null">
        plate_number = #{plateNumber,jdbcType=VARCHAR},
      </if>
      <if test="orderAmount != null">
        order_amount = #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="virtualAmount != null">
        virtual_amount = #{virtualAmount,jdbcType=DECIMAL},
      </if>
      <if test="groupCode != null">
        group_code = #{groupCode,jdbcType=VARCHAR},
      </if>
      <if test="discountAmount != null">
        discount_amount = #{discountAmount,jdbcType=DECIMAL},
      </if>
      <if test="settleAmount != null">
        settle_amount = #{settleAmount,jdbcType=DECIMAL},
      </if>
      <if test="remedialAmount != null">
        remedial_amount = #{remedialAmount,jdbcType=DECIMAL},
      </if>
      <if test="chargeStartTime != null">
        charge_start_time = #{chargeStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="chargeEndTime != null">
        charge_end_time = #{chargeEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startType != null">
        start_type = #{startType,jdbcType=VARCHAR},
      </if>
      <if test="reservedStartTime != null">
        reserved_start_time = #{reservedStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="reservedEndTime != null">
        reserved_end_time = #{reservedEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startSoc != null">
        start_soc = #{startSoc,jdbcType=VARCHAR},
      </if>
      <if test="endSoc != null">
        end_soc = #{endSoc,jdbcType=VARCHAR},
      </if>
      <if test="reason != null">
        reason = #{reason,jdbcType=VARCHAR},
      </if>
      <if test="settlementTime != null">
        settlement_time = #{settlementTime,jdbcType=TIMESTAMP},
      </if>
      <if test="refundAmount != null">
        refund_amount = #{refundAmount,jdbcType=DECIMAL},
      </if>
      <if test="refundStatus != null">
        refund_status = #{refundStatus,jdbcType=VARCHAR},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=CHAR},
      </if>
    </trim>
  </insert>

    <resultMap extends="BaseResultMap" id="OrderBasicInfoOrderDetailResult" type="com.jsowell.pile.domain.OrderBasicInfo">
        <collection javaType="java.util.List" notNullColumn="sub_id" property="orderDetailList" resultMap="OrderDetailResult" />
    </resultMap>

    <resultMap id="OrderDetailResult" type="com.jsowell.pile.domain.OrderDetail">
        <result column="id" property="id" />
        <result column="order_code" property="orderCode" />
        <result column="total_used_electricity" property="totalUsedElectricity" />
        <result column="total_order_amount" property="totalOrderAmount" />
        <result column="total_electricity_amount" property="totalElectricityAmount" />
        <result column="total_service_amount" property="totalServiceAmount" />
        <result column="sharp_price" property="sharpPrice" />
        <result column="sharp_used_electricity" property="sharpUsedElectricity" />
        <result column="sharp_electricity_price" property="sharpElectricityPrice" />
        <result column="sharp_service_price" property="sharpServicePrice" />
        <result column="sharp_amount" property="sharpAmount" />
        <result column="peak_price" property="peakPrice" />
        <result column="peak_used_electricity" property="peakUsedElectricity" />
        <result column="peak_electricity_price" property="peakElectricityPrice" />
        <result column="peak_service_price" property="peakServicePrice" />
        <result column="peak_amount" property="peakAmount" />
        <result column="flat_price" property="flatPrice" />
        <result column="flat_used_electricity" property="flatUsedElectricity" />
        <result column="flat_electricity_price" property="flatElectricityPrice" />
        <result column="flat_service_price" property="flatServicePrice" />
        <result column="flat_amount" property="flatAmount" />
        <result column="valley_price" property="valleyPrice" />
        <result column="valley_used_electricity" property="valleyUsedElectricity" />
        <result column="valley_electricity_price" property="valleyElectricityPrice" />
        <result column="valley_service_price" property="valleyServicePrice" />
        <result column="valley_amount" property="valleyAmount" />
        <result column="create_by" property="createBy" />
        <result column="create_time" property="createTime" />
        <result column="update_by" property="updateBy" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
    </resultMap>

    <sql id="selectOrderBasicInfoVo">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
    </sql>

    <sql id="Detail_Base_Column_List">
        id,
        order_code,
        total_used_electricity,
        total_order_amount,
        total_electricity_amount,
        total_service_amount,
        sharp_price,
        sharp_used_electricity,
        sharp_electricity_price,
        sharp_service_price,
        sharp_amount,
        peak_price,
        peak_used_electricity,
        peak_electricity_price,
        peak_service_price,
        peak_amount,
        flat_price,
        flat_used_electricity,
        flat_electricity_price,
        flat_service_price,
        flat_amount,
        valley_price,
        valley_used_electricity,
        valley_electricity_price,
        valley_service_price,
        valley_amount,
        create_by,
        create_time,
        update_by,
        update_time,
        del_flag
    </sql>

  <select id="selectOrderBasicInfoList" parameterType="com.jsowell.pile.dto.QueryOrderDTO"
          resultType="com.jsowell.pile.vo.web.OrderListVO">
    SELECT t1.id                       as id,
           t1.order_code               as orderCode,
           t1.transaction_code         as transactionCode,
           t1.order_status             as orderStatus,
           t1.member_id                as memberId,
           t2.nick_name                as nickName,
           t2.mobile_number            as mobileNumber,
           t1.station_id               as stationId,
           t3.station_name             as stationName,
           t1.pile_sn                  as pileSn,
           t1.connector_code           as connectorCode,
           t1.logic_card               as logicCard,
           t1.vin_code                 as vinCode,
           t1.plate_number             as plateNumber,
           t1.start_mode               as startMode,
           t1.third_party_type         as thirdPartyType,
           t1.pay_mode                 as payMode,
           t1.pay_status               as payStatus,
           t1.pay_amount               as payAmount,
           t1.pay_time                 as payTime,
           t1.order_amount             as orderAmount,
           t1.virtual_amount           as virtualAmount,
           t1.discount_amount          as discountAmount,
           t1.settle_amount            as settleAmount,
           t1.settlement_time          as settlementTime,
           t1.start_soc                as startSoc,
           t1.end_soc                  as endSoc,
           t1.charge_start_time        as chargeStartTime,
           t1.charge_end_time          as chargeEndTime,
           t1.create_time              as createTime,
           t4.total_used_electricity   as chargingDegree,
           t4.total_electricity_amount as totalElectricityAmount,
           t4.total_service_amount     as totalServiceAmount,
           t4.sharp_used_electricity   as sharpElectricity,
           t4.peak_used_electricity    as peakElectricity,
           t4.flat_used_electricity    as flatElectricity,
           t4.valley_used_electricity  as valleyElectricity
    from order_basic_info t1
           left join member_basic_info t2 on t1.member_id = t2.member_id and t2.del_flag = '0'
           join pile_station_info t3 on t1.station_id = t3.id and t3.del_flag = '0'
           join order_detail t4 on t4.order_code = t1.order_code and t4.del_flag = '0'
    where t1.del_flag = '0'
    <if test="pileSn != null and pileSn != ''">
      and t1.pile_sn = #{pileSn,jdbcType=VARCHAR}
    </if>
    <if test="connectorCode != null and connectorCode != ''">
      and t1.connector_code = #{connectorCode,jdbcType=VARCHAR}
    </if>
    <if test="memberId != null and memberId != ''">
      and t1.member_id = #{memberId,jdbcType=VARCHAR}
    </if>
    <if test="orderStatus != null and orderStatus != ''">
      and t1.order_status = #{orderStatus,jdbcType=VARCHAR}
    </if>
    <if test="orderCode != null and orderCode != ''">
      and t1.order_code = #{orderCode,jdbcType=VARCHAR}
    </if>
    <if test="transactionCode != null and transactionCode != ''">
      and t1.transaction_code = #{transactionCode,jdbcType=VARCHAR}
    </if>
    <if test="mobileNumber != null and mobileNumber != ''">
      and t2.mobile_number = #{mobileNumber,jdbcType=VARCHAR}
    </if>
    <if test="merchantId != null and merchantId != ''">
      and t1.merchant_id = #{merchantId,jdbcType=VARCHAR}
    </if>
    <if test="stationId != null and stationId != ''">
      and t1.station_id = #{stationId,jdbcType=VARCHAR}
    </if>
    <if test="startTime != null and startTime != ''">
      and t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
    </if>
    <if test="endTime != null and endTime != ''">
      and t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
    </if>
    <if test="startSettleTime != null and startSettleTime != ''">
      and t1.settlement_time <![CDATA[ >= ]]> #{startSettleTime,jdbcType=VARCHAR}
    </if>
    <if test="endSettleTime != null and endSettleTime != ''">
      and t1.settlement_time <![CDATA[ <= ]]> #{endSettleTime,jdbcType=VARCHAR}
    </if>
    <if test="groupCode != null and groupCode != ''">
      and t1.group_code = #{groupCode,jdbcType=VARCHAR}
    </if>
    <if test="vinCode != null and vinCode != ''">
      and t1.vin_code = #{vinCode,jdbcType=VARCHAR}
    </if>
    <if test="stationDeptIds != null and stationDeptIds.size() != 0">
      and t3.dept_id in
      <foreach close=")" collection="stationDeptIds" item="stationDeptId" open="(" separator=",">
        #{stationDeptId}
      </foreach>
    </if>
    order by t1.create_time desc
  </select>

    <select id="getOrderTotalData" parameterType="com.jsowell.pile.dto.QueryOrderDTO" resultType="com.jsowell.pile.vo.web.OrderTotalDataVO">
        select
        IFNULL(sum(t1.order_amount),0) as sumOrderAmount,
        IFNULL(sum(t4.total_used_electricity),0) as sumUsedElectricity,
        IFNULL(sum(t1.settle_amount),0) as sumSettleAmount
        from order_basic_info t1
         left join member_basic_info t2 on t1.member_id = t2.member_id and t2.del_flag = '0'
         join pile_station_info t3 on t1.station_id = t3.id and t3.del_flag = '0'
         join order_detail t4 on t4.order_code = t1.order_code and t4.del_flag = '0'
        where t1.del_flag = '0'
        <if test="pileSn != null and pileSn != ''">
            and t1.pile_sn = #{pileSn,jdbcType=VARCHAR}
        </if>
        <if test="connectorCode != null and connectorCode != ''">
            and t1.connector_code = #{connectorCode,jdbcType=VARCHAR}
        </if>
        <if test="memberId != null and memberId != ''">
            and t1.member_id = #{memberId,jdbcType=VARCHAR}
        </if>
        <if test="orderStatus != null and orderStatus != ''">
            and t1.order_status = #{orderStatus,jdbcType=VARCHAR}
        </if>
        <if test="orderCode != null and orderCode != ''">
            and t1.order_code = #{orderCode,jdbcType=VARCHAR}
        </if>
        <if test="transactionCode != null and transactionCode != ''">
            and t1.transaction_code = #{transactionCode,jdbcType=VARCHAR}
        </if>
        <if test="mobileNumber != null and mobileNumber != ''">
            and t2.mobile_number = #{mobileNumber,jdbcType=VARCHAR}
        </if>
        <if test="stationId != null and stationId != ''">
            and t1.station_id = #{stationId,jdbcType=VARCHAR}
        </if>
        <if test="startTime != null and startTime != ''">
            and t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
        </if>
        <if test="endTime != null and endTime != ''">
            and t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
        </if>
        <if test="startSettleTime != null and startSettleTime != ''">
            and t1.settlement_time <![CDATA[ >= ]]> #{startSettleTime,jdbcType=VARCHAR}
        </if>
        <if test="endSettleTime != null and endSettleTime != ''">
            and t1.settlement_time <![CDATA[ <= ]]> #{endSettleTime,jdbcType=VARCHAR}
        </if>
        <if test="merchantId != null and merchantId != ''">
            and t1.merchant_id = #{merchantId,jdbcType=VARCHAR}
        </if>
        <if test="stationDeptIds != null and stationDeptIds.size() != 0">
            and t3.dept_id in
            <foreach close=")" collection="stationDeptIds" item="stationDeptId" open="(" separator=",">
                #{stationDeptId}
            </foreach>
        </if>
        order by t1.create_time desc
    </select>

    <select id="selectOrderBasicInfoById" parameterType="Long" resultMap="OrderBasicInfoOrderDetailResult">
        select a.id,
               a.order_code,
               a.order_status,
               a.member_id,
               a.station_id,
               a.pile_sn,
               a.connector_code,
               a.start_mode,
               a.pay_mode,
               a.pay_status,
               a.pay_amount,
               a.pay_time,
               a.order_amount,
               a.reason,
               a.create_by,
               a.create_time,
               a.update_by,
               a.update_time,
               a.del_flag,
               b.id                       as sub_id,
               b.order_code               as sub_order_code,
               b.total_used_electricity   as sub_total_used_electricity,
               b.total_order_amount       as sub_total_order_amount,
               b.total_electricity_amount as sub_total_electricity_amount,
               b.total_service_amount     as sub_total_service_amount,
               b.sharp_used_electricity   as sub_sharp_used_electricity,
               b.sharp_electricity_price  as sub_sharp_electricity_price,
               b.sharp_service_price      as sub_sharp_service_price,
               b.peak_used_electricity    as sub_peak_used_electricity,
               b.peak_electricity_price   as sub_peak_electricity_price,
               b.peak_service_price       as sub_peak_service_price,
               b.flat_used_electricity    as sub_flat_used_electricity,
               b.flat_electricity_price   as sub_flat_electricity_price,
               b.flat_service_price       as sub_flat_service_price,
               b.valley_used_electricity  as sub_valley_used_electricity,
               b.valley_electricity_price as sub_valley_electricity_price,
               b.valley_service_price     as sub_valley_service_price,
               b.create_by                as sub_create_by,
               b.create_time              as sub_create_time,
               b.update_by                as sub_update_by,
               b.update_time              as sub_update_time,
               b.del_flag                 as sub_del_flag
        from order_basic_info a
                 left join order_detail b on b.order_code = a.id
        where a.id = #{id}
    </select>

    <insert id="insertOrderBasicInfo" keyProperty="id" parameterType="com.jsowell.pile.domain.OrderBasicInfo" useGeneratedKeys="true">
        insert into order_basic_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderCode != null">
                order_code,
            </if>
            <if test="transactionCode != null">
                transaction_code,
            </if>
            <if test="orderStatus != null">
                order_status,
            </if>
            <if test="memberId != null">
                member_id,
            </if>
            <if test="stationId != null">
                station_id,
            </if>
            <if test="merchantId != null">
                merchant_id,
            </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="logicCard != null">
                logic_card,
            </if>
            <if test="vinCode != null">
                vin_code,
            </if>
            <if test="startMode != null">
                start_mode,
            </if>
            <if test="thirdPartyType != null">
                third_party_type,
            </if>
            <if test="payMode != null">
                pay_mode,
            </if>
            <if test="payStatus != null">
                pay_status,
            </if>
            <if test="payAmount != null">
                pay_amount,
            </if>
            <if test="payTime != null">
                pay_time,
            </if>
            <if test="plateNumber != null">
                plate_number,
            </if>
            <if test="orderAmount != null">
                order_amount,
            </if>
            <if test="virtualAmount != null">
                virtual_amount,
            </if>
            <if test="settleAmount != null">
                settle_amount,
            </if>
            <if test="chargeStartTime != null">
                charge_start_time,
            </if>
            <if test="chargeEndTime != null">
                charge_end_time,
            </if>
            <if test="startType != null">
                start_type,
            </if>
            <if test="reservedStartTime != null">
                reserved_start_time,
            </if>
            <if test="reservedEndTime != null">
                reserved_end_time,
            </if>
            <if test="startSoc != null">
                start_soc,
            </if>
            <if test="endSoc != null">
                end_soc,
            </if>
            <if test="reason != null">
                reason,
            </if>
            <if test="settlementTime != null">
                settlement_time,
            </if>
            <if test="refundAmount != null">
                refund_amount,
            </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="delFlag != null">
                del_flag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderCode != null">
                #{orderCode},
            </if>
            <if test="transactionCode != null">
                #{transactionCode},
            </if>
            <if test="orderStatus != null">
                #{orderStatus},
            </if>
            <if test="memberId != null">
                #{memberId},
            </if>
            <if test="stationId != null">
                #{stationId},
            </if>
            <if test="merchantId != null">
                #{merchantId},
            </if>
            <if test="pileSn != null">
                #{pileSn,jdbcType=VARCHAR},
            </if>
            <if test="connectorCode != null">
                #{connectorCode},
            </if>
            <if test="pileConnectorCode != null">
                #{pileConnectorCode},
            </if>
            <if test="logicCard != null">
                #{logicCard},
            </if>
            <if test="vinCode != null">
                #{vinCode,jdbcType=VARCHAR},
            </if>
            <if test="startMode != null">
                #{startMode},
            </if>
            <if test="thirdPartyType != null">
                 #{thirdPartyType},
            </if>
            <if test="payMode != null">
                #{payMode},
            </if>
            <if test="payStatus != null">
                #{payStatus},
            </if>
            <if test="payAmount != null">
                #{payAmount},
            </if>
            <if test="payTime != null">
                #{payTime},
            </if>
            <if test="plateNumber != null">
                #{plateNumber},
            </if>
            <if test="orderAmount != null">
                #{orderAmount},
            </if>
            <if test="virtualAmount != null">
                #{virtualAmount},
            </if>
            <if test="settleAmount != null">
                #{settleAmount},
            </if>
            <if test="chargeStartTime != null">
                #{chargeStartTime},
            </if>
            <if test="chargeEndTime != null">
                #{chargeEndTime},
            </if>
            <if test="startType != null">
                #{startType},
            </if>
            <if test="reservedStartTime != null">
                #{reservedStartTime},
            </if>
            <if test="reservedEndTime != null">
                #{reservedEndTime},
            </if>
            <if test="startSoc != null">
              #{startSoc},
            </if>
            <if test="endSoc != null">
              #{endSoc},
            </if>
            <if test="reason != null">
                #{reason},
            </if>
            <if test="settlementTime != null">
                #{settlementTime},
            </if>
            <if test="refundAmount != null">
                #{refundAmount},
            </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="delFlag != null">
                #{delFlag},
            </if>
        </trim>
    </insert>

    <update id="updateOrderBasicInfo" parameterType="com.jsowell.pile.domain.OrderBasicInfo">
        update order_basic_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderCode != null">
                order_code = #{orderCode},
            </if>
            <if test="orderStatus != null">
                order_status = #{orderStatus},
            </if>
            <if test="memberId != null">
                member_id = #{memberId},
            </if>
            <if test="stationId != null">
                station_id = #{stationId},
            </if>
            <if test="merchantId != null">
                merchant_id = #{merchantId},
            </if>
            <if test="pileSn != null">
                pile_sn = #{pileSn},
            </if>
            <if test="connectorCode != null">
                connector_code = #{connectorCode},
            </if>
            <if test="pileConnectorCode != null">
                pile_connector_code = #{pileConnectorCode},
            </if>
            <if test="logicCard != null">
                logic_card = #{logicCard},
            </if>
            <if test="vinCode != null">
                vin_code = #{vinCode},
            </if>
            <if test="startMode != null">
                start_mode = #{startMode},
            </if>
          <if test="thirdPartyType != null">
            third_party_type = #{thirdPartyType},
          </if>
            <if test="payMode != null">
                pay_mode = #{payMode},
            </if>
            <if test="payStatus != null">
                pay_status = #{payStatus},
            </if>
            <if test="payAmount != null">
                pay_amount = #{payAmount},
            </if>
            <if test="payTime != null">
                pay_time = #{payTime},
            </if>
            <if test="plateNumber != null">
                plate_number = #{plateNumber},
            </if>
            <if test="orderAmount != null">
                order_amount = #{orderAmount},
            </if>
            <if test="virtualAmount != null">
                virtual_amount = #{virtualAmount},
            </if>
          <if test="groupCode != null">
            group_code = #{groupCode},
          </if>
          <if test="discountAmount != null">
            discount_amount = #{discountAmount},
          </if>
            <if test="settleAmount != null">
                settle_amount = #{settleAmount},
            </if>
            <if test="chargeStartTime != null">
                charge_start_time = #{chargeStartTime},
            </if>
            <if test="chargeEndTime != null">
                charge_end_time = #{chargeEndTime},
            </if>
            <if test="startType != null">
                start_type = #{startType},
            </if>
            <if test="startSoc != null">
              start_soc = #{startSoc},
            </if>
            <if test="endSoc != null">
              end_soc = #{endSoc},
            </if>
            <if test="reason != null">
                reason = #{reason},
            </if>
            <if test="settlementTime != null">
                settlement_time = #{settlementTime},
            </if>
            <if test="refundAmount != null">
                refund_amount = #{refundAmount},
            </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="delFlag != null">
                del_flag = #{delFlag},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderBasicInfoByIds" parameterType="String">
        delete
        from order_basic_info where id in
        <foreach close=")" collection="array" item="id" open="(" separator=",">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteOrderDetailByOrderCodes" parameterType="String">
        delete
        from order_detail where order_code in
        <foreach close=")" collection="array" item="orderCode" open="(" separator=",">
            #{orderCode}
        </foreach>
    </delete>

    <delete id="deleteOrderDetailByOrderCode" parameterType="Long">
        delete
        from order_detail
        where order_code = #{orderCode}
    </delete>

    <insert id="batchOrderDetail">
        insert into order_detail(id, order_code, total_used_electricity, total_order_amount, total_electricity_amount,
                                 total_service_amount,
                                 sharp_price, sharp_used_electricity, sharp_electricity_price, sharp_service_price,
                                 sharp_amount,
                                 peak_price, peak_used_electricity, peak_electricity_price, peak_service_price,
                                 peak_amount,
                                 flat_price, flat_used_electricity, flat_electricity_price, flat_service_price,
                                 flat_amount,
                                 valley_price, valley_used_electricity, valley_electricity_price, valley_service_price,
                                 valley_amount,
                                 create_by, update_by)
        values
        <foreach collection="list" index="index" item="item" separator=",">
            (#{item.id}, #{item.orderCode}, #{item.totalUsedElectricity}, #{item.totalOrderAmount},
             #{item.totalElectricityAmount}, #{item.totalServiceAmount},
             #{item.sharpPrice}, #{item.sharpUsedElectricity}, #{item.sharpElectricityPrice}, #{item.sharpServicePrice},
             #{item.sharpAmount},
             #{item.peakPrice}, #{item.peakUsedElectricity}, #{item.peakElectricityPrice}, #{item.peakServicePrice},
             #{item.peakAmount},
             #{item.flatPrice}, #{item.flatUsedElectricity}, #{item.flatElectricityPrice}, #{item.flatServicePrice},
             #{item.flatAmount},
             #{item.valleyPrice}, #{item.valleyUsedElectricity}, #{item.valleyElectricityPrice},
             #{item.valleyServicePrice}, #{item.valleyAmount},
             #{item.createBy}, #{item.updateBy})
        </foreach>
    </insert>

    <update id="updateOrderDetail" parameterType="com.jsowell.pile.domain.OrderDetail">
        update order_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderCode != null">
                order_code = #{orderCode},
            </if>
            <if test="totalUsedElectricity != null">
                total_used_electricity = #{totalUsedElectricity},
            </if>
            <if test="totalOrderAmount != null">
                total_order_amount = #{totalOrderAmount},
            </if>
            <if test="totalElectricityAmount != null">
                total_electricity_amount = #{totalElectricityAmount},
            </if>
          <if test="discountElectricityAmount != null">
            discount_electricity_amount = #{discountElectricityAmount},
          </if>
            <if test="totalServiceAmount != null">
                total_service_amount = #{totalServiceAmount},
            </if>
          <if test="discountServiceAmount != null">
            discount_service_amount = #{discountServiceAmount},
          </if>
            <if test="sharpPrice != null">
                sharp_price = #{sharpPrice},
            </if>
            <if test="sharpUsedElectricity != null">
                sharp_used_electricity = #{sharpUsedElectricity},
            </if>
            <if test="sharpElectricityPrice != null">
                sharp_electricity_price = #{sharpElectricityPrice},
            </if>
            <if test="sharpServicePrice != null">
                sharp_service_price = #{sharpServicePrice},
            </if>
            <if test="sharpAmount != null">
                sharp_amount = #{sharpAmount},
            </if>
            <if test="peakPrice != null">
                peak_price = #{peakPrice},
            </if>
            <if test="peakUsedElectricity != null">
                peak_used_electricity = #{peakUsedElectricity},
            </if>
            <if test="peakElectricityPrice != null">
                peak_electricity_price = #{peakElectricityPrice},
            </if>
            <if test="peakServicePrice != null">
                peak_service_price = #{peakServicePrice},
            </if>
            <if test="peakAmount != null">
                peak_amount = #{peakAmount},
            </if>
            <if test="flatPrice != null">
                flat_price = #{flatPrice},
            </if>
            <if test="flatUsedElectricity != null">
                flat_used_electricity = #{flatUsedElectricity},
            </if>
            <if test="flatElectricityPrice != null">
                flat_electricity_price = #{flatElectricityPrice},
            </if>
            <if test="flatServicePrice != null">
                flat_service_price = #{flatServicePrice},
            </if>
            <if test="flatAmount != null">
                flat_amount = #{flatAmount},
            </if>
            <if test="valleyPrice != null">
                valley_price = #{valleyPrice},
            </if>
            <if test="valleyUsedElectricity != null">
                valley_used_electricity = #{valleyUsedElectricity},
            </if>
            <if test="valleyElectricityPrice != null">
                valley_electricity_price = #{valleyElectricityPrice},
            </if>
            <if test="valleyServicePrice != null">
                valley_service_price = #{valleyServicePrice},
            </if>
            <if test="valleyAmount != null">
                valley_amount = #{valleyAmount},
            </if>
            <if test="createBy != null">
                create_by = #{createBy},
            </if>
            <if test="updateBy != null">
                update_by = #{updateBy},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag},
            </if>
        </trim>
        where id = #{id}
    </update>


    <select id="getOrderInfoByOrderCode" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        <where>
            order_code = #{orderCode,jdbcType=VARCHAR}
        </where>
        and del_flag = '0'
    </select>

    <select id="getOrderInfoByTransactionCode" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        where del_flag = '0'
          and transaction_code = #{transactionCode,jdbcType=VARCHAR}
    </select>

    <select id="queryOrderBasicInfo" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        where del_flag = '0'
          and pile_sn = #{pileSn,jdbcType=VARCHAR}
          and connector_code = #{connectorCode,jdbcType=VARCHAR}
          and order_status = #{orderStatus,jdbcType=VARCHAR}
        order by create_time DESC
        limit 1
    </select>

    <select id="getOrderDetailByOrderCode" resultMap="OrderDetailResult">
        select
        <include refid="Detail_Base_Column_List" />
        from order_detail
        where del_flag = '0'
          and order_code = #{orderCode,jdbcType=VARCHAR}
    </select>

    <select id="getListByMemberIdAndOrderStatus" resultType="com.jsowell.pile.vo.uniapp.customer.OrderVO">
        SELECT t1.id,
               t1.order_code               as orderCode,
                t1.transaction_code as transactionCode,
               t1.order_status             as orderStatus,
               t1.reason,
               t1.station_id               as stationId,
               t3.station_name             as stationName,
               t1.pile_sn                  as pileSn,
               t1.connector_code           as connectorCode,
               t1.pay_status               as payStatus,
               t1.start_mode               as startMode,
               t1.order_amount             as orderAmount,
               t1.virtual_amount           as virtualAmount,
               t1.settle_amount            as settleAmount,
               t1.pay_amount               as payAmount,
               t2.total_used_electricity   as chargingDegree,
               t1.charge_start_time        as startTime,
               t1.charge_end_time          as endTime,
               t2.total_electricity_amount as totalElectricityAmount,
               t2.total_service_amount     as totalServiceAmount
        from order_basic_info t1
                 join order_detail t2 on t1.order_code = t2.order_code
                 join pile_station_info t3 on t1.station_id = t3.id
        where t1.del_flag = '0'
          and t1.member_id = #{memberId,jdbcType=VARCHAR}
        <if test="stationId != null and stationId != ''">
            and t1.station_id = #{stationId,jdbcType=VARCHAR}
        </if>
        <if test="orderStatusList != null and orderStatusList.size() != 0">
            and t1.order_status in
            <foreach close=")" collection="orderStatusList" item="orderStatus" open="(" separator=",">
                #{orderStatus,jdbcType=VARCHAR}
            </foreach>
        </if>
        <if test="dateTime != null">
            and t1.create_time <![CDATA[ >= ]]> #{dateTime,jdbcType=VARCHAR}
        </if>
        order by t1.create_time desc
    </select>

    <update id="updateOrderStatusByOrderCode">
        update order_basic_info
        set order_status = #{orderStatus,jdbcType=VARCHAR}
        where del_flag = '0'
          and order_code = #{orderCode,jdbcType=VARCHAR}
    </update>

    <select id="getIndexOrderInfo" resultType="com.jsowell.pile.vo.web.IndexOrderInfoVO">
        SELECT DATE_FORMAT(t1.create_time, '%Y-%m-%d') as date,
               sum(t2.total_used_electricity)          AS totalElectricity,
               sum(t2.total_order_amount)              AS totalOrderAmount,
               sum(t2.sharp_used_electricity)          AS totalSharpUsedElectricity,
               sum(t2.peak_used_electricity)           AS totalPeakUsedElectricity,
               sum(t2.flat_used_electricity)           AS totalFlatUsedElectricity,
               sum(t2.valley_used_electricity)         AS totalValleyUsedElectricity
        FROM order_basic_info t1
                 JOIN order_detail t2 ON t1.order_code = t2.order_code
            AND t1.del_flag = '0'
        WHERE date(t1.create_time) &gt;= DATE_SUB(CURDATE(), INTERVAL 30 day)
          and t1.order_status = '6'
        <if test="dto.stationId != null and dto.stationId != ''">
            and t1.station_id = #{dto.stationId,jdbcType=VARCHAR}
        </if>
        <if test="dto.stationIdList != null and dto.stationIdList.size() != 0">
            and t1.station_id in
            <foreach close=")" collection="dto.stationIdList" item="item" open="(" separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
        group by DATE_FORMAT(t1.create_time, '%Y-%m-%d')
    </select>

    <select id="getUnpaidOrderListOver15Min" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        where del_flag = '0'
          and order_status = '0'
          and pay_status = '0'
          and create_time <![CDATA[ <= ]]> #{createTime,jdbcType=VARCHAR}
    </select>

    <select id="selectOrderListByTimeRangeAndStatus" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        where del_flag = '0'
        and start_mode != '4'
        <if test="startTime != null and startTime != ''">
            and create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
        </if>
        <if test="endTime != null and endTime != ''">
            and create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
        </if>
        <if test="orderStatus != null and orderStatus != ''">
            and order_status = #{orderStatus,jdbcType=VARCHAR}
        </if>
        <if test="payStatus != null and payStatus != ''">
            and pay_status = #{payStatus,jdbcType=VARCHAR}
        </if>
    </select>

    <update id="updateOrderStatusById">
        update order_basic_info
        set order_status = #{orderStatus,jdbcType=VARCHAR}
        where del_flag = '0'
          and id in
        <foreach close=")" collection="orderIds" item="orderId" open="(" separator=",">
            #{orderId,jdbcType=VARCHAR}
        </foreach>
    </update>

    <select id="selectOrderInfoByOrderCode" resultType="com.jsowell.pile.vo.uniapp.customer.SendMessageVO">
        SELECT t1.order_code             as orderCode,
               t1.pile_sn                as pileSn,
               t1.connector_code         as connectorCode,
               t1.charge_start_time      as chargeStartTime,
               t1.charge_end_time        as chargeStopTime,
               t1.reason                 as stopReason,
               t1.station_id             as stationId,
               t2.station_name           as stationName,
               t3.total_order_amount     as orderAmount,
                t1.order_amount as orderAmount,
                t1.discount_amount as discountAmount,
                t1.settle_amount as settleAmount,
               t3.total_used_electricity as chargingDegree,
               t4.open_id                as openId
        FROM order_basic_info t1
       JOIN pile_station_info t2 ON t1.station_id = t2.id and t1.del_flag = '0'
       join order_detail t3 on t1.order_code = t3.order_code and t3.del_flag = '0'
       join member_basic_info t4 on t1.member_id = t4.member_id and t4.del_flag = '0'
        where t1.del_flag = '0'
            and t1.order_code = #{orderCode,jdbcType=VARCHAR}
    </select>

    <select id="getOrderBasicInfo" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        where del_flag = '0'
        <if test="memberId != null and memberId != ''">
            AND member_id = #{memberId,jdbcType=VARCHAR}
        </if>
        <if test="pileConnectorCode != null and pileConnectorCode != ''">
            AND pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR}
        </if>
        <if test="orderStatus != null and orderStatus != ''">
            AND order_status = #{orderStatus,jdbcType=VARCHAR}
        </if>
        <if test="startMode != null and startMode != ''">
            AND start_mode = #{startMode,jdbcType=VARCHAR}
        </if>
        order by create_time desc
        limit 1
    </select>

    <select id="getAccumulativeInfo" resultType="com.jsowell.pile.vo.uniapp.customer.PersonPileConnectorSumInfoVO">
        SELECT t1.member_id              as memberId,
               t1.pile_connector_code    as pileConnectorCode,
               t1.pile_sn                as pileSn,
               t1.charge_start_time      as chargeStartTime,
               t1.charge_end_time        as chargeEndTime,
               t2.total_used_electricity as sumChargingDegree
        FROM order_basic_info t1
        JOIN order_detail t2 ON t1.order_code = t2.order_code
        WHERE t1.pile_connector_code = #{pileConnectorCode,jdbcType=VARCHAR}
          AND t1.member_id = #{memberId,jdbcType=VARCHAR}
          AND t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
          AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
          AND t1.order_status = '6'
          AND t1.del_flag = '0'
    </select>

    <select id="getListByOrderCodes" resultType="com.jsowell.pile.vo.uniapp.customer.OrderVO">
        SELECT t1.order_code               as orderCode,
               t1.order_status             as orderStatus,
               t1.reason                   as reason,
               t1.merchant_id              as merchantId,
               t1.station_id               as stationId,
               t3.station_name             as stationName,
               t1.pile_sn                  as pileSn,
               t1.connector_code           as connectorCode,
               t1.pay_status               as payStatus,
               t1.order_amount             as orderAmount,
               t1.pay_amount               as payAmount,
               t2.total_used_electricity   as chargingDegree,
               t1.charge_start_time        as startTime,
               t1.charge_end_time          as endTime,
               t2.total_electricity_amount as totalElectricityAmount,
               t2.total_service_amount     as totalServiceAmount
        from order_basic_info t1
        join order_detail t2 on t1.order_code = t2.order_code
        join pile_station_info t3 on t1.station_id = t3.id
        where t1.del_flag = '0'
          and t1.order_code in
        <foreach close=")" collection="orderCodes" item="orderCode" open="(" separator=",">
            #{orderCode,jdbcType=VARCHAR}
        </foreach>
    </select>

    <select id="getAccumulativeInfoForLianLian" resultType="com.jsowell.pile.vo.lianlian.AccumulativeInfoVO">
        SELECT t1.order_code                           as orderCode,
               t1.pile_connector_code                  as pileConnectorCode,
               t1.pile_sn                              as pileSn,
               t1.station_id                           as stationId,
               IFNULL(t2.total_used_electricity, 0.00) as connectorElectricity
        FROM order_basic_info t1
                 JOIN order_detail t2 ON t1.order_code = t2.order_code
        WHERE t1.del_flag = '0'
          AND t1.station_id = #{stationID,jdbcType=VARCHAR}
          AND t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
          AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
    </select>

    <select id="queryElecAmountNullList" resultMap="OrderDetailResult">
        select
        <include refid="Detail_Base_Column_List" />
        from order_detail
        where del_flag = '0'
          and total_order_amount is not null
          AND total_order_amount &gt; '0.00'
          and total_electricity_amount is null
    </select>

    <update id="batchUpdateOrderDetail">
        update order_detail
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="total_electricity_amount =case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.totalElectricityAmount != null">
                        when id = #{item.id} then #{item.totalElectricityAmount}
                    </if>
                </foreach>
            </trim>
            <trim prefix="total_service_amount =case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.totalServiceAmount != null">
                        when id = #{item.id} then #{item.totalServiceAmount}
                    </if>
                </foreach>
            </trim>
        </trim>
        where
        <foreach collection="list" index="index" item="i" separator="or">
            id = #{i.id}
        </foreach>
    </update>

    <select id="getOrderDetailList" resultMap="OrderDetailResult">
        select
        <include refid="Detail_Base_Column_List" />
        from order_detail
        where del_flag = '0'
          and order_code in
        <foreach close=")" collection="list" item="item" open="(" separator=",">
            #{item,jdbcType=VARCHAR}
        </foreach>
    </select>
    <select id="tempQueryWeChatRefundOrders" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        where del_flag = '0'
          and pay_mode = '4'
          and refund_amount &gt; '0.00'
          and create_time BETWEEN #{startTime} and #{endTime}
    </select>

    <select id="getMerchantOrderInfoList" resultType="com.jsowell.pile.vo.base.MerchantOrderInfoVO">
        select t1.order_code       as orderCode,
               t1.transaction_code as transactionCode,
               t1.order_status     as orderStatus,
               t1.station_id       as stationId,
               t2.station_name     as stationName,
               t1.order_amount     as orderAmount,
               t1.settlement_time  as orderSettleTime
        from order_basic_info t1
                 left join pile_station_info t2 on t1.station_id = t2.id
        where t1.del_flag = '0'
          and t1.merchant_id = #{dto.merchantId,jdbcType=VARCHAR}
        <if test="dto.startTime != null">
            and t1.create_time <![CDATA[ >= ]]> #{dto.startTime,jdbcType=VARCHAR}
        </if>
        <if test="dto.endTime != null">
            and t1.settlement_time <![CDATA[ <= ]]> #{dto.endTime,jdbcType=VARCHAR}
        </if>
        order by t1.create_time desc
    </select>

    <select id="batchRefundQuery" resultType="com.jsowell.pile.vo.web.RefundOrder">
        SELECT t1.order_code     as orderCode,
               t1.`order_status` as orderStatus,
               t1.station_id     as stationId,
               t2.station_name   AS stationName,
               t1.pay_amount     AS payAmount,
               t1.order_amount   AS orderAmount,
               t1.refund_amount  AS refundAmount
        FROM order_basic_info t1
                 JOIN pile_station_info t2 ON t1.station_id = t2.id
        WHERE
            t1.order_code IN
        <foreach close=")" collection="list" item="itme" open="(" separator=",">
            #{itme,jdbcType=VARCHAR}
        </foreach>
    </select>

    <select id="queryOrderList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from order_basic_info
        where del_flag = '0'
          and order_code in
        <foreach close=")" collection="orderCodeList" item="item" open="(" separator=",">
            #{item,jdbcType=VARCHAR}
        </foreach>
    </select>

    <select id="getIndexOrderInfoV2" resultType="com.jsowell.pile.vo.web.IndexOrderInfoVO">
        SELECT trade_date      AS date,
               order_codes     as orderCodes,
               use_electricity AS totalElectricity,
               total_amount    as totalOrderAmount
        from settle_order_report
        where del_flag = '0'
        and date(trade_date) &gt;= DATE_SUB(CURDATE(), INTERVAL 30 day)
        <if test="dto.stationId != null and dto.stationId != ''">
            and station_id = #{dto.stationId,jdbcType=VARCHAR}
        </if>
        <if test="dto.stationIdList != null and dto.stationIdList.size() != 0">
            and station_id in
            <foreach close=")" collection="dto.stationIdList" item="item" open="(" separator=",">
                #{item,jdbcType=VARCHAR}
            </foreach>
        </if>
    </select>

    <select id="getIndexOrderDetail" resultType="com.jsowell.pile.vo.web.IndexOrderInfoVO">
        select
               sum(sharp_used_electricity)          AS totalSharpUsedElectricity,
               sum(peak_used_electricity)           AS totalPeakUsedElectricity,
               sum(flat_used_electricity)           AS totalFlatUsedElectricity,
               sum(valley_used_electricity)         AS totalValleyUsedElectricity
        from order_detail
        <if test="list != null and list.size() != 0">
            where order_code in
            <foreach close=")" collection="list" item="orderCode" open="(" separator=",">
                #{orderCode,jdbcType=VARCHAR}
            </foreach>
        </if>
    </select>

    <update id="updateMerchantByStationId">
        update
            order_basic_info
        set
            merchant_id = #{newMerchantId,jdbcType=VARCHAR}
        where
            station_id = #{stationId,jdbcType=BIGINT}
    </update>

    <select id="getNROrderInfoByOrderCode" resultType="com.jsowell.pile.vo.nanrui.JiangSuOrderInfoVO">
        SELECT
            t1.station_id as stationId,
            t1.merchant_id,
            t1.third_party_type as thirdPartyType,
            t3.organization_code AS operatorId,
            t1.pile_connector_code AS connectorId,
            t1.order_code AS startChargeSeq,
            t2.total_used_electricity AS elect,
            t2.sharp_used_electricity AS cuspElect,
            t2.peak_used_electricity AS peakElect,
            t2.flat_used_electricity AS flatElect,
            t2.valley_used_electricity AS valleyElect,
            t1.charge_start_time AS startTime,
            t1.charge_end_time AS endTime
        FROM
            order_basic_info t1
                JOIN order_detail t2 ON t1.order_code = t2.order_code
                AND t1.del_flag = '0'
                JOIN pile_merchant_info t3 ON t1.merchant_id = t3.id
                AND t3.del_flag = '0'
        <where>
            <if test="dto.orderCode != null and dto.orderCode != ''">
                and t1.order_code = #{dto.orderCode,jdbcType=VARCHAR}
            </if>
            <if test="dto.queryStartTime != null and dto.queryStartTime != '' and dto.queryEndTime != null and dto.queryEndTime != ''">
                and t1.charge_end_time between #{dto.queryStartTime,jdbcType=VARCHAR} and #{dto.queryEndTime,jdbcType=VARCHAR}
            </if>
        </where>
    </select>

    <select id="queryOrderPayDetail" resultType="com.jsowell.pile.vo.web.OrderPayDetailVO">
        select
            t1.order_code as orderCode,
        t1.create_time as createTime,
        t1.settlement_time as settlementTime,
        t1.`pay_amount` as payAmount,
        t1.refund_amount as refundAmount,
        t1.settle_amount as settleAmount,
        t1.refund_amount as refundAmount,
        t1.merchant_id as merchantId,
        t2.payment_id as paymentId
        from order_basic_info t1
        join adapay_callback_record t2 on t1.order_code = t2.order_code
        where t1.`del_flag` = '0'
          and t1.settlement_time BETWEEN #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
          and t1.settle_amount &gt; 0.00
          and t1.pay_mode = '4'
    </select>

    <select id="getOrderInfoByNXJT" resultType="com.jsowell.pile.vo.uniapp.customer.OrderVO">
        SELECT
            t1.charge_start_time AS startTime,
            t1.station_id AS stationId,
            t2.station_name AS stationName,
            t1.plate_number as licensePlateNumber,
            t1.order_amount AS orderAmount
        FROM
            order_basic_info t1
                JOIN pile_station_info t2 ON t1.station_id = t2.id
        WHERE t1.del_flag = '0'
            <if test="licensePlateNumber != null and licensePlateNumber != ''">
                AND t1.plate_number = #{licensePlateNumber,jdbcType=VARCHAR}
            </if>
            <if test="startTime != null and startTime != ''">
                AND t1.create_time <![CDATA[ >= ]]> #{startTime,jdbcType=VARCHAR}
            </if>
            <if test="endTime != null and endTime != ''">
                AND t1.create_time <![CDATA[ <= ]]> #{endTime,jdbcType=VARCHAR}
            </if>
    </select>

  <select id="queryRepayOrder" resultMap="BaseResultMap">
    select
        <include refid="Base_Column_List"/>
    from order_basic_info
    where order_status = '3'
    and member_id =#{memberId,jdbcType=VARCHAR}
  </select>

  <select id="queryOrderListByGroupCode" resultMap="BaseResultMap">
    select
        <include refid="Base_Column_List"/>
    from order_basic_info
    where order_status = '6'
    and pay_mode = '1'
    and group_code =#{groupCode,jdbcType=VARCHAR}
  </select>

  <select id="queryXDTOrderList" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from order_basic_info
    where order_status = '3'
    and member_id =#{memberId,jdbcType=VARCHAR}
  </select>

    <select id="getChargeOrderInfoByOrderCode" resultType="com.jsowell.pile.vo.uniapp.customer.OrderVO">
        SELECT
        t1.merchant_id as mercahntId,
        t3.organization_code as organizationCode,
        t1.order_code AS orderCode,
        t1.transaction_code AS transactionCode,
        t1.order_status AS orderStatus,
        t1.station_id AS stationId,
        t1.pile_sn AS pileSn,
        t1.connector_code AS connectorCode,
        t1.pile_connector_code AS pileConnectorCode,
        t1.pay_mode AS payMode,
        t1.pay_amount AS payAmount,
        t1.pay_time AS payTime,
        t1.order_amount AS orderAmount,
        t1.plate_number AS plateNumber,
        t1.discount_amount AS discountAmount,
        t1.settle_amount AS settleAmount,
        t1.charge_start_time AS startTime,
        t1.charge_end_time AS endTime,
        t1.start_soc AS startSoc,
        t1.end_soc AS endSoc,
        t1.reason AS stopReason,
        t2.total_used_electricity AS totalPower,
        t2.total_electricity_amount AS totalElectricityAmount,
        t2.total_service_amount AS totalServiceAmount
        FROM
        order_basic_info t1
        JOIN
        order_detail t2 ON t1.order_code = t2.order_code
        join
        pile_merchant_info t3 on t1.merchant_id = t3.id
        WHERE
        t1.del_flag = '0'
        AND
        t1.order_code = #{orderCode,jdbcType=VARCHAR}
    </select>

  <select id="getReservedOrder" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from order_basic_info
    where del_flag = '0'
    and pay_status = '1'
    and start_type = 'reserved'
    and order_status = '0'
    and order_basic_info.reserved_start_time <![CDATA[ <= ]]> #{dateTime,jdbcType=TIMESTAMP}
  </select>

  <select id="queryOrderListByStationId" resultType="com.jsowell.pile.vo.SupStationStatsVO">
    SELECT
      t1.order_code as orderCode,
      t3.organization_code as organizationCode,
      t1.station_id AS stationId,
      t1.pile_sn AS pileSn,
      t1.pile_connector_code AS pileConnectorCode,
      t1.charge_start_time AS StartTime,
      t1.charge_end_time AS EndTime,
      t2.total_used_electricity AS totalPower
    FROM
      order_basic_info t1
        JOIN order_detail t2 ON t1.order_code = t2.order_code
        AND t1.del_flag = '0'
    JOIN pile_merchant_info t3 on t1.merchant_id = t3.id
    WHERE
      t1.station_id = #{stationId,jdbcType=VARCHAR}
      AND t1.charge_start_time <![CDATA[ >= ]]> DATE_SUB( CURDATE(), INTERVAL 1 DAY )
      AND t1.charge_start_time <![CDATA[ < ]]> CURDATE()
  </select>

  <select id="queryOrderByOccupyTime" resultType="com.jsowell.pile.vo.web.OrderListVO">
    SELECT t1.id                       as id,
           t1.order_code               as orderCode,
           t1.transaction_code         as transactionCode,
           t1.order_status             as orderStatus,
           t1.member_id                as memberId,
           t2.nick_name                as nickName,
           t2.mobile_number            as mobileNumber,
           t1.station_id               as stationId,
           t3.station_name             as stationName,
           t1.pile_sn                  as pileSn,
           t1.connector_code           as connectorCode,
           t1.logic_card               as logicCard,
           t1.vin_code                 as vinCode,
           t1.plate_number             as plateNumber,
           t1.start_mode               as startMode,
           t1.third_party_type         as thirdPartyType,
           t1.pay_mode                 as payMode,
           t1.pay_status               as payStatus,
           t1.pay_amount               as payAmount,
           t1.pay_time                 as payTime,
           t1.order_amount             as orderAmount,
           t1.virtual_amount           as virtualAmount,
           t1.discount_amount          as discountAmount,
           t1.settle_amount            as settleAmount,
           t1.settlement_time          as settlementTime,
           t1.start_soc                as startSoc,
           t1.end_soc                  as endSoc,
           t1.charge_start_time        as chargeStartTime,
           t1.charge_end_time          as chargeEndTime,
           t1.create_time              as createTime,
           t4.total_used_electricity   as chargingDegree,
           t4.total_electricity_amount as totalElectricityAmount,
           t4.total_service_amount     as totalServiceAmount,
           t4.sharp_used_electricity   as sharpElectricity,
           t4.peak_used_electricity    as peakElectricity,
           t4.flat_used_electricity    as flatElectricity,
           t4.valley_used_electricity  as valleyElectricity
    from order_basic_info t1
   left join member_basic_info t2 on t1.member_id = t2.member_id and t2.del_flag = '0'
   join pile_station_info t3 on t1.station_id = t3.id and t3.del_flag = '0'
   join order_detail t4 on t4.order_code = t1.order_code and t4.del_flag = '0'
    where t1.del_flag = '0'
      and `t1`.`member_id` = #{memberId,jdbcType=VARCHAR}
      and `t1`.`station_id` = #{stationId,jdbcType=VARCHAR}
      and (`t1`.`charge_start_time` <![CDATA[ >= ]]> #{endTime,jdbcType=VARCHAR} or `t1`.`charge_end_time` <![CDATA[ <= ]]> #{startTime,jdbcType=VARCHAR})
  </select>
</mapper>