<?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.SettlementDetailSupplierMapper">
  
<resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.settlement.po.SettlementDetailSupplier">
  <id column="id" jdbcType="INTEGER" property="id" />
  <result column="settlement_id" jdbcType="VARCHAR" property="settlementId" />
  <result column="order_id" jdbcType="VARCHAR" property="orderId" />
  <result column="user_name" jdbcType="VARCHAR" property="userName" />
  <result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
  <result column="survey_fee" jdbcType="DECIMAL" property="surveyFee" />
  <result column="survey_fee_with_tax" jdbcType="DECIMAL" property="surveyFeeWithTax" />
  <result column="item_fee" jdbcType="DECIMAL" property="itemFee" />
  <result column="item_fee_with_tax" jdbcType="DECIMAL" property="itemFeeWithTax" />
  <result column="install_fee" jdbcType="DECIMAL" property="installFee" />
  <result column="install_fee_with_tax" jdbcType="DECIMAL" property="installFeeWithTax" />
  <result column="expand_fee" jdbcType="DECIMAL" property="expandFee" />
  <result column="total_fee" jdbcType="DECIMAL" property="totalFee" />
  <result column="total_fee_with_tax" jdbcType="DECIMAL" property="totalFeeWithTax" />
  <result column="finish_time" jdbcType="TIMESTAMP" property="finishTime" />
  <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  <result column="is_del" jdbcType="INTEGER" property="isDel" />
</resultMap>

  
<sql id="Base_Column_List">
  id, settlement_id, order_id, user_name, user_phone, survey_fee, survey_fee_with_tax, 
  item_fee, item_fee_with_tax, install_fee, install_fee_with_tax, expand_fee, total_fee, 
  total_fee_with_tax, finish_time, create_time,is_del
