<?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.boco.nbd.wios.manage.mapper.def.SupplierContractPriceMapper">
  
<resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.SupplierContractPrice">
  <id column="id" jdbcType="INTEGER" property="id" />
  <result column="contract_id" jdbcType="INTEGER" property="contractId" />
  <result column="region_id" jdbcType="INTEGER" property="regionId" />
  <result column="oem_id" jdbcType="INTEGER" property="oemId" />
  <result column="device_model" jdbcType="VARCHAR" property="deviceModel" />
  <result column="survey_price" jdbcType="DECIMAL" property="surveyPrice" />
  <result column="survey_rate_price" jdbcType="DECIMAL" property="surveyRatePrice" />
  <result column="installation_price" jdbcType="DECIMAL" property="installationPrice" />
  <result column="installation_rate_price" jdbcType="DECIMAL" property="installationRatePrice" />
  <result column="description" jdbcType="VARCHAR" property="description" />
  <result column="create_account" jdbcType="VARCHAR" property="createAccount" />
  <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  <result column="modify_account" jdbcType="VARCHAR" property="modifyAccount" />
  <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
</resultMap>

  
<sql id="Base_Column_List">
  id, contract_id, region_id, oem_id, device_model, survey_price, survey_rate_price, 
  installation_price, installation_rate_price, description, create_account, create_time, 
  modify_account, modify_time
</sql>

  
<delete id="delete" parameterType="java.lang.Integer">
  delete from t_supplier_contract_price
  where id = #{id,jdbcType=INTEGER}
