<?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="resources/ctariff.CtariffMapper">
  <resultMap id="BaseResultMap" type="com.ag.ctc.domain.pojo.Ctariff">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="ID" jdbcType="VARCHAR" property="id" />
    <result column="TENANCY_ID" jdbcType="VARCHAR" property="tenancyId" />
    <result column="CHARGING_ID" jdbcType="VARCHAR" property="chargingId" />
    <result column="RATE" jdbcType="DECIMAL" property="rate" />
    <result column="CURRENCY" jdbcType="VARCHAR" property="currency" />
    <result column="NOTES" jdbcType="VARCHAR" property="notes" />
    <result column="CREATED_BY" jdbcType="VARCHAR" property="createdBy" />
    <result column="CREATED_ON" jdbcType="TIMESTAMP" property="createdOn" />
    <result column="UPDATED_BY" jdbcType="VARCHAR" property="updatedBy" />
    <result column="UPDATED_ON" jdbcType="TIMESTAMP" property="updatedOn" />
    <result column="CONTRACT_ID" jdbcType="VARCHAR" property="contractId" />
    <result column="AMOUNT_FORMAT" jdbcType="DECIMAL" property="amountFormat" />
    <result column="FORMAT_UNIT" jdbcType="DECIMAL" property="formatUnit" />
    <result column="SORT" jdbcType="DECIMAL" property="sort" />
    <result column="VOL_PRICE" jdbcType="DECIMAL" property="volPrice" />
    <result column="RECEIVE_CODE" jdbcType="VARCHAR" property="receiveCode" />
    <result column="PAY_CODE" jdbcType="VARCHAR" property="payCode" />
    <result column="PAY_RATE" jdbcType="DECIMAL" property="payRate" />
    <result column="RECEIVE_RATE" jdbcType="DECIMAL" property="receiveRate" />
    <result column="PAY_CURRENCY" jdbcType="VARCHAR" property="payCurrency" />
    <result column="RECEIVE_CURRENCY" jdbcType="VARCHAR" property="receiveCurrency" />
    <result column="KEY_DESCRIPTION" jdbcType="VARCHAR" property="keyDescription" />
    <result column="VAL_DESCRIPTION" jdbcType="VARCHAR" property="valDescription" />
    <result column="EFFECTIVE_DATE" jdbcType="TIMESTAMP" property="effectiveDate" />
    <result column="EXPIRED_DATE" jdbcType="TIMESTAMP" property="expiredDate" />
    <result column="APPENDLX_NOTES" jdbcType="VARCHAR" property="appendlxNotes" />
    <result column="CONFIRM_STATUS" jdbcType="DECIMAL" property="confirmStatus" />
    <result column="CONFIRM_BY" jdbcType="VARCHAR" property="confirmBy" />
    <result column="CONFIRM_ON" jdbcType="TIMESTAMP" property="confirmOn" />
    <result column="DEL_FLAG" jdbcType="DECIMAL" property="delFlag" />
    <result column="BYTON" jdbcType="DECIMAL" property="byton" />
    <result column="MIN_AMOUNT" jdbcType="DECIMAL" property="minAmount" />
    <result column="MAX_AMOUNT" jdbcType="DECIMAL" property="maxAmount" />
    <result column="IS_FORMAT" jdbcType="DECIMAL" property="isFormat" />
    <result column="VERIFY_FLAG" jdbcType="DECIMAL" property="verifyFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    ID, TENANCY_ID, CHARGING_ID, RATE, CURRENCY, NOTES, CREATED_BY, CREATED_ON, UPDATED_BY, 
    UPDATED_ON, CONTRACT_ID, AMOUNT_FORMAT, FORMAT_UNIT, SORT, VOL_PRICE, RECEIVE_CODE, 
    PAY_CODE, PAY_RATE, RECEIVE_RATE, PAY_CURRENCY, RECEIVE_CURRENCY, KEY_DESCRIPTION, 
    VAL_DESCRIPTION, EFFECTIVE_DATE, EXPIRED_DATE, APPENDLX_NOTES, CONFIRM_STATUS, CONFIRM_BY, 
    CONFIRM_ON, DEL_FLAG, BYTON, MIN_AMOUNT, MAX_AMOUNT, IS_FORMAT, VERIFY_FLAG
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from C_TARIFF
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from C_TARIFF
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.ag.ctc.domain.pojo.Ctariff">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into C_TARIFF (ID, TENANCY_ID, CHARGING_ID, 
      RATE, CURRENCY, NOTES, 
      CREATED_BY, CREATED_ON, UPDATED_BY, 
      UPDATED_ON, CONTRACT_ID, AMOUNT_FORMAT, 
      FORMAT_UNIT, SORT, VOL_PRICE, 
      RECEIVE_CODE, PAY_CODE, PAY_RATE, 
      RECEIVE_RATE, PAY_CURRENCY, RECEIVE_CURRENCY, 
      KEY_DESCRIPTION, VAL_DESCRIPTION, EFFECTIVE_DATE, 
      EXPIRED_DATE, APPENDLX_NOTES, CONFIRM_STATUS, 
      CONFIRM_BY, CONFIRM_ON, DEL_FLAG, 
      BYTON, MIN_AMOUNT, MAX_AMOUNT, 
      IS_FORMAT, VERIFY_FLAG)
    values (#{id,jdbcType=VARCHAR}, #{tenancyId,jdbcType=VARCHAR}, #{chargingId,jdbcType=VARCHAR}, 
      #{rate,jdbcType=DECIMAL}, #{currency,jdbcType=VARCHAR}, #{notes,jdbcType=VARCHAR}, 
      #{createdBy,jdbcType=VARCHAR}, #{createdOn,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}, 
      #{updatedOn,jdbcType=TIMESTAMP}, #{contractId,jdbcType=VARCHAR}, #{amountFormat,jdbcType=DECIMAL}, 
      #{formatUnit,jdbcType=DECIMAL}, #{sort,jdbcType=DECIMAL}, #{volPrice,jdbcType=DECIMAL}, 
      #{receiveCode,jdbcType=VARCHAR}, #{payCode,jdbcType=VARCHAR}, #{payRate,jdbcType=DECIMAL}, 
      #{receiveRate,jdbcType=DECIMAL}, #{payCurrency,jdbcType=VARCHAR}, #{receiveCurrency,jdbcType=VARCHAR}, 
      #{keyDescription,jdbcType=VARCHAR}, #{valDescription,jdbcType=VARCHAR}, #{effectiveDate,jdbcType=TIMESTAMP}, 
      #{expiredDate,jdbcType=TIMESTAMP}, #{appendlxNotes,jdbcType=VARCHAR}, #{confirmStatus,jdbcType=DECIMAL}, 
      #{confirmBy,jdbcType=VARCHAR}, #{confirmOn,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=DECIMAL}, 
      #{byton,jdbcType=DECIMAL}, #{minAmount,jdbcType=DECIMAL}, #{maxAmount,jdbcType=DECIMAL}, 
      #{isFormat,jdbcType=DECIMAL}, #{verifyFlag,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" parameterType="com.ag.ctc.domain.pojo.Ctariff">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into C_TARIFF
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        ID,
      </if>
      <if test="tenancyId != null">
        TENANCY_ID,
      </if>
      <if test="chargingId != null">
        CHARGING_ID,
      </if>
      <if test="rate != null">
        RATE,
      </if>
      <if test="currency != null">
        CURRENCY,
      </if>
      <if test="notes != null">
        NOTES,
      </if>
      <if test="createdBy != null">
        CREATED_BY,
      </if>
      <if test="createdOn != null">
        CREATED_ON,
      </if>
      <if test="updatedBy != null">
        UPDATED_BY,
      </if>
      <if test="updatedOn != null">
        UPDATED_ON,
      </if>
      <if test="contractId != null">
        CONTRACT_ID,
      </if>
      <if test="amountFormat != null">
        AMOUNT_FORMAT,
      </if>
      <if test="formatUnit != null">
        FORMAT_UNIT,
      </if>
      <if test="sort != null">
        SORT,
      </if>
      <if test="volPrice != null">
        VOL_PRICE,
      </if>
      <if test="receiveCode != null">
        RECEIVE_CODE,
      </if>
      <if test="payCode != null">
        PAY_CODE,
      </if>
      <if test="payRate != null">
        PAY_RATE,
      </if>
      <if test="receiveRate != null">
        RECEIVE_RATE,
      </if>
      <if test="payCurrency != null">
        PAY_CURRENCY,
      </if>
      <if test="receiveCurrency != null">
        RECEIVE_CURRENCY,
      </if>
      <if test="keyDescription != null">
        KEY_DESCRIPTION,
      </if>
      <if test="valDescription != null">
        VAL_DESCRIPTION,
      </if>
      <if test="effectiveDate != null">
        EFFECTIVE_DATE,
      </if>
      <if test="expiredDate != null">
        EXPIRED_DATE,
      </if>
      <if test="appendlxNotes != null">
        APPENDLX_NOTES,
      </if>
      <if test="confirmStatus != null">
        CONFIRM_STATUS,
      </if>
      <if test="confirmBy != null">
        CONFIRM_BY,
      </if>
      <if test="confirmOn != null">
        CONFIRM_ON,
      </if>
      <if test="delFlag != null">
        DEL_FLAG,
      </if>
      <if test="byton != null">
        BYTON,
      </if>
      <if test="minAmount != null">
        MIN_AMOUNT,
      </if>
      <if test="maxAmount != null">
        MAX_AMOUNT,
      </if>
      <if test="isFormat != null">
        IS_FORMAT,
      </if>
      <if test="verifyFlag != null">
        VERIFY_FLAG,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="tenancyId != null">
        #{tenancyId,jdbcType=VARCHAR},
      </if>
      <if test="chargingId != null">
        #{chargingId,jdbcType=VARCHAR},
      </if>
      <if test="rate != null">
        #{rate,jdbcType=DECIMAL},
      </if>
      <if test="currency != null">
        #{currency,jdbcType=VARCHAR},
      </if>
      <if test="notes != null">
        #{notes,jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="createdOn != null">
        #{createdOn,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedOn != null">
        #{updatedOn,jdbcType=TIMESTAMP},
      </if>
      <if test="contractId != null">
        #{contractId,jdbcType=VARCHAR},
      </if>
      <if test="amountFormat != null">
        #{amountFormat,jdbcType=DECIMAL},
      </if>
      <if test="formatUnit != null">
        #{formatUnit,jdbcType=DECIMAL},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=DECIMAL},
      </if>
      <if test="volPrice != null">
        #{volPrice,jdbcType=DECIMAL},
      </if>
      <if test="receiveCode != null">
        #{receiveCode,jdbcType=VARCHAR},
      </if>
      <if test="payCode != null">
        #{payCode,jdbcType=VARCHAR},
      </if>
      <if test="payRate != null">
        #{payRate,jdbcType=DECIMAL},
      </if>
      <if test="receiveRate != null">
        #{receiveRate,jdbcType=DECIMAL},
      </if>
      <if test="payCurrency != null">
        #{payCurrency,jdbcType=VARCHAR},
      </if>
      <if test="receiveCurrency != null">
        #{receiveCurrency,jdbcType=VARCHAR},
      </if>
      <if test="keyDescription != null">
        #{keyDescription,jdbcType=VARCHAR},
      </if>
      <if test="valDescription != null">
        #{valDescription,jdbcType=VARCHAR},
      </if>
      <if test="effectiveDate != null">
        #{effectiveDate,jdbcType=TIMESTAMP},
      </if>
      <if test="expiredDate != null">
        #{expiredDate,jdbcType=TIMESTAMP},
      </if>
      <if test="appendlxNotes != null">
        #{appendlxNotes,jdbcType=VARCHAR},
      </if>
      <if test="confirmStatus != null">
        #{confirmStatus,jdbcType=DECIMAL},
      </if>
      <if test="confirmBy != null">
        #{confirmBy,jdbcType=VARCHAR},
      </if>
      <if test="confirmOn != null">
        #{confirmOn,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=DECIMAL},
      </if>
      <if test="byton != null">
        #{byton,jdbcType=DECIMAL},
      </if>
      <if test="minAmount != null">
        #{minAmount,jdbcType=DECIMAL},
      </if>
      <if test="maxAmount != null">
        #{maxAmount,jdbcType=DECIMAL},
      </if>
      <if test="isFormat != null">
        #{isFormat,jdbcType=DECIMAL},
      </if>
      <if test="verifyFlag != null">
        #{verifyFlag,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.ag.ctc.domain.pojo.Ctariff">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update C_TARIFF
    <set>
      <if test="tenancyId != null">
        TENANCY_ID = #{tenancyId,jdbcType=VARCHAR},
      </if>
      <if test="chargingId != null">
        CHARGING_ID = #{chargingId,jdbcType=VARCHAR},
      </if>
      <if test="rate != null">
        RATE = #{rate,jdbcType=DECIMAL},
      </if>
      <if test="currency != null">
        CURRENCY = #{currency,jdbcType=VARCHAR},
      </if>
      <if test="notes != null">
        NOTES = #{notes,jdbcType=VARCHAR},
      </if>
      <if test="createdBy != null">
        CREATED_BY = #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="createdOn != null">
        CREATED_ON = #{createdOn,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        UPDATED_BY = #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedOn != null">
        UPDATED_ON = #{updatedOn,jdbcType=TIMESTAMP},
      </if>
      <if test="contractId != null">
        CONTRACT_ID = #{contractId,jdbcType=VARCHAR},
      </if>
      <if test="amountFormat != null">
        AMOUNT_FORMAT = #{amountFormat,jdbcType=DECIMAL},
      </if>
      <if test="formatUnit != null">
        FORMAT_UNIT = #{formatUnit,jdbcType=DECIMAL},
      </if>
      <if test="sort != null">
        SORT = #{sort,jdbcType=DECIMAL},
      </if>
      <if test="volPrice != null">
        VOL_PRICE = #{volPrice,jdbcType=DECIMAL},
      </if>
      <if test="receiveCode != null">
        RECEIVE_CODE = #{receiveCode,jdbcType=VARCHAR},
      </if>
      <if test="payCode != null">
        PAY_CODE = #{payCode,jdbcType=VARCHAR},
      </if>
      <if test="payRate != null">
        PAY_RATE = #{payRate,jdbcType=DECIMAL},
      </if>
      <if test="receiveRate != null">
        RECEIVE_RATE = #{receiveRate,jdbcType=DECIMAL},
      </if>
      <if test="payCurrency != null">
        PAY_CURRENCY = #{payCurrency,jdbcType=VARCHAR},
      </if>
      <if test="receiveCurrency != null">
        RECEIVE_CURRENCY = #{receiveCurrency,jdbcType=VARCHAR},
      </if>
      <if test="keyDescription != null">
        KEY_DESCRIPTION = #{keyDescription,jdbcType=VARCHAR},
      </if>
      <if test="valDescription != null">
        VAL_DESCRIPTION = #{valDescription,jdbcType=VARCHAR},
      </if>
      <!--<if test="effectiveDate != null">-->
        EFFECTIVE_DATE = #{effectiveDate,jdbcType=TIMESTAMP},
      <!--</if>-->
      <!--<if test="expiredDate != null">-->
        EXPIRED_DATE = #{expiredDate,jdbcType=TIMESTAMP},
      <!--</if>-->
      <!--<if test="appendlxNotes != null">-->
        APPENDLX_NOTES = #{appendlxNotes,jdbcType=VARCHAR},
      <!--</if>-->
      <if test="confirmStatus != null">
        CONFIRM_STATUS = #{confirmStatus,jdbcType=DECIMAL},
      </if>
      <if test="confirmBy != null">
        CONFIRM_BY = #{confirmBy,jdbcType=VARCHAR},
      </if>
      <if test="confirmOn != null">
        CONFIRM_ON = #{confirmOn,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        DEL_FLAG = #{delFlag,jdbcType=DECIMAL},
      </if>
      <if test="byton != null">
        BYTON = #{byton,jdbcType=DECIMAL},
      </if>
      <if test="minAmount != null">
        MIN_AMOUNT = #{minAmount,jdbcType=DECIMAL},
      </if>
      <if test="maxAmount != null">
        MAX_AMOUNT = #{maxAmount,jdbcType=DECIMAL},
      </if>
      <if test="isFormat != null">
        IS_FORMAT = #{isFormat,jdbcType=DECIMAL},
      </if>
      <if test="verifyFlag != null">
        VERIFY_FLAG = #{verifyFlag,jdbcType=DECIMAL},
      </if>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ag.ctc.domain.pojo.Ctariff">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update C_TARIFF
    set TENANCY_ID = #{tenancyId,jdbcType=VARCHAR},
      CHARGING_ID = #{chargingId,jdbcType=VARCHAR},
      RATE = #{rate,jdbcType=DECIMAL},
      CURRENCY = #{currency,jdbcType=VARCHAR},
      NOTES = #{notes,jdbcType=VARCHAR},
      CREATED_BY = #{createdBy,jdbcType=VARCHAR},
      CREATED_ON = #{createdOn,jdbcType=TIMESTAMP},
      UPDATED_BY = #{updatedBy,jdbcType=VARCHAR},
      UPDATED_ON = #{updatedOn,jdbcType=TIMESTAMP},
      CONTRACT_ID = #{contractId,jdbcType=VARCHAR},
      AMOUNT_FORMAT = #{amountFormat,jdbcType=DECIMAL},
      FORMAT_UNIT = #{formatUnit,jdbcType=DECIMAL},
      SORT = #{sort,jdbcType=DECIMAL},
      VOL_PRICE = #{volPrice,jdbcType=DECIMAL},
      RECEIVE_CODE = #{receiveCode,jdbcType=VARCHAR},
      PAY_CODE = #{payCode,jdbcType=VARCHAR},
      PAY_RATE = #{payRate,jdbcType=DECIMAL},
      RECEIVE_RATE = #{receiveRate,jdbcType=DECIMAL},
      PAY_CURRENCY = #{payCurrency,jdbcType=VARCHAR},
      RECEIVE_CURRENCY = #{receiveCurrency,jdbcType=VARCHAR},
      KEY_DESCRIPTION = #{keyDescription,jdbcType=VARCHAR},
      VAL_DESCRIPTION = #{valDescription,jdbcType=VARCHAR},
      EFFECTIVE_DATE = #{effectiveDate,jdbcType=TIMESTAMP},
      EXPIRED_DATE = #{expiredDate,jdbcType=TIMESTAMP},
      APPENDLX_NOTES = #{appendlxNotes,jdbcType=VARCHAR},
      CONFIRM_STATUS = #{confirmStatus,jdbcType=DECIMAL},
      CONFIRM_BY = #{confirmBy,jdbcType=VARCHAR},
      CONFIRM_ON = #{confirmOn,jdbcType=TIMESTAMP},
      DEL_FLAG = #{delFlag,jdbcType=DECIMAL},
      BYTON = #{byton,jdbcType=DECIMAL},
      MIN_AMOUNT = #{minAmount,jdbcType=DECIMAL},
      MAX_AMOUNT = #{maxAmount,jdbcType=DECIMAL},
      IS_FORMAT = #{isFormat,jdbcType=DECIMAL},
      VERIFY_FLAG = #{verifyFlag,jdbcType=DECIMAL}
    where ID = #{id,jdbcType=VARCHAR}
  </update>


  <select id="selectByitemid" parameterType="map" resultMap="BaseResultMap">

    select
    ID, TENANCY_ID, CHARGING_ID, RATE, CURRENCY, NOTES, CREATED_BY, CREATED_ON, UPDATED_BY,
    UPDATED_ON, CONTRACT_ID, AMOUNT_FORMAT, FORMAT_UNIT, SORT, VOL_PRICE, RECEIVE_CODE,
    PAY_CODE, PAY_RATE, RECEIVE_RATE, PAY_CURRENCY, RECEIVE_CURRENCY, KEY_DESCRIPTION,
    VAL_DESCRIPTION, EFFECTIVE_DATE, EXPIRED_DATE, APPENDLX_NOTES, CONFIRM_STATUS, CONFIRM_BY,
    CONFIRM_ON, DEL_FLAG, BYTON, MIN_AMOUNT, MAX_AMOUNT, IS_FORMAT, VERIFY_FLAG
    from C_TARIFF
    where CHARGING_ID = #{itemId,jdbcType=VARCHAR}
    and CONTRACT_ID = #{contractId,jdbcType=VARCHAR}
    and del_flag = 0
    <if test="confirmStatus != null">
      and CONFIRM_STATUS = #{confirmStatus}
    </if>
  </select>
  <select id="selectpropertyByitemid" parameterType="java.lang.String" resultType="map">

    select * from C_ITEM_PROPERTIES where ITEM_ID=#{id,jdbcType=VARCHAR}
  </select>
  <update id="updateDelFlagById" parameterType="java.lang.String">
    update C_TARIFF
    set DEL_FLAG = 1
    where ID = #{id,jdbcType=VARCHAR}
  </update>
</mapper>