<?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.goafanti.common.dao.TArrearsDunMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.TArrearsDun">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
    <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
    <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
    <result column="order_receivables" jdbcType="DECIMAL" property="orderReceivables" />
    <result column="order_arrears" jdbcType="DECIMAL" property="orderArrears" />
    <result column="dun_status" jdbcType="INTEGER" property="dunStatus" />
    <result column="type" jdbcType="INTEGER" property="type" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    <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.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    <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.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    id, create_time, start_time, end_time, order_no, order_receivables, order_arrears, 
    dun_status, type
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.TArrearsDunExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from t_arrears_dun
    <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.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    select 
    <include refid="Base_Column_List" />
    from t_arrears_dun
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    delete from t_arrears_dun
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.TArrearsDunExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    delete from t_arrears_dun
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.TArrearsDun">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    insert into t_arrears_dun (id, create_time, start_time, 
      end_time, order_no, order_receivables, 
      order_arrears, dun_status, type
      )
    values (#{id,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{startTime,jdbcType=TIMESTAMP}, 
      #{endTime,jdbcType=TIMESTAMP}, #{orderNo,jdbcType=VARCHAR}, #{orderReceivables,jdbcType=DECIMAL}, 
      #{orderArrears,jdbcType=DECIMAL}, #{dunStatus,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.TArrearsDun">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    insert into t_arrears_dun
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="orderNo != null">
        order_no,
      </if>
      <if test="orderReceivables != null">
        order_receivables,
      </if>
      <if test="orderArrears != null">
        order_arrears,
      </if>
      <if test="dunStatus != null">
        dun_status,
      </if>
      <if test="type != null">
        type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="orderNo != null">
        #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="orderReceivables != null">
        #{orderReceivables,jdbcType=DECIMAL},
      </if>
      <if test="orderArrears != null">
        #{orderArrears,jdbcType=DECIMAL},
      </if>
      <if test="dunStatus != null">
        #{dunStatus,jdbcType=INTEGER},
      </if>
      <if test="type != null">
        #{type,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.TArrearsDunExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    select count(*) from t_arrears_dun
    <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.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    update t_arrears_dun
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.startTime != null">
        start_time = #{record.startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.endTime != null">
        end_time = #{record.endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.orderNo != null">
        order_no = #{record.orderNo,jdbcType=VARCHAR},
      </if>
      <if test="record.orderReceivables != null">
        order_receivables = #{record.orderReceivables,jdbcType=DECIMAL},
      </if>
      <if test="record.orderArrears != null">
        order_arrears = #{record.orderArrears,jdbcType=DECIMAL},
      </if>
      <if test="record.dunStatus != null">
        dun_status = #{record.dunStatus,jdbcType=INTEGER},
      </if>
      <if test="record.type != null">
        type = #{record.type,jdbcType=INTEGER},
      </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.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    update t_arrears_dun
    set id = #{record.id,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      start_time = #{record.startTime,jdbcType=TIMESTAMP},
      end_time = #{record.endTime,jdbcType=TIMESTAMP},
      order_no = #{record.orderNo,jdbcType=VARCHAR},
      order_receivables = #{record.orderReceivables,jdbcType=DECIMAL},
      order_arrears = #{record.orderArrears,jdbcType=DECIMAL},
      dun_status = #{record.dunStatus,jdbcType=INTEGER},
      type = #{record.type,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TArrearsDun">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    update t_arrears_dun
    <set>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        end_time = #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="orderNo != null">
        order_no = #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="orderReceivables != null">
        order_receivables = #{orderReceivables,jdbcType=DECIMAL},
      </if>
      <if test="orderArrears != null">
        order_arrears = #{orderArrears,jdbcType=DECIMAL},
      </if>
      <if test="dunStatus != null">
        dun_status = #{dunStatus,jdbcType=INTEGER},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TArrearsDun">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 15 15:52:48 CST 2020.
    -->
    update t_arrears_dun
    set create_time = #{createTime,jdbcType=TIMESTAMP},
      start_time = #{startTime,jdbcType=TIMESTAMP},
      end_time = #{endTime,jdbcType=TIMESTAMP},
      order_no = #{orderNo,jdbcType=VARCHAR},
      order_receivables = #{orderReceivables,jdbcType=DECIMAL},
      order_arrears = #{orderArrears,jdbcType=DECIMAL},
      dun_status = #{dunStatus,jdbcType=INTEGER},
      type = #{type,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="checkOrderNo" resultType="java.lang.Integer">
  select count(*) from t_arrears_dun where 1=1
  <if test="status !=null ">
  and dun_status= #{status,jdbcType=INTEGER} 
  </if>
  and order_no= #{orderNo,jdbcType=VARCHAR}
  </select>
  <select id="selectByStatus" resultType="java.lang.Integer">
  select id from t_arrears_dun where 1=1
  <if test="status !=null ">
  and dun_status= #{status,jdbcType=INTEGER} 
  </if>
  and order_no= #{orderNo,jdbcType=VARCHAR}
  limit 1
  </select>
  
  
  <select id="selectStatusAll" resultType="com.goafanti.common.model.TArrearsDun">
  select id,create_time createTime,order_no orderNo,order_arrears orderArrears,order_receivables orderReceivables,
	dun_status dunStatus,start_time startTime, end_time endTime from t_arrears_dun  
  where dun_status= #{status}
  </select>
  
  <select id="selectStatusAndAmount" resultType="com.goafanti.common.model.TArrearsDun">
  select a.id,a.order_no orderNo,a.order_arrears orderArrears,a.order_receivables orderReceivables,
	a.dun_status dunStatus from t_arrears_dun a left join t_order_mid b on a.order_no=b.order_no   
  where b.order_arrears !=0 and dun_status= #{status}
  </select>
</mapper>