</delete>

  
<insert id="insert" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPrice">
  insert into t_supplier_contract_price (id, contract_id, region_id, 
    oem_id, device_model, survey_price, 
    survey_rate_price, installation_price, installation_rate_price, 
    description, create_account, create_time, 
    modify_account, modify_time)
  values (#{id,jdbcType=INTEGER}, #{contractId,jdbcType=INTEGER}, #{regionId,jdbcType=INTEGER}, 
    #{oemId,jdbcType=INTEGER}, #{deviceModel,jdbcType=VARCHAR}, #{surveyPrice,jdbcType=DECIMAL}, 
    #{surveyRatePrice,jdbcType=DECIMAL}, #{installationPrice,jdbcType=DECIMAL}, #{installationRatePrice,jdbcType=DECIMAL}, 
    #{description,jdbcType=VARCHAR}, #{createAccount,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
    #{modifyAccount,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP})
</insert>

  
<insert id="insertDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPrice">
  insert into t_supplier_contract_price
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="id != null">
      id,
    </if>
    <if test="contractId != null">
      contract_id,
    </if>
    <if test="regionId != null">
      region_id,
    </if>
    <if test="oemId != null">
      oem_id,
    </if>
    <if test="deviceModel != null">
      device_model,
    </if>
    <if test="surveyPrice != null">
      survey_price,
    </if>
    <if test="surveyRatePrice != null">
      survey_rate_price,
    </if>
    <if test="installationPrice != null">
      installation_price,
    </if>
    <if test="installationRatePrice != null">
      installation_rate_price,
    </if>
    <if test="description != null">
      description,
    </if>
    <if test="createAccount != null">
      create_account,
    </if>
    <if test="createTime != null">
      create_time,
    </if>
    <if test="modifyAccount != null">
      modify_account,
    </if>
    <if test="modifyTime != null">
      modify_time,
    </if>
  </trim>
  <trim prefix="values (" suffix=")" suffixOverrides=",">
    <if test="id != null">
      #{id,jdbcType=INTEGER},
    </if>
    <if test="contractId != null">
      #{contractId,jdbcType=INTEGER},
    </if>
    <if test="regionId != null">
      #{regionId,jdbcType=INTEGER},
    </if>
    <if test="oemId != null">
      #{oemId,jdbcType=INTEGER},
    </if>
    <if test="deviceModel != null">
      #{deviceModel,jdbcType=VARCHAR},
    </if>
    <if test="surveyPrice != null">
      #{surveyPrice,jdbcType=DECIMAL},
    </if>
    <if test="surveyRatePrice != null">
      #{surveyRatePrice,jdbcType=DECIMAL},
    </if>
    <if test="installationPrice != null">
      #{installationPrice,jdbcType=DECIMAL},
    </if>
    <if test="installationRatePrice != null">
      #{installationRatePrice,jdbcType=DECIMAL},
    </if>
    <if test="description != null">
      #{description,jdbcType=VARCHAR},
    </if>
    <if test="createAccount != null">
      #{createAccount,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      #{createTime,jdbcType=TIMESTAMP},
    </if>
    <if test="modifyAccount != null">
      #{modifyAccount,jdbcType=VARCHAR},
    </if>
    <if test="modifyTime != null">
      #{modifyTime,jdbcType=TIMESTAMP},
    </if>
  </trim>
</insert>

  
<update id="updateDynamic" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPrice">
  update t_supplier_contract_price
  <set>
    <if test="contractId != null">
      contract_id = #{contractId,jdbcType=INTEGER},
    </if>
    <if test="regionId != null">
      region_id = #{regionId,jdbcType=INTEGER},
    </if>
    <if test="oemId != null">
      oem_id = #{oemId,jdbcType=INTEGER},
    </if>
    <if test="deviceModel != null">
      device_model = #{deviceModel,jdbcType=VARCHAR},
    </if>
    <if test="surveyPrice != null">
      survey_price = #{surveyPrice,jdbcType=DECIMAL},
    </if>
    <if test="surveyRatePrice != null">
      survey_rate_price = #{surveyRatePrice,jdbcType=DECIMAL},
    </if>
    <if test="installationPrice != null">
      installation_price = #{installationPrice,jdbcType=DECIMAL},
    </if>
    <if test="installationRatePrice != null">
      installation_rate_price = #{installationRatePrice,jdbcType=DECIMAL},
    </if>
    <if test="description != null">
      description = #{description,jdbcType=VARCHAR},
    </if>
    <if test="createAccount != null">
      create_account = #{createAccount,jdbcType=VARCHAR},
    </if>
    <if test="createTime != null">
      create_time = #{createTime,jdbcType=TIMESTAMP},
    </if>
    <if test="modifyAccount != null">
      modify_account = #{modifyAccount,jdbcType=VARCHAR},
    </if>
    <if test="modifyTime != null">
      modify_time = #{modifyTime,jdbcType=TIMESTAMP},
    </if>
  </set>
  where id = #{id,jdbcType=INTEGER}
</update>

  
<update id="update" parameterType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPrice">
  update t_supplier_contract_price
  set contract_id = #{contractId,jdbcType=INTEGER},
    region_id = #{regionId,jdbcType=INTEGER},
    oem_id = #{oemId,jdbcType=INTEGER},
    device_model = #{deviceModel,jdbcType=VARCHAR},
    survey_price = #{surveyPrice,jdbcType=DECIMAL},
    survey_rate_price = #{surveyRatePrice,jdbcType=DECIMAL},
    installation_price = #{installationPrice,jdbcType=DECIMAL},
    installation_rate_price = #{installationRatePrice,jdbcType=DECIMAL},
    description = #{description,jdbcType=VARCHAR},
    create_account = #{createAccount,jdbcType=VARCHAR},
    create_time = #{createTime,jdbcType=TIMESTAMP},
    modify_account = #{modifyAccount,jdbcType=VARCHAR},
    modify_time = #{modifyTime,jdbcType=TIMESTAMP}
  where id = #{id,jdbcType=INTEGER}
</update>

  
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  select
	<include refid="Base_Column_List" />
  from  t_supplier_contract_price
  where id = #{id,jdbcType=INTEGER}
</select>

<select id="selectByContractId" parameterType="java.lang.Integer" resultType="com.boco.nbd.wios.manage.entity.bo.SupplierContractPriceVo">
  select t.*,o.name as oemName,o.code as oemCode,
         r.name as regionName,r.id_tree as regionIdTree, a.name packTypeName
  from  t_supplier_contract_price t
  left join t_oem o on o.id=t.oem_id
  left join t_region r on r.id=t.region_id
  left join t_oem_cascade a on t.pack_type=a.id
  where t.contract_id = #{contractId,jdbcType=INTEGER}
</select>

<select id="selectPureByContractId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  select t.*
  from  t_supplier_contract_price t
  where t.contract_id = #{contractId,jdbcType=INTEGER}
</select>
  
<insert id="batchInsert" parameterType="java.util.List">
  insert into t_supplier_contract_price (id, contract_id, region_id, pack_type,
    oem_id, device_model, survey_price, 
    survey_rate_price, installation_price, installation_rate_price, 
    description, create_account, create_time, 
    modify_account, modify_time)
  values 
  <foreach collection="list" item="item" separator=",">
  (#{item.id,jdbcType=INTEGER}, #{item.contractId,jdbcType=INTEGER}, #{item.regionId,jdbcType=INTEGER}, #{item.packType,jdbcType=VARCHAR},
    #{item.oemId,jdbcType=INTEGER}, #{item.deviceModel,jdbcType=VARCHAR}, #{item.surveyPrice,jdbcType=DECIMAL}, 
    #{item.surveyRatePrice,jdbcType=DECIMAL}, #{item.installationPrice,jdbcType=DECIMAL}, #{item.installationRatePrice,jdbcType=DECIMAL}, 
    #{item.description,jdbcType=VARCHAR}, #{item.createAccount,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
    #{item.modifyAccount,jdbcType=VARCHAR}, #{item.modifyTime,jdbcType=TIMESTAMP})
   </foreach>
</insert>
  
<delete id="deleteByContractId" parameterType="java.lang.Integer">
  delete from t_supplier_contract_price
  where contract_id = #{contractId}
</delete>
  
</mapper>