</sql>

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

    <insert id="insert" parameterType="com.boco.nbd.wios.manage.entity.settlement.po.SettlementDetailSupplier">
  insert into t_settlement_detail_supplier (id, settlement_id, order_id, 
    user_name, user_phone, survey_fee, 
    survey_fee_with_tax, item_fee, item_fee_with_tax, 
    install_fee, install_fee_with_tax, expand_fee, 
    total_fee, total_fee_with_tax, finish_time, 
    create_time)
  values (#{id,jdbcType=INTEGER}, #{settlementId,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR}, 
    #{userName,jdbcType=VARCHAR}, #{userPhone,jdbcType=VARCHAR}, #{surveyFee,jdbcType=DECIMAL}, 
    #{surveyFeeWithTax,jdbcType=DECIMAL}, #{itemFee,jdbcType=DECIMAL}, #{itemFeeWithTax,jdbcType=DECIMAL}, 
    #{installFee,jdbcType=DECIMAL}, #{installFeeWithTax,jdbcType=DECIMAL}, #{expandFee,jdbcType=DECIMAL}, 
    #{totalFee,jdbcType=DECIMAL}, #{totalFeeWithTax,jdbcType=DECIMAL}, #{finishTime,jdbcType=TIMESTAMP}, 
    #{createTime,jdbcType=TIMESTAMP})
</insert>

  
<insert id="insertDynamic" parameterType="com.boco.nbd.wios.manage.entity.settlement.po.SettlementDetailSupplier">
  insert into t_settlement_detail_supplier
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="id != null">
      id,
    </if>
    <if test="settlementId != null">
      settlement_id,
    </if>
    <if test="orderId != null">
      order_id,
    </if>
    <if test="userName != null">
      user_name,
    </if>
    <if test="userPhone != null">
      user_phone,
    </if>
    <if test="surveyFee != null">
      survey_fee,
    </if>
    <if test="surveyFeeWithTax != null">
      survey_fee_with_tax,
    </if>
    <if test="itemFee != null">
      item_fee,
    </if>
    <if test="itemFeeWithTax != null">
      item_fee_with_tax,
    </if>
    <if test="installFee != null">
      install_fee,
    </if>
    <if test="installFeeWithTax != null">
      install_fee_with_tax,
    </if>
    <if test="expandFee != null">
      expand_fee,
    </if>
    <if test="totalFee != null">
      total_fee,
    </if>
    <if test="totalFeeWithTax != null">
      total_fee_with_tax,
    </if>
    <if test="finishTime != null">
      finish_time,
    </if>
    <if test="createTime != null">
      create_time,
    </if>
  </trim>
  <trim prefix="values (" suffix=")" suffixOverrides=",">
    <if test="id != null">
      #{id,jdbcType=INTEGER},
    </if>
    <if test="settlementId != null">
      #{settlementId,jdbcType=VARCHAR},
    </if>
    <if test="orderId != null">
      #{orderId,jdbcType=VARCHAR},
    </if>
    <if test="userName != null">
      #{userName,jdbcType=VARCHAR},
    </if>
    <if test="userPhone != null">
      #{userPhone,jdbcType=VARCHAR},
    </if>
    <if test="surveyFee != null">
      #{surveyFee,jdbcType=DECIMAL},
    </if>
    <if test="surveyFeeWithTax != null">
      #{surveyFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="itemFee != null">
      #{itemFee,jdbcType=DECIMAL},
    </if>
    <if test="itemFeeWithTax != null">
      #{itemFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="installFee != null">
      #{installFee,jdbcType=DECIMAL},
    </if>
    <if test="installFeeWithTax != null">
      #{installFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="expandFee != null">
      #{expandFee,jdbcType=DECIMAL},
    </if>
    <if test="totalFee != null">
      #{totalFee,jdbcType=DECIMAL},
    </if>
    <if test="totalFeeWithTax != null">
      #{totalFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="finishTime != null">
      #{finishTime,jdbcType=TIMESTAMP},
    </if>
    <if test="createTime != null">
      #{createTime,jdbcType=TIMESTAMP},
    </if>
  </trim>
</insert>

  
<update id="updateDynamic" parameterType="com.boco.nbd.wios.manage.entity.settlement.po.SettlementDetailSupplier">
  update t_settlement_detail_supplier
  <set>
    <if test="settlementId != null">
      settlement_id = #{settlementId,jdbcType=VARCHAR},
    </if>
    <if test="orderId != null">
      order_id = #{orderId,jdbcType=VARCHAR},
    </if>
    <if test="userName != null">
      user_name = #{userName,jdbcType=VARCHAR},
    </if>
    <if test="userPhone != null">
      user_phone = #{userPhone,jdbcType=VARCHAR},
    </if>
    <if test="surveyFee != null">
      survey_fee = #{surveyFee,jdbcType=DECIMAL},
    </if>
    <if test="surveyFeeWithTax != null">
      survey_fee_with_tax = #{surveyFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="itemFee != null">
      item_fee = #{itemFee,jdbcType=DECIMAL},
    </if>
    <if test="itemFeeWithTax != null">
      item_fee_with_tax = #{itemFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="installFee != null">
      install_fee = #{installFee,jdbcType=DECIMAL},
    </if>
    <if test="installFeeWithTax != null">
      install_fee_with_tax = #{installFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="expandFee != null">
      expand_fee = #{expandFee,jdbcType=DECIMAL},
    </if>
    <if test="totalFee != null">
      total_fee = #{totalFee,jdbcType=DECIMAL},
    </if>
    <if test="totalFeeWithTax != null">
      total_fee_with_tax = #{totalFeeWithTax,jdbcType=DECIMAL},
    </if>
    <if test="finishTime != null">
      finish_time = #{finishTime,jdbcType=TIMESTAMP},
    </if>
    <if test="createTime != null">
      create_time = #{createTime,jdbcType=TIMESTAMP},
    </if>
  </set>
  where id = #{id,jdbcType=INTEGER}
</update>

  
<update id="update" parameterType="com.boco.nbd.wios.manage.entity.settlement.po.SettlementDetailSupplier">
  update t_settlement_detail_supplier
  set settlement_id = #{settlementId,jdbcType=VARCHAR},
    order_id = #{orderId,jdbcType=VARCHAR},
    user_name = #{userName,jdbcType=VARCHAR},
    user_phone = #{userPhone,jdbcType=VARCHAR},
    survey_fee = #{surveyFee,jdbcType=DECIMAL},
    survey_fee_with_tax = #{surveyFeeWithTax,jdbcType=DECIMAL},
    item_fee = #{itemFee,jdbcType=DECIMAL},
    item_fee_with_tax = #{itemFeeWithTax,jdbcType=DECIMAL},
    install_fee = #{installFee,jdbcType=DECIMAL},
    install_fee_with_tax = #{installFeeWithTax,jdbcType=DECIMAL},
    expand_fee = #{expandFee,jdbcType=DECIMAL},
    total_fee = #{totalFee,jdbcType=DECIMAL},
    total_fee_with_tax = #{totalFeeWithTax,jdbcType=DECIMAL},
    finish_time = #{finishTime,jdbcType=TIMESTAMP},
    create_time = #{createTime,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_settlement_detail_supplier
  where id = #{id,jdbcType=INTEGER}
</select>

  
<select id="selectBySupplierId" resultMap="BaseResultMap">
  select t.*
  from  t_settlement_detail_supplier t
  left join t_order o on o.id=t.order_id
  where 
  o.install_supplier_id = #{supplierId,jdbcType=INTEGER} 
  and
  t.finish_time &gt; #{finishStartTime,jdbcType=VARCHAR}
  and
  t.finish_time &lt; #{finishEndTime,jdbcType=VARCHAR}
</select>

<select id="selectBySettlementId" resultMap="BaseResultMap">
  select t.*
  from  t_settlement_detail_supplier t
  where 
  t.settlement_id=#{settlementId}
</select>

<update id="batchUpdateSettlementId">
  update t_settlement_detail_supplier
  set settlement_id = #{settlementId,jdbcType=VARCHAR}
  where id in
    <foreach collection="idList" index="index" item="item" separator="," open="(" close=")">
        #{item}
    </foreach>
</update>

<update id="deleteByOrderId">
  UPDATE t_settlement_detail_supplier
  SET is_del = 1
  WHERE
      order_id = #{orderId,jdbcType=VARCHAR}
</update>
</mapper>