<?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.platform.yijia.dao.PayOrderMapper">
  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.PayOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="order_id" jdbcType="INTEGER" property="orderId" />
    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
    <result column="oil_gun" jdbcType="VARCHAR" property="oilGun" />
    <result column="oil_name" jdbcType="VARCHAR" property="oilName" />
    <result column="consumer_id" jdbcType="INTEGER" property="consumerId" />
    <result column="consumer" jdbcType="VARCHAR" property="consumer" />
    <result column="amt" jdbcType="VARCHAR" property="amt" />
    <result column="station_id" jdbcType="INTEGER" property="stationId" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="order_liters" jdbcType="VARCHAR" property="orderLiters" />
    <result column="pay_type" jdbcType="VARCHAR" property="payType" />
    <result column="pay_way" jdbcType="VARCHAR" property="payWay" />
    <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
    <result column="oil_personnel" jdbcType="VARCHAR" property="oilPersonnel" />
    <result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
    <result column="order_type" jdbcType="CHAR" property="orderType" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    order_id, order_no, oil_gun, oil_name, consumer_id, consumer, amt, station_id, status, 
    order_liters, pay_type, pay_way, pay_date, oil_personnel, created_date, order_type
  </sql>

  <!-- 根据油品名称和油站查询油枪编号和价格 -->
  <select id="selectOilGunNoAndOilPrice" parameterType="map" resultType="map">
    SELECT
        A.oil_gun_no 	AS oliGunNo,
        A.oil_name 	    AS oilName,
        A.station_name  AS stationName,
        B.oil_price	    AS oilPrice
    FROM station_oil_gun AS A
        LEFT JOIN station_oil_price AS B ON A.oil_name = B.oil_name AND A.station_id = B.station_id
    <where>
        <if test="oilGunId != null and oilGunId !=''">
          A.oil_gun_id = #{oilGunId}
        </if>
        <if test="stationId !=null and stationId !=''">
          AND A.station_id = #{stationId}
        </if>
    </where>
  </select>
  <!-- 根据油品名称和油站id获取当前油品调价信息 -->
  <select id="selectOilPriceAdjust" parameterType="map" resultType="map">
    SELECT
        adjust_price_id     AS adjustPriceId,
        oil_name            AS oilName,
        oil_adjust_price    AS oilAdjustPrice,
        take_effect_status  AS takeEffectStatus,
        take_effect_date    AS takeEffectDate,
        adjust_date         AS adjustDate,
        station_id          AS stationId,
        operator            AS operator,
        status              AS status
    FROM
        station_oil_price_adjust
    <where>
      <if test="oilName !=null and oilName !=''">
        oil_name = #{oilName}
      </if>
      <if test="stationId !=null and stationId !=''">
        AND station_id = #{stationId}
      </if>
      ORDER BY take_effect_date DESC
    </where>

  </select>



  <select id="selectByExample" parameterType="com.platform.yijia.pojo.PayOrderExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from pay_order
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from pay_order
    where order_id = #{orderId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from pay_order
    where order_id = #{orderId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.platform.yijia.pojo.PayOrderExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from pay_order
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.platform.yijia.pojo.PayOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into pay_order (order_id, order_no, oil_gun, 
      oil_name, consumer_id, consumer, 
      amt, station_id, status, 
      order_liters, pay_type, pay_way, 
      pay_date, oil_personnel, created_date, 
      order_type)
    values (#{orderId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{oilGun,jdbcType=VARCHAR}, 
      #{oilName,jdbcType=VARCHAR}, #{consumerId,jdbcType=INTEGER}, #{consumer,jdbcType=VARCHAR}, 
      #{amt,jdbcType=VARCHAR}, #{stationId,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR}, 
      #{orderLiters,jdbcType=VARCHAR}, #{payType,jdbcType=VARCHAR}, #{payWay,jdbcType=VARCHAR}, 
      #{payDate,jdbcType=TIMESTAMP}, #{oilPersonnel,jdbcType=VARCHAR}, #{createdDate,jdbcType=TIMESTAMP}, 
      #{orderType,jdbcType=CHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.platform.yijia.pojo.PayOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into pay_order
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderId != null">
        order_id,
      </if>
      <if test="orderNo != null">
        order_no,
      </if>
      <if test="oilGun != null">
        oil_gun,
      </if>
      <if test="oilName != null">
        oil_name,
      </if>
      <if test="consumerId != null">
        consumer_id,
      </if>
      <if test="consumer != null">
        consumer,
      </if>
      <if test="amt != null">
        amt,
      </if>
      <if test="stationId != null">
        station_id,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="orderLiters != null">
        order_liters,
      </if>
      <if test="payType != null">
        pay_type,
      </if>
      <if test="payWay != null">
        pay_way,
      </if>
      <if test="payDate != null">
        pay_date,
      </if>
      <if test="oilPersonnel != null">
        oil_personnel,
      </if>
      <if test="createdDate != null">
        created_date,
      </if>
      <if test="orderType != null">
        order_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderId != null">
        #{orderId,jdbcType=INTEGER},
      </if>
      <if test="orderNo != null">
        #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="oilGun != null">
        #{oilGun,jdbcType=VARCHAR},
      </if>
      <if test="oilName != null">
        #{oilName,jdbcType=VARCHAR},
      </if>
      <if test="consumerId != null">
        #{consumerId,jdbcType=INTEGER},
      </if>
      <if test="consumer != null">
        #{consumer,jdbcType=VARCHAR},
      </if>
      <if test="amt != null">
        #{amt,jdbcType=VARCHAR},
      </if>
      <if test="stationId != null">
        #{stationId,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="orderLiters != null">
        #{orderLiters,jdbcType=VARCHAR},
      </if>
      <if test="payType != null">
        #{payType,jdbcType=VARCHAR},
      </if>
      <if test="payWay != null">
        #{payWay,jdbcType=VARCHAR},
      </if>
      <if test="payDate != null">
        #{payDate,jdbcType=TIMESTAMP},
      </if>
      <if test="oilPersonnel != null">
        #{oilPersonnel,jdbcType=VARCHAR},
      </if>
      <if test="createdDate != null">
        #{createdDate,jdbcType=TIMESTAMP},
      </if>
      <if test="orderType != null">
        #{orderType,jdbcType=CHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.platform.yijia.pojo.PayOrderExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from pay_order
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update pay_order
    <set>
      <if test="record.orderId != null">
        order_id = #{record.orderId,jdbcType=INTEGER},
      </if>
      <if test="record.orderNo != null">
        order_no = #{record.orderNo,jdbcType=VARCHAR},
      </if>
      <if test="record.oilGun != null">
        oil_gun = #{record.oilGun,jdbcType=VARCHAR},
      </if>
      <if test="record.oilName != null">
        oil_name = #{record.oilName,jdbcType=VARCHAR},
      </if>
      <if test="record.consumerId != null">
        consumer_id = #{record.consumerId,jdbcType=INTEGER},
      </if>
      <if test="record.consumer != null">
        consumer = #{record.consumer,jdbcType=VARCHAR},
      </if>
      <if test="record.amt != null">
        amt = #{record.amt,jdbcType=VARCHAR},
      </if>
      <if test="record.stationId != null">
        station_id = #{record.stationId,jdbcType=INTEGER},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=VARCHAR},
      </if>
      <if test="record.orderLiters != null">
        order_liters = #{record.orderLiters,jdbcType=VARCHAR},
      </if>
      <if test="record.payType != null">
        pay_type = #{record.payType,jdbcType=VARCHAR},
      </if>
      <if test="record.payWay != null">
        pay_way = #{record.payWay,jdbcType=VARCHAR},
      </if>
      <if test="record.payDate != null">
        pay_date = #{record.payDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.oilPersonnel != null">
        oil_personnel = #{record.oilPersonnel,jdbcType=VARCHAR},
      </if>
      <if test="record.createdDate != null">
        created_date = #{record.createdDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.orderType != null">
        order_type = #{record.orderType,jdbcType=CHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update pay_order
    set order_id = #{record.orderId,jdbcType=INTEGER},
      order_no = #{record.orderNo,jdbcType=VARCHAR},
      oil_gun = #{record.oilGun,jdbcType=VARCHAR},
      oil_name = #{record.oilName,jdbcType=VARCHAR},
      consumer_id = #{record.consumerId,jdbcType=INTEGER},
      consumer = #{record.consumer,jdbcType=VARCHAR},
      amt = #{record.amt,jdbcType=VARCHAR},
      station_id = #{record.stationId,jdbcType=INTEGER},
      status = #{record.status,jdbcType=VARCHAR},
      order_liters = #{record.orderLiters,jdbcType=VARCHAR},
      pay_type = #{record.payType,jdbcType=VARCHAR},
      pay_way = #{record.payWay,jdbcType=VARCHAR},
      pay_date = #{record.payDate,jdbcType=TIMESTAMP},
      oil_personnel = #{record.oilPersonnel,jdbcType=VARCHAR},
      created_date = #{record.createdDate,jdbcType=TIMESTAMP},
      order_type = #{record.orderType,jdbcType=CHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.platform.yijia.pojo.PayOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update pay_order
    <set>
      <if test="orderNo != null">
        order_no = #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="oilGun != null">
        oil_gun = #{oilGun,jdbcType=VARCHAR},
      </if>
      <if test="oilName != null">
        oil_name = #{oilName,jdbcType=VARCHAR},
      </if>
      <if test="consumerId != null">
        consumer_id = #{consumerId,jdbcType=INTEGER},
      </if>
      <if test="consumer != null">
        consumer = #{consumer,jdbcType=VARCHAR},
      </if>
      <if test="amt != null">
        amt = #{amt,jdbcType=VARCHAR},
      </if>
      <if test="stationId != null">
        station_id = #{stationId,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=VARCHAR},
      </if>
      <if test="orderLiters != null">
        order_liters = #{orderLiters,jdbcType=VARCHAR},
      </if>
      <if test="payType != null">
        pay_type = #{payType,jdbcType=VARCHAR},
      </if>
      <if test="payWay != null">
        pay_way = #{payWay,jdbcType=VARCHAR},
      </if>
      <if test="payDate != null">
        pay_date = #{payDate,jdbcType=TIMESTAMP},
      </if>
      <if test="oilPersonnel != null">
        oil_personnel = #{oilPersonnel,jdbcType=VARCHAR},
      </if>
      <if test="createdDate != null">
        created_date = #{createdDate,jdbcType=TIMESTAMP},
      </if>
      <if test="orderType != null">
        order_type = #{orderType,jdbcType=CHAR},
      </if>
    </set>
    where order_id = #{orderId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.platform.yijia.pojo.PayOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update pay_order
    set order_no = #{orderNo,jdbcType=VARCHAR},
      oil_gun = #{oilGun,jdbcType=VARCHAR},
      oil_name = #{oilName,jdbcType=VARCHAR},
      consumer_id = #{consumerId,jdbcType=INTEGER},
      consumer = #{consumer,jdbcType=VARCHAR},
      amt = #{amt,jdbcType=VARCHAR},
      station_id = #{stationId,jdbcType=INTEGER},
      status = #{status,jdbcType=VARCHAR},
      order_liters = #{orderLiters,jdbcType=VARCHAR},
      pay_type = #{payType,jdbcType=VARCHAR},
      pay_way = #{payWay,jdbcType=VARCHAR},
      pay_date = #{payDate,jdbcType=TIMESTAMP},
      oil_personnel = #{oilPersonnel,jdbcType=VARCHAR},
      created_date = #{createdDate,jdbcType=TIMESTAMP},
      order_type = #{orderType,jdbcType=CHAR}
    where order_id = #{orderId,jdbcType=INTEGER}
  </update>
</mapper>