<?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.TOrderMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    <id column="order_no" jdbcType="VARCHAR" property="orderNo" />
    <result column="order_type" jdbcType="INTEGER" property="orderType" />
    <result column="creater" jdbcType="VARCHAR" property="creater" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="buyer_id" jdbcType="VARCHAR" property="buyerId" />
    <result column="seller_id" jdbcType="VARCHAR" property="sellerId" />
    <result column="first_payment" jdbcType="DECIMAL" property="firstPayment" />
    <result column="order_amount" jdbcType="DECIMAL" property="orderAmount" />
    <result column="brokerage_amount" jdbcType="DECIMAL" property="brokerageAmount" />
    <result column="sign_first_payment" jdbcType="DECIMAL" property="signFirstPayment" />
    <result column="actually_first_payment" jdbcType="DECIMAL" property="actuallyFirstPayment" />
    <result column="sign_total_amount" jdbcType="DECIMAL" property="signTotalAmount" />
    <result column="actually_total_amount" jdbcType="DECIMAL" property="actuallyTotalAmount" />
    <result column="sign_brokerage_amount" jdbcType="DECIMAL" property="signBrokerageAmount" />
    <result column="actually_brokerage_amount" jdbcType="DECIMAL" property="actuallyBrokerageAmount" />
    <result column="sign_withdraw_amount" jdbcType="DECIMAL" property="signWithdrawAmount" />
    <result column="actually_withdraw_amount" jdbcType="DECIMAL" property="actuallyWithdrawAmount" />
    <result column="order_stage" jdbcType="INTEGER" property="orderStage" />
    <result column="project_stage" jdbcType="INTEGER" property="projectStage" />
    <result column="order_status" jdbcType="INTEGER" property="orderStatus" />
    <result column="liquidation_status" jdbcType="INTEGER" property="liquidationStatus" />
    <result column="order_channel" jdbcType="INTEGER" property="orderChannel" />
    <result column="approval" jdbcType="INTEGER" property="approval" />
    <result column="order_remarks" jdbcType="VARCHAR" property="orderRemarks" />
    <result column="delete_sign" jdbcType="INTEGER" property="deleteSign" />
    <result column="salesman_id" jdbcType="VARCHAR" property="salesmanId" />
    <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
    <result column="technician_id" jdbcType="VARCHAR" property="technicianId" />
    <result column="confirm_time" jdbcType="TIMESTAMP" property="confirmTime" />
    <result column="sign_time" jdbcType="TIMESTAMP" property="signTime" />
    <result column="set_up_time" jdbcType="TIMESTAMP" property="setUpTime" />
    <result column="settlement_time" jdbcType="TIMESTAMP" property="settlementTime" />
    <result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
    <result column="contract_type" jdbcType="VARCHAR" property="contractType" />
    <result column="change_status" jdbcType="INTEGER" property="changeStatus" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.goafanti.common.model.TOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    <result column="contract_picture_url" jdbcType="LONGVARCHAR" property="contractPictureUrl" />
  </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 11 14:30:55 CST 2018.
    -->
    <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 11 14:30:55 CST 2018.
    -->
    <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 11 14:30:55 CST 2018.
    -->
    order_no, order_type, creater, create_time, update_time, buyer_id, seller_id, first_payment, 
    order_amount, brokerage_amount, sign_first_payment, actually_first_payment, sign_total_amount, 
    actually_total_amount, sign_brokerage_amount, actually_brokerage_amount, sign_withdraw_amount, 
    actually_withdraw_amount, order_stage, project_stage, order_status, liquidation_status, 
    order_channel, approval, order_remarks, delete_sign, salesman_id, finance_id, technician_id, 
    confirm_time, sign_time, set_up_time, settlement_time, contract_no, contract_type, 
    change_status
  </sql>
  <sql id="Blob_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    contract_picture_url
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.goafanti.common.model.TOrderExample" resultMap="ResultMapWithBLOBs">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_order
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.goafanti.common.model.TOrderExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from t_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.String" resultMap="ResultMapWithBLOBs">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from t_order
    where order_no = #{orderNo,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    delete from t_order
    where order_no = #{orderNo,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.TOrderExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    delete from t_order
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.TOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    insert into t_order (order_no, order_type, creater, 
      create_time, update_time, buyer_id, 
      seller_id, first_payment, order_amount, 
      brokerage_amount, sign_first_payment, actually_first_payment, 
      sign_total_amount, actually_total_amount, sign_brokerage_amount, 
      actually_brokerage_amount, sign_withdraw_amount, 
      actually_withdraw_amount, order_stage, project_stage, 
      order_status, liquidation_status, order_channel, 
      approval, order_remarks, delete_sign, 
      salesman_id, finance_id, technician_id, 
      confirm_time, sign_time, set_up_time, 
      settlement_time, contract_no, contract_type, 
      change_status, contract_picture_url)
    values (#{orderNo,jdbcType=VARCHAR}, #{orderType,jdbcType=INTEGER}, #{creater,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{buyerId,jdbcType=VARCHAR}, 
      #{sellerId,jdbcType=VARCHAR}, #{firstPayment,jdbcType=DECIMAL}, #{orderAmount,jdbcType=DECIMAL}, 
      #{brokerageAmount,jdbcType=DECIMAL}, #{signFirstPayment,jdbcType=DECIMAL}, #{actuallyFirstPayment,jdbcType=DECIMAL}, 
      #{signTotalAmount,jdbcType=DECIMAL}, #{actuallyTotalAmount,jdbcType=DECIMAL}, #{signBrokerageAmount,jdbcType=DECIMAL}, 
      #{actuallyBrokerageAmount,jdbcType=DECIMAL}, #{signWithdrawAmount,jdbcType=DECIMAL}, 
      #{actuallyWithdrawAmount,jdbcType=DECIMAL}, #{orderStage,jdbcType=INTEGER}, #{projectStage,jdbcType=INTEGER}, 
      #{orderStatus,jdbcType=INTEGER}, #{liquidationStatus,jdbcType=INTEGER}, #{orderChannel,jdbcType=INTEGER}, 
      #{approval,jdbcType=INTEGER}, #{orderRemarks,jdbcType=VARCHAR}, #{deleteSign,jdbcType=INTEGER}, 
      #{salesmanId,jdbcType=VARCHAR}, #{financeId,jdbcType=VARCHAR}, #{technicianId,jdbcType=VARCHAR}, 
      #{confirmTime,jdbcType=TIMESTAMP}, #{signTime,jdbcType=TIMESTAMP}, #{setUpTime,jdbcType=TIMESTAMP}, 
      #{settlementTime,jdbcType=TIMESTAMP}, #{contractNo,jdbcType=VARCHAR}, #{contractType,jdbcType=VARCHAR}, 
      #{changeStatus,jdbcType=INTEGER}, #{contractPictureUrl,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.TOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    insert into t_order
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderNo != null">
        order_no,
      </if>
      <if test="orderType != null">
        order_type,
      </if>
      <if test="creater != null">
        creater,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="buyerId != null">
        buyer_id,
      </if>
      <if test="sellerId != null">
        seller_id,
      </if>
      <if test="firstPayment != null">
        first_payment,
      </if>
      <if test="orderAmount != null">
        order_amount,
      </if>
      <if test="brokerageAmount != null">
        brokerage_amount,
      </if>
      <if test="signFirstPayment != null">
        sign_first_payment,
      </if>
      <if test="actuallyFirstPayment != null">
        actually_first_payment,
      </if>
      <if test="signTotalAmount != null">
        sign_total_amount,
      </if>
      <if test="actuallyTotalAmount != null">
        actually_total_amount,
      </if>
      <if test="signBrokerageAmount != null">
        sign_brokerage_amount,
      </if>
      <if test="actuallyBrokerageAmount != null">
        actually_brokerage_amount,
      </if>
      <if test="signWithdrawAmount != null">
        sign_withdraw_amount,
      </if>
      <if test="actuallyWithdrawAmount != null">
        actually_withdraw_amount,
      </if>
      <if test="orderStage != null">
        order_stage,
      </if>
      <if test="projectStage != null">
        project_stage,
      </if>
      <if test="orderStatus != null">
        order_status,
      </if>
      <if test="liquidationStatus != null">
        liquidation_status,
      </if>
      <if test="orderChannel != null">
        order_channel,
      </if>
      <if test="approval != null">
        approval,
      </if>
      <if test="orderRemarks != null">
        order_remarks,
      </if>
      <if test="deleteSign != null">
        delete_sign,
      </if>
      <if test="salesmanId != null">
        salesman_id,
      </if>
      <if test="financeId != null">
        finance_id,
      </if>
      <if test="technicianId != null">
        technician_id,
      </if>
      <if test="confirmTime != null">
        confirm_time,
      </if>
      <if test="signTime != null">
        sign_time,
      </if>
      <if test="setUpTime != null">
        set_up_time,
      </if>
      <if test="settlementTime != null">
        settlement_time,
      </if>
      <if test="contractNo != null">
        contract_no,
      </if>
      <if test="contractType != null">
        contract_type,
      </if>
      <if test="changeStatus != null">
        change_status,
      </if>
      <if test="contractPictureUrl != null">
        contract_picture_url,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderNo != null">
        #{orderNo,jdbcType=VARCHAR},
      </if>
      <if test="orderType != null">
        #{orderType,jdbcType=INTEGER},
      </if>
      <if test="creater != null">
        #{creater,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="buyerId != null">
        #{buyerId,jdbcType=VARCHAR},
      </if>
      <if test="sellerId != null">
        #{sellerId,jdbcType=VARCHAR},
      </if>
      <if test="firstPayment != null">
        #{firstPayment,jdbcType=DECIMAL},
      </if>
      <if test="orderAmount != null">
        #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="brokerageAmount != null">
        #{brokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="signFirstPayment != null">
        #{signFirstPayment,jdbcType=DECIMAL},
      </if>
      <if test="actuallyFirstPayment != null">
        #{actuallyFirstPayment,jdbcType=DECIMAL},
      </if>
      <if test="signTotalAmount != null">
        #{signTotalAmount,jdbcType=DECIMAL},
      </if>
      <if test="actuallyTotalAmount != null">
        #{actuallyTotalAmount,jdbcType=DECIMAL},
      </if>
      <if test="signBrokerageAmount != null">
        #{signBrokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="actuallyBrokerageAmount != null">
        #{actuallyBrokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="signWithdrawAmount != null">
        #{signWithdrawAmount,jdbcType=DECIMAL},
      </if>
      <if test="actuallyWithdrawAmount != null">
        #{actuallyWithdrawAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderStage != null">
        #{orderStage,jdbcType=INTEGER},
      </if>
      <if test="projectStage != null">
        #{projectStage,jdbcType=INTEGER},
      </if>
      <if test="orderStatus != null">
        #{orderStatus,jdbcType=INTEGER},
      </if>
      <if test="liquidationStatus != null">
        #{liquidationStatus,jdbcType=INTEGER},
      </if>
      <if test="orderChannel != null">
        #{orderChannel,jdbcType=INTEGER},
      </if>
      <if test="approval != null">
        #{approval,jdbcType=INTEGER},
      </if>
      <if test="orderRemarks != null">
        #{orderRemarks,jdbcType=VARCHAR},
      </if>
      <if test="deleteSign != null">
        #{deleteSign,jdbcType=INTEGER},
      </if>
      <if test="salesmanId != null">
        #{salesmanId,jdbcType=VARCHAR},
      </if>
      <if test="financeId != null">
        #{financeId,jdbcType=VARCHAR},
      </if>
      <if test="technicianId != null">
        #{technicianId,jdbcType=VARCHAR},
      </if>
      <if test="confirmTime != null">
        #{confirmTime,jdbcType=TIMESTAMP},
      </if>
      <if test="signTime != null">
        #{signTime,jdbcType=TIMESTAMP},
      </if>
      <if test="setUpTime != null">
        #{setUpTime,jdbcType=TIMESTAMP},
      </if>
      <if test="settlementTime != null">
        #{settlementTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractNo != null">
        #{contractNo,jdbcType=VARCHAR},
      </if>
      <if test="contractType != null">
        #{contractType,jdbcType=VARCHAR},
      </if>
      <if test="changeStatus != null">
        #{changeStatus,jdbcType=INTEGER},
      </if>
      <if test="contractPictureUrl != null">
        #{contractPictureUrl,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.TOrderExample" 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 11 14:30:55 CST 2018.
    -->
    select count(*) from t_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.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    update t_order
    <set>
      <if test="record.orderNo != null">
        order_no = #{record.orderNo,jdbcType=VARCHAR},
      </if>
      <if test="record.orderType != null">
        order_type = #{record.orderType,jdbcType=INTEGER},
      </if>
      <if test="record.creater != null">
        creater = #{record.creater,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.buyerId != null">
        buyer_id = #{record.buyerId,jdbcType=VARCHAR},
      </if>
      <if test="record.sellerId != null">
        seller_id = #{record.sellerId,jdbcType=VARCHAR},
      </if>
      <if test="record.firstPayment != null">
        first_payment = #{record.firstPayment,jdbcType=DECIMAL},
      </if>
      <if test="record.orderAmount != null">
        order_amount = #{record.orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.brokerageAmount != null">
        brokerage_amount = #{record.brokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.signFirstPayment != null">
        sign_first_payment = #{record.signFirstPayment,jdbcType=DECIMAL},
      </if>
      <if test="record.actuallyFirstPayment != null">
        actually_first_payment = #{record.actuallyFirstPayment,jdbcType=DECIMAL},
      </if>
      <if test="record.signTotalAmount != null">
        sign_total_amount = #{record.signTotalAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.actuallyTotalAmount != null">
        actually_total_amount = #{record.actuallyTotalAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.signBrokerageAmount != null">
        sign_brokerage_amount = #{record.signBrokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.actuallyBrokerageAmount != null">
        actually_brokerage_amount = #{record.actuallyBrokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.signWithdrawAmount != null">
        sign_withdraw_amount = #{record.signWithdrawAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.actuallyWithdrawAmount != null">
        actually_withdraw_amount = #{record.actuallyWithdrawAmount,jdbcType=DECIMAL},
      </if>
      <if test="record.orderStage != null">
        order_stage = #{record.orderStage,jdbcType=INTEGER},
      </if>
      <if test="record.projectStage != null">
        project_stage = #{record.projectStage,jdbcType=INTEGER},
      </if>
      <if test="record.orderStatus != null">
        order_status = #{record.orderStatus,jdbcType=INTEGER},
      </if>
      <if test="record.liquidationStatus != null">
        liquidation_status = #{record.liquidationStatus,jdbcType=INTEGER},
      </if>
      <if test="record.orderChannel != null">
        order_channel = #{record.orderChannel,jdbcType=INTEGER},
      </if>
      <if test="record.approval != null">
        approval = #{record.approval,jdbcType=INTEGER},
      </if>
      <if test="record.orderRemarks != null">
        order_remarks = #{record.orderRemarks,jdbcType=VARCHAR},
      </if>
      <if test="record.deleteSign != null">
        delete_sign = #{record.deleteSign,jdbcType=INTEGER},
      </if>
      <if test="record.salesmanId != null">
        salesman_id = #{record.salesmanId,jdbcType=VARCHAR},
      </if>
      <if test="record.financeId != null">
        finance_id = #{record.financeId,jdbcType=VARCHAR},
      </if>
      <if test="record.technicianId != null">
        technician_id = #{record.technicianId,jdbcType=VARCHAR},
      </if>
      <if test="record.confirmTime != null">
        confirm_time = #{record.confirmTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.signTime != null">
        sign_time = #{record.signTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.setUpTime != null">
        set_up_time = #{record.setUpTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.settlementTime != null">
        settlement_time = #{record.settlementTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.contractNo != null">
        contract_no = #{record.contractNo,jdbcType=VARCHAR},
      </if>
      <if test="record.contractType != null">
        contract_type = #{record.contractType,jdbcType=VARCHAR},
      </if>
      <if test="record.changeStatus != null">
        change_status = #{record.changeStatus,jdbcType=INTEGER},
      </if>
      <if test="record.contractPictureUrl != null">
        contract_picture_url = #{record.contractPictureUrl,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    update t_order
    set order_no = #{record.orderNo,jdbcType=VARCHAR},
      order_type = #{record.orderType,jdbcType=INTEGER},
      creater = #{record.creater,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      buyer_id = #{record.buyerId,jdbcType=VARCHAR},
      seller_id = #{record.sellerId,jdbcType=VARCHAR},
      first_payment = #{record.firstPayment,jdbcType=DECIMAL},
      order_amount = #{record.orderAmount,jdbcType=DECIMAL},
      brokerage_amount = #{record.brokerageAmount,jdbcType=DECIMAL},
      sign_first_payment = #{record.signFirstPayment,jdbcType=DECIMAL},
      actually_first_payment = #{record.actuallyFirstPayment,jdbcType=DECIMAL},
      sign_total_amount = #{record.signTotalAmount,jdbcType=DECIMAL},
      actually_total_amount = #{record.actuallyTotalAmount,jdbcType=DECIMAL},
      sign_brokerage_amount = #{record.signBrokerageAmount,jdbcType=DECIMAL},
      actually_brokerage_amount = #{record.actuallyBrokerageAmount,jdbcType=DECIMAL},
      sign_withdraw_amount = #{record.signWithdrawAmount,jdbcType=DECIMAL},
      actually_withdraw_amount = #{record.actuallyWithdrawAmount,jdbcType=DECIMAL},
      order_stage = #{record.orderStage,jdbcType=INTEGER},
      project_stage = #{record.projectStage,jdbcType=INTEGER},
      order_status = #{record.orderStatus,jdbcType=INTEGER},
      liquidation_status = #{record.liquidationStatus,jdbcType=INTEGER},
      order_channel = #{record.orderChannel,jdbcType=INTEGER},
      approval = #{record.approval,jdbcType=INTEGER},
      order_remarks = #{record.orderRemarks,jdbcType=VARCHAR},
      delete_sign = #{record.deleteSign,jdbcType=INTEGER},
      salesman_id = #{record.salesmanId,jdbcType=VARCHAR},
      finance_id = #{record.financeId,jdbcType=VARCHAR},
      technician_id = #{record.technicianId,jdbcType=VARCHAR},
      confirm_time = #{record.confirmTime,jdbcType=TIMESTAMP},
      sign_time = #{record.signTime,jdbcType=TIMESTAMP},
      set_up_time = #{record.setUpTime,jdbcType=TIMESTAMP},
      settlement_time = #{record.settlementTime,jdbcType=TIMESTAMP},
      contract_no = #{record.contractNo,jdbcType=VARCHAR},
      contract_type = #{record.contractType,jdbcType=VARCHAR},
      change_status = #{record.changeStatus,jdbcType=INTEGER},
      contract_picture_url = #{record.contractPictureUrl,jdbcType=LONGVARCHAR}
    <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 11 14:30:55 CST 2018.
    -->
    update t_order
    set order_no = #{record.orderNo,jdbcType=VARCHAR},
      order_type = #{record.orderType,jdbcType=INTEGER},
      creater = #{record.creater,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      buyer_id = #{record.buyerId,jdbcType=VARCHAR},
      seller_id = #{record.sellerId,jdbcType=VARCHAR},
      first_payment = #{record.firstPayment,jdbcType=DECIMAL},
      order_amount = #{record.orderAmount,jdbcType=DECIMAL},
      brokerage_amount = #{record.brokerageAmount,jdbcType=DECIMAL},
      sign_first_payment = #{record.signFirstPayment,jdbcType=DECIMAL},
      actually_first_payment = #{record.actuallyFirstPayment,jdbcType=DECIMAL},
      sign_total_amount = #{record.signTotalAmount,jdbcType=DECIMAL},
      actually_total_amount = #{record.actuallyTotalAmount,jdbcType=DECIMAL},
      sign_brokerage_amount = #{record.signBrokerageAmount,jdbcType=DECIMAL},
      actually_brokerage_amount = #{record.actuallyBrokerageAmount,jdbcType=DECIMAL},
      sign_withdraw_amount = #{record.signWithdrawAmount,jdbcType=DECIMAL},
      actually_withdraw_amount = #{record.actuallyWithdrawAmount,jdbcType=DECIMAL},
      order_stage = #{record.orderStage,jdbcType=INTEGER},
      project_stage = #{record.projectStage,jdbcType=INTEGER},
      order_status = #{record.orderStatus,jdbcType=INTEGER},
      liquidation_status = #{record.liquidationStatus,jdbcType=INTEGER},
      order_channel = #{record.orderChannel,jdbcType=INTEGER},
      approval = #{record.approval,jdbcType=INTEGER},
      order_remarks = #{record.orderRemarks,jdbcType=VARCHAR},
      delete_sign = #{record.deleteSign,jdbcType=INTEGER},
      salesman_id = #{record.salesmanId,jdbcType=VARCHAR},
      finance_id = #{record.financeId,jdbcType=VARCHAR},
      technician_id = #{record.technicianId,jdbcType=VARCHAR},
      confirm_time = #{record.confirmTime,jdbcType=TIMESTAMP},
      sign_time = #{record.signTime,jdbcType=TIMESTAMP},
      set_up_time = #{record.setUpTime,jdbcType=TIMESTAMP},
      settlement_time = #{record.settlementTime,jdbcType=TIMESTAMP},
      contract_no = #{record.contractNo,jdbcType=VARCHAR},
      contract_type = #{record.contractType,jdbcType=VARCHAR},
      change_status = #{record.changeStatus,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    update t_order
    <set>
      <if test="orderType != null">
        order_type = #{orderType,jdbcType=INTEGER},
      </if>
      <if test="creater != null">
        creater = #{creater,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="buyerId != null">
        buyer_id = #{buyerId,jdbcType=VARCHAR},
      </if>
      <if test="sellerId != null">
        seller_id = #{sellerId,jdbcType=VARCHAR},
      </if>
      <if test="firstPayment != null">
        first_payment = #{firstPayment,jdbcType=DECIMAL},
      </if>
      <if test="orderAmount != null">
        order_amount = #{orderAmount,jdbcType=DECIMAL},
      </if>
      <if test="brokerageAmount != null">
        brokerage_amount = #{brokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="signFirstPayment != null">
        sign_first_payment = #{signFirstPayment,jdbcType=DECIMAL},
      </if>
      <if test="actuallyFirstPayment != null">
        actually_first_payment = #{actuallyFirstPayment,jdbcType=DECIMAL},
      </if>
      <if test="signTotalAmount != null">
        sign_total_amount = #{signTotalAmount,jdbcType=DECIMAL},
      </if>
      <if test="actuallyTotalAmount != null">
        actually_total_amount = #{actuallyTotalAmount,jdbcType=DECIMAL},
      </if>
      <if test="signBrokerageAmount != null">
        sign_brokerage_amount = #{signBrokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="actuallyBrokerageAmount != null">
        actually_brokerage_amount = #{actuallyBrokerageAmount,jdbcType=DECIMAL},
      </if>
      <if test="signWithdrawAmount != null">
        sign_withdraw_amount = #{signWithdrawAmount,jdbcType=DECIMAL},
      </if>
      <if test="actuallyWithdrawAmount != null">
        actually_withdraw_amount = #{actuallyWithdrawAmount,jdbcType=DECIMAL},
      </if>
      <if test="orderStage != null">
        order_stage = #{orderStage,jdbcType=INTEGER},
      </if>
      <if test="projectStage != null">
        project_stage = #{projectStage,jdbcType=INTEGER},
      </if>
      <if test="orderStatus != null">
        order_status = #{orderStatus,jdbcType=INTEGER},
      </if>
      <if test="liquidationStatus != null">
        liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
      </if>
      <if test="orderChannel != null">
        order_channel = #{orderChannel,jdbcType=INTEGER},
      </if>
      <if test="approval != null">
        approval = #{approval,jdbcType=INTEGER},
      </if>
      <if test="orderRemarks != null">
        order_remarks = #{orderRemarks,jdbcType=VARCHAR},
      </if>
      <if test="deleteSign != null">
        delete_sign = #{deleteSign,jdbcType=INTEGER},
      </if>
      <if test="salesmanId != null">
        salesman_id = #{salesmanId,jdbcType=VARCHAR},
      </if>
      <if test="financeId != null">
        finance_id = #{financeId,jdbcType=VARCHAR},
      </if>
      <if test="technicianId != null">
        technician_id = #{technicianId,jdbcType=VARCHAR},
      </if>
      <if test="confirmTime != null">
        confirm_time = #{confirmTime,jdbcType=TIMESTAMP},
      </if>
      <if test="signTime != null">
        sign_time = #{signTime,jdbcType=TIMESTAMP},
      </if>
      <if test="setUpTime != null">
        set_up_time = #{setUpTime,jdbcType=TIMESTAMP},
      </if>
      <if test="settlementTime != null">
        settlement_time = #{settlementTime,jdbcType=TIMESTAMP},
      </if>
      <if test="contractNo != null">
        contract_no = #{contractNo,jdbcType=VARCHAR},
      </if>
      <if test="contractType != null">
        contract_type = #{contractType,jdbcType=VARCHAR},
      </if>
      <if test="changeStatus != null">
        change_status = #{changeStatus,jdbcType=INTEGER},
      </if>
      <if test="contractPictureUrl != null">
        contract_picture_url = #{contractPictureUrl,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where order_no = #{orderNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.goafanti.common.model.TOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    update t_order
    set order_type = #{orderType,jdbcType=INTEGER},
      creater = #{creater,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      buyer_id = #{buyerId,jdbcType=VARCHAR},
      seller_id = #{sellerId,jdbcType=VARCHAR},
      first_payment = #{firstPayment,jdbcType=DECIMAL},
      order_amount = #{orderAmount,jdbcType=DECIMAL},
      brokerage_amount = #{brokerageAmount,jdbcType=DECIMAL},
      sign_first_payment = #{signFirstPayment,jdbcType=DECIMAL},
      actually_first_payment = #{actuallyFirstPayment,jdbcType=DECIMAL},
      sign_total_amount = #{signTotalAmount,jdbcType=DECIMAL},
      actually_total_amount = #{actuallyTotalAmount,jdbcType=DECIMAL},
      sign_brokerage_amount = #{signBrokerageAmount,jdbcType=DECIMAL},
      actually_brokerage_amount = #{actuallyBrokerageAmount,jdbcType=DECIMAL},
      sign_withdraw_amount = #{signWithdrawAmount,jdbcType=DECIMAL},
      actually_withdraw_amount = #{actuallyWithdrawAmount,jdbcType=DECIMAL},
      order_stage = #{orderStage,jdbcType=INTEGER},
      project_stage = #{projectStage,jdbcType=INTEGER},
      order_status = #{orderStatus,jdbcType=INTEGER},
      liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
      order_channel = #{orderChannel,jdbcType=INTEGER},
      approval = #{approval,jdbcType=INTEGER},
      order_remarks = #{orderRemarks,jdbcType=VARCHAR},
      delete_sign = #{deleteSign,jdbcType=INTEGER},
      salesman_id = #{salesmanId,jdbcType=VARCHAR},
      finance_id = #{financeId,jdbcType=VARCHAR},
      technician_id = #{technicianId,jdbcType=VARCHAR},
      confirm_time = #{confirmTime,jdbcType=TIMESTAMP},
      sign_time = #{signTime,jdbcType=TIMESTAMP},
      set_up_time = #{setUpTime,jdbcType=TIMESTAMP},
      settlement_time = #{settlementTime,jdbcType=TIMESTAMP},
      contract_no = #{contractNo,jdbcType=VARCHAR},
      contract_type = #{contractType,jdbcType=VARCHAR},
      change_status = #{changeStatus,jdbcType=INTEGER},
      contract_picture_url = #{contractPictureUrl,jdbcType=LONGVARCHAR}
    where order_no = #{orderNo,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrder">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Apr 11 14:30:55 CST 2018.
    -->
    update t_order
    set order_type = #{orderType,jdbcType=INTEGER},
      creater = #{creater,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      buyer_id = #{buyerId,jdbcType=VARCHAR},
      seller_id = #{sellerId,jdbcType=VARCHAR},
      first_payment = #{firstPayment,jdbcType=DECIMAL},
      order_amount = #{orderAmount,jdbcType=DECIMAL},
      brokerage_amount = #{brokerageAmount,jdbcType=DECIMAL},
      sign_first_payment = #{signFirstPayment,jdbcType=DECIMAL},
      actually_first_payment = #{actuallyFirstPayment,jdbcType=DECIMAL},
      sign_total_amount = #{signTotalAmount,jdbcType=DECIMAL},
      actually_total_amount = #{actuallyTotalAmount,jdbcType=DECIMAL},
      sign_brokerage_amount = #{signBrokerageAmount,jdbcType=DECIMAL},
      actually_brokerage_amount = #{actuallyBrokerageAmount,jdbcType=DECIMAL},
      sign_withdraw_amount = #{signWithdrawAmount,jdbcType=DECIMAL},
      actually_withdraw_amount = #{actuallyWithdrawAmount,jdbcType=DECIMAL},
      order_stage = #{orderStage,jdbcType=INTEGER},
      project_stage = #{projectStage,jdbcType=INTEGER},
      order_status = #{orderStatus,jdbcType=INTEGER},
      liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
      order_channel = #{orderChannel,jdbcType=INTEGER},
      approval = #{approval,jdbcType=INTEGER},
      order_remarks = #{orderRemarks,jdbcType=VARCHAR},
      delete_sign = #{deleteSign,jdbcType=INTEGER},
      salesman_id = #{salesmanId,jdbcType=VARCHAR},
      finance_id = #{financeId,jdbcType=VARCHAR},
      technician_id = #{technicianId,jdbcType=VARCHAR},
      confirm_time = #{confirmTime,jdbcType=TIMESTAMP},
      sign_time = #{signTime,jdbcType=TIMESTAMP},
      set_up_time = #{setUpTime,jdbcType=TIMESTAMP},
      settlement_time = #{settlementTime,jdbcType=TIMESTAMP},
      contract_no = #{contractNo,jdbcType=VARCHAR},
      contract_type = #{contractType,jdbcType=VARCHAR},
      change_status = #{changeStatus,jdbcType=INTEGER}
    where order_no = #{orderNo,jdbcType=VARCHAR}
  </update>
  
  <select id="selectCommodityDetail" resultType="com.goafanti.order.bo.CommodityDetailBo">
  	<choose>
  		<when test="commodityType == 0">
  			select id as commodityId,bname as commodityName,cid as commodityClassify,ifnull(price,0) as commodityPrice,ifnull(first_payment,0) as commodityFirstPayment from business_project where id = #{commodityId,jdbcType=VARCHAR}
  		</when>
  		<when test="commodityType == 1">
  			select id as commodityId,name as commodityName,introduction,ifnull(transfer_price,0) as commodityPrice,owner_id as sellerId from achievement where id = #{commodityId,jdbcType=VARCHAR}
  		</when>
  		<when test="commodityType == 2">
  			select id as commodityId,name as commodityName,problem_des as introduction,ifnull(budget_cost,0) as commodityPrice,employer_id as sellerId from demand where id = #{commodityId,jdbcType=VARCHAR}
  		</when>
  		<when test="commodityType == 3">
  			select a.id as commodityId,a.nickname as commodityName,a.id as sellerId,ifnull(b.consultation_price,0) as commodityPrice,ifnull(b.professional_title,'暂无职称') as introduction from user a 
  			left join user_identity b on a.id=b.uid where a.id = #{commodityId,jdbcType=VARCHAR}
  		</when>
  		<when test="commodityType == 4">
  			
  		</when>
  		<when test="commodityType == 5">
  		
  		</when>
  		<when test="commodityType == 6">
  			select a.id as commodityId,a.nickname as commodityName,a.id as sellerId,ifnull(b.consultation_price,0) as commodityPrice,ifnull(b.professional_title,'暂无职称') as introduction from user a 
  			left join user_identity b on a.id=b.uid where a.id = #{commodityId,jdbcType=VARCHAR}
  		</when>
  	</choose>
  </select>
  
  <select id="selectOrderListByPage" resultMap="BaseResultMap">
  	select 
    <include refid="Base_Column_List" />
    from t_order where delete_sign = 0
    <choose>
    	<when test="orderStatus == 1"><!-- 意向订单 -->
    		and order_status = 1 and (buyer_id = #{uid,jdbcType=VARCHAR} or seller_id =  #{uid,jdbcType=VARCHAR})
    	</when>
    	<otherwise>
    		and order_status != 1 and (buyer_id = #{uid,jdbcType=VARCHAR} or seller_id =  #{uid,jdbcType=VARCHAR})
    	</otherwise>
    </choose>
    order by create_time desc
    <if test="page_sql!=null">
			${page_sql}
	</if>
  </select>
  
   <select id="selectOrderListCount" resultType="java.lang.Integer">
  	select 
  		count(0) 
  	from t_order where delete_sign = 0
    <choose>
    	<when test="orderStatus == 0"><!-- 意向订单 -->
    		and order_status = 1 and (buyer_id = #{uid,jdbcType=VARCHAR} or seller_id =  #{uid,jdbcType=VARCHAR})
    	</when>
    	<otherwise>
    		and order_status != 1  and buyer_id = #{uid,jdbcType=VARCHAR}
    	</otherwise>
    </choose>
  </select>
  
  <select id="selectOrderBillByPage" resultType="com.goafanti.order.bo.BillListBo">
	select
		a.order_no as orderNo,
		date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
		a.transaction_subject as transactionSubject,
		a.transaction_amount as transactionAmount,
		a.confirm_sign as confirmSign
	from
		t_order_bill a
	where
		(a.payee_id = #{uid,jdbcType=VARCHAR} or a.payer_id = #{uid,jdbcType=VARCHAR})
		<if test="orderNo != null and orderNo != ''">
			and a.order_no = #{orderNo,jdbcType=VARCHAR}
		</if>
		order by a.create_time desc
		<if test="page_sql!=null">
			${page_sql}
		</if>
  </select>
  
  <select id="selectOrderBillCount" resultType="java.lang.Integer">
  	select
		count(0)
	from
		t_order_bill a
	where
		(a.payee_id = #{uid,jdbcType=VARCHAR} or a.payer_id = #{uid,jdbcType=VARCHAR})
		<if test="orderNo != null and orderNo != ''">
			a.order_no = #{orderNo,jdbcType=VARCHAR}
		</if>
  </select>
  
  <select id="selectOrderCommodity" parameterType="java.lang.String" resultType="com.goafanti.common.model.TOrderDetail">
		select
			id,
			order_no as orderNo,
			commodity_id as commodityId,
			commodity_name as commodityName,
			commodity_quantity as commodityQuantity,
			commodity_price as commodityPrice,
			commodity_first_payment as commodityFirstPayment,
			commodity_type as commodityType,
			commodity_mode as commodityMode,
			discount_price as discountPrice,
			discount_first_payment as discountFirstPayment,
			create_time as createTime,
			remarks
		from
			t_order_detail
		where
			order_no = #{orderNo,jdbcType=VARCHAR}
  </select>
  
  
  
  <select id="selectServiceOrderDetail" parameterType="java.lang.String" resultType="com.goafanti.order.bo.ServiceOrderDetailBo">
  		select
			a.order_no as orderNo,
			a.order_type as orderType,
			date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
			date_format(a.sign_time,'%Y-%m-%d') as signTime,
			date_format(a.set_up_time,'%Y-%m-%d %H:%i:%S') as setUpTime,
			date_format(a.settlement_time,'%Y-%m-%d %H:%i:%S') as settlementTime,
			a.order_amount as orderAmount,
			a.first_payment as firstPayment,
			a.sign_total_amount as signTotalAmount,
			a.sign_first_payment as signFirstPayment,
			a.actually_total_amount as actuallyTotalAmount,
			a.order_status as orderStatus,
			a.order_stage as orderStage,
			a.project_stage as projectStage,
			a.delete_sign as deleteSign,
			a.liquidation_status as liquidationStatus,
			a.approval,
			a.order_remarks as orderRemarks,
			a.order_channel as orderChannel,
			a.contract_picture_url as contractPictureUrl,
			a.buyer_id as buyerId,
			a.seller_id as sellerId,
			a.buyer_id as buyerId,
			a.salesman_id as salesmanId,
			b.type as buyerType,
			b.nickname as buyerName,
			c.name as salesmanName,
			x.name as departmentName,
			a.finance_id as financeId,
			c.name as financeName,
			a.technician_id as technicianId,
			e.name as technicianName,
			a.delete_sign as deleteSign,
			a.contract_no as contractNo,
			f.cname as projectType,
			a.change_status as changeStatus
		from
			t_order a left join user b on
			a.buyer_id = b.id left join admin c on
			a.salesman_id = c.id left join admin d on
			a.finance_id = d.id left join department x on 
			c.department_id=x.id left join admin e on
			a.technician_id = e.id left join business_category f on
			a.contract_type = f.id
		where a.order_no = #{orderNo,jdbcType=VARCHAR}
  </select>
  
  <select id="selectPublicOrderByPage" resultType="com.goafanti.order.bo.OrderListBo">
  		select
			a.order_no as orderNo,
			a.order_type as orderType,
			date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
			a.order_amount as orderAmount,
			a.sign_total_amount as signTotalAmount,
			a.order_status as orderStatus,
			a.order_stage as orderStage,
			a.liquidation_status as liquidationStatus,
			a.order_channel as orderChannel,
			b.nickname as buyerName
		from
			t_order a left join user b on
			a.buyer_id = b.id 
		where a.salesman_id is null
		<if test="startDate != null">
			and a.create_time &gt; #{a.startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time &lt; #{a.endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="buyerName != null and buyerName != ''">
			and b.nickname = #{buyerName,jdbcType=VARCHAR}
		</if>
		<if test="orderType != null">
			and a.order_type = #{orderType,jdbcType=INTEGER}
		</if>
		<if test="orderStatus != null">
			and a.order_status = #{orderStatus,jdbcType=INTEGER}
		</if>
		<if test="orderChannel != null">
			and a.orderChannel = #{orderChannel,jdbcType=INTEGER}
		</if>
		<if test="page_sql != null">
			${page_sql}
		</if>
  </select>
  <select id="selectPublicOrderCount" resultType="java.lang.Integer">
  		select
			count(0)
		from
			t_order a left join user b on
			a.buyer_id = b.id 
		where a.salesman_id is null
		<if test="startDate != null">
			and a.create_time &gt; #{a.startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time &lt; #{a.endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="buyerName != null and buyerName != ''">
			and b.nickname = #{buyerName,jdbcType=VARCHAR}
		</if>
		<if test="orderStatus != null">
			and a.order_status = #{orderStatus,jdbcType=INTEGER}
		</if>
		<if test="orderChannel != null">
			and a.orderChannel = #{orderChannel,jdbcType=INTEGER}
		</if>
  </select>
  <select id="selectSettlementByPage" resultType="com.goafanti.order.bo.OrderListBo">
  	select
			a.order_no as orderNo,
			a.order_type as orderType,
			date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
			a.sign_total_amount as signTotalAmount,
			a.actually_total_amount as actuallyTotalAmount,
			a.order_status as orderStatus,
			a.order_stage as orderStage,
			a.project_stage as projectStage,
			a.liquidation_status as liquidationStatus,
			a.approval,
			a.order_channel as orderChannel,
			a.buyer_id as buyerId,
			a.seller_id as sellerId,
			b.nickname as buyerName,		
			c.name as salesmanName,
			d.name as financeName,
			e.name as technicianName,
			f.name as departmentName
		from
			t_order a left join user b on
			a.buyer_id = b.id left join admin c on
			a.salesman_id = c.id left join admin d on
			a.finance_id = d.id left join admin e on
			a.technician_id = e.id left join department f on 
			c.department_id = f.id
		where a.order_type = 0 and order_status = 3	and delete_sign = 0	
		<if test="orderNo != null">
			and a.order_no = #{orderNo,jdbcType=VARCHAR}
		</if>
		<if test="financeId != null">
			and a.finance_id = #{financeId,jdbcType=VARCHAR}
		</if>
		<if test="startDate != null">
			and a.create_time &gt; #{startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time &lt; #{endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="orderStatus != null">
			and a.order_status = #{orderStatus,jdbcType=INTEGER}
		</if>
		<if test="liquidationStatus != null">
			and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
		</if>
		<if test="approval != null">
			and a.approval = #{approval,jdbcType=INTEGER}
		</if>
		<if test="isDistributionFinance == 0">
			and a.finance_id is null
		</if>
		<if test="isDistributionFinance == 1">
			and a.finance_id is  not null
		</if>
		<if test="buyerName != null and buyerName != ''">
			and b.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
		</if>
		<if test="depId != null">
			and c.department_id = #{depId,jdbcType=VARCHAR}
		</if>
		<if test="salesmanName != null and salesmanName != ''">
			and c.name =  #{salesmanName,jdbcType=VARCHAR}
		</if>
		<if test="financeName != null and financeName != ''">
			and d.name =  #{financeName,jdbcType=VARCHAR}
		</if>
		order by a.create_time desc
		<if test="page_sql != null">
			${page_sql}
		</if>
  </select>
  <select id="selectSettlementCount" resultType="java.lang.Integer">
 	 select
			count(0)
		from
			t_order a left join user b on
			a.buyer_id = b.id left join admin c on
			a.salesman_id = c.id left join admin d on
			a.finance_id = d.id left join admin e on
			a.technician_id = e.id left join department f on 
			c.department_id = f.id
		where a.order_type = 0 and order_status = 3	and delete_sign = 0	
		<if test="orderNo != null">
			and a.order_no = #{orderNo,jdbcType=VARCHAR}
		</if>
		<if test="financeId != null">
			and a.finance_id = #{financeId,jdbcType=VARCHAR}
		</if>
		<if test="startDate != null">
			and a.create_time &gt; #{startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time &lt; #{endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="orderStatus != null">
			and a.order_status = #{orderStatus,jdbcType=INTEGER}
		</if>
		<if test="liquidationStatus != null">
			and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
		</if>
		<if test="approval != null">
			and a.approval = #{approval,jdbcType=INTEGER}
		</if>
		<if test="isDistributionFinance == 0">
			and a.finance_id is null
		</if>
		<if test="isDistributionFinance == 1">
			and a.finance_id is not null
		</if>
		<if test="buyerName != null and buyerName != ''">
			and b.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
		</if>
		<if test="depId != null">
			and c.department_id = #{depId,jdbcType=VARCHAR}
		</if>
		<if test="salesmanName != null and salesmanName != ''">
			and c.name =  #{salesmanName,jdbcType=VARCHAR}
		</if>
		<if test="financeName != null and financeName != ''">
			and d.name =  #{financeName,jdbcType=VARCHAR}
		</if>
  </select>
  <select id="selectBillByPage" resultType="com.goafanti.order.bo.BillListBo">
	select
		a.bill_no as billNo,
		date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
		a.transaction_amount as transactionAmount,
		a.transaction_channel as transactionChannel,
		a.transaction_subject as transactionSubject,
		a.transaction_mode as transactionMode,
		a.financial_pay_no as financialPayNo,
		date_format(a.financial_pay_time,'%Y-%m-%d %H:%i:%S') as financialPayTime,
		a.confirm_sign as confirmSign,
		a.delete_sign as deleteSign,
		date_format(a.confirm_time,'%Y-%m-%d %H:%i:%S') as confirmTime,
		b.order_no as orderNo,
		c.nickname as payeeName,
		d.nickname as payerName,
		e.name as financeName,
		f.name as salesmanName,
		g.name as departmentName
	from
		t_order_bill a left join t_order b on
		a.order_no = b.order_no left join user c on 
		a.payee_id = c.id left join user d on
		a.payer_id = d.id left join admin e on 
		b.finance_id = e.id left join admin f on 
		b.salesman_id = f.id left join department g on
		f.department_id = g.id
	where a.delete_sign = 0
	<if test="orderNo != null and orderNo != ''">
		and b.order_no = #{orderNo,jdbcType=VARCHAR}
	</if>
	<if test="payeeName != null and payeeName != ''">
		and c.nickname = #{payeeName,jdbcType=VARCHAR}
	</if>
	<if test="payerName != null and payerName !=''">
		and d.nickname = #{payerName,jdbcType=VARCHAR}
	</if>
	<if test="salesmanName != null and salesmanName != ''">
		and f.name = #{salesmanName,jdbcType=VARCHAR}
	</if>
	<if test="financeName != null and financeName != ''">
		and e.name = #{financeName,jdbcType=VARCHAR}
	</if>
	<if test="confirmSign != null">
		and a.confirm_sign = #{confirmSign,jdbcType=INTEGER}
	</if>
	<if test="deleteSign != null">
		and a.delete_sign = #{deleteSign,jdbcType=INTEGER}
	</if>
	<if test="depId != null and depId != ''">
		and f.department_id = #{depId,jdbcType=VARCHAR}
	</if>
	<if test="isFinance == 0"> <!-- 我的订单流水查询 -->
		and 
			(b.salesman_id = #{aid,jdbcType=VARCHAR} 
		or 
			b.finance_id = #{aid,jdbcType=VARCHAR} 
		or 
			b.technician_id = #{aid,jdbcType=VARCHAR})
	</if>
	<if test="isFinance == 1"> <!-- 我的结算流水 -->
		and b.finance_id = #{aid,jdbcType=VARCHAR} 
	</if>
		order by a.create_time desc
	<if test="page_sql != null">
		${page_sql}
	</if>
  </select>
  <select id="selectBillCount" resultType="java.lang.Integer">
  	select
  		count(0)
  	from
		t_order_bill a left join t_order b on
		a.order_no = b.order_no left join user c on 
		a.payee_id = c.id left join user d on
		a.payer_id = d.id left join admin e on 
		b.finance_id = e.id left join admin f on 
		b.salesman_id = f.id left join department g on
		f.department_id = g.id
	where a.delete_sign = 0
	<if test="orderNo != null and orderNo != ''">
		and b.order_no = #{orderNo,jdbcType=VARCHAR}
	</if>
	<if test="payeeName != null and payeeName != ''">
		and c.nickname = #{payeeName,jdbcType=VARCHAR}
	</if>
	<if test="payerName != null and payerName !=''">
		and d.nickname = #{payerName,jdbcType=VARCHAR}
	</if>
	<if test="salesmanName != null and salesmanName != ''">
		and f.name = #{salesmanName,jdbcType=VARCHAR}
	</if>
	<if test="financeName != null and financeName != ''">
		and e.name = #{financeName,jdbcType=VARCHAR}
	</if>
	<if test="confirmSign != null">
		and a.confirm_sign = #{confirmSign,jdbcType=INTEGER}
	</if>
	<if test="deleteSign != null">
		and a.delete_sign = #{deleteSign,jdbcType=INTEGER}
	</if>
	<if test="depId != null and depId != ''">
		and f.department_id = #{depId,jdbcType=VARCHAR}
	</if>
	<if test="isFinance == 0"> <!-- 我的订单流水查询 -->
		and 
			(b.salesman_id = #{aid,jdbcType=VARCHAR} 
		or 
			b.finance_id = #{aid,jdbcType=VARCHAR} 
		or 
			b.technician_id = #{aid,jdbcType=VARCHAR})
	</if>
	<if test="isFinance == 1"> <!-- 我的结算流水 -->
		and b.finance_id = #{aid,jdbcType=VARCHAR} 
	</if>
  </select>
  
  <select id="selectBillDetail" parameterType="java.lang.String" resultType="com.goafanti.order.bo.BillDetailBo">
		select
			a.bill_no as billNo,
			date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
			a.transaction_amount as transactionAmount,
			a.transaction_channel as transactionChannel,
			a.transaction_subject as transactionSubject,
			a.transaction_mode as transactionMode,
			a.financial_pay_no as financialPayNo,
			date_format(a.financial_pay_time,'%Y-%m-%d %H:%i:%S') as financialPayTime,
			date_format(a.confirm_time,'%Y-%m-%d %H:%i:%S') as confirmTime,
			a.confirm_sign as confirmSign,
			a.delete_sign as deleteSign,
			a.remarks,
			a.postscript,
			b.order_no as orderNo,
			c.nickname as payeeName,
			d.nickname as payerName,
			e.name as financeName,
			f.name as salesmanName,
			g.name as departmentName
		from
			t_order_bill a left join t_order b on
			a.order_no = b.order_no left join user c on
			a.payee_id = c.id left join user d on
			a.payer_id = d.id left join admin e on
			b.finance_id = e.id left join admin f on
			b.salesman_id = f.id left join department g on
			f.department_id = g.id
		where
			a.bill_no = #{billNo,jdbcType=VARCHAR}
  </select>
  
  <select id="selectSetUpServiceOrderByPage" resultType="com.goafanti.order.bo.OrderListBo">
		select
			a.order_no as orderNo,
			a.order_type as orderType,
			date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
			a.order_status as orderStatus,
			a.project_stage as projectStage,
			a.liquidation_status as liquidationStatus,
			a.approval,
			a.order_channel as orderChannel,
			b.nickname as buyerName,
			c.name as salesmanName,
			d.name as financeName,
			e.name as technicianName,
			f.name as departmentName,
			g.cname as projectType
		from
			t_order a left join user b on
			a.buyer_id = b.id left join admin c on
			a.salesman_id = c.id left join admin d on
			a.finance_id = d.id left join admin e on
			a.technician_id = e.id left join department f on 
			c.department_id = f.id left join business_category g on
			a.contract_type = g.id
		where a.order_type = 0 and a.order_status = 3 and project_stage = 1
			and (a.liquidation_status = 1 or a.liquidation_status = 2 or a.approval = 2) <!-- 已首付 or 已付清 or 已特批 -->
			and a.delete_sign=0
		<if test="salesmanId != null">
			and a.salesman_id = #{a.salesmanId,jdbcType=VARCHAR}
		</if>
		<if test="financeId != null">
			and a.finance_id = #{financeId,jdbcType=VARCHAR}
		</if>
		<if test="technicianId != null">
			and a.technician_id = #{technicianId,jdbcType=VARCHAR}
		</if>
		<if test="startDate != null">
			and a.create_time &gt; #{a.startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time &lt; #{a.endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="approval != null">
			and a.approval = #{approval,jdbcType=INTEGER}
		</if>
		<if test="depId != null and depId != ''">
			and f.id = #{depId,jdbcType=VARCHAR}
		</if>
		<if test="buyerName != null and buyerName != ''">
			and b.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
		</if>
		<if test="salesmanName != null and salesmanName != ''">
			and c.name = #{salesmanName,jdbcType=VARCHAR}
		</if>
		<if test="financeName != null and financeName != ''">
			and d.name = #{financeName,jdbcType=VARCHAR}
		</if>
		 	order by a.create_time desc
		<if test="page_sql != null">
			${page_sql}
		</if>
  </select>
  <select id="selectSetUpServiceOrderCount" resultType="java.lang.Integer">
		select
			count(0)
		from
			t_order a left join user b on
			a.buyer_id = b.id left join admin c on
			a.salesman_id = c.id left join admin d on
			a.finance_id = d.id left join admin e on
			a.technician_id = e.id left join department f on 
			c.department_id = f.id left join business_category g on
			a.contract_type = g.id
		where a.order_type = 0 and a.order_status = 3 and project_stage = 1
			and (a.liquidation_status = 1 or a.liquidation_status = 2 or a.approval = 2) <!-- 已首付 or 已付清 or 已特批 -->
		<if test="salesmanId != null">
			and a.salesman_id = #{a.salesmanId,jdbcType=VARCHAR}
		</if>
		<if test="financeId != null">
			and a.finance_id = #{financeId,jdbcType=VARCHAR}
		</if>
		<if test="technicianId != null">
			and a.technician_id = #{technicianId,jdbcType=VARCHAR}
		</if>
		<if test="startDate != null">
			and a.create_time &gt; #{a.startDate,jdbcType=TIMESTAMP}
		</if>
		<if test="endDate != null">
			and a.create_time &lt; #{a.endDate,jdbcType=TIMESTAMP}
		</if>
		<if test="approval != null">
			and a.approval = #{approval,jdbcType=INTEGER}
		</if>
		<if test="depId != null and depId != ''">
			and f.id = #{depId,jdbcType=VARCHAR}
		</if>
		<if test="buyerName != null and buyerName != ''">
			and b.nickname like concat('%',#{buyerName,jdbcType=VARCHAR},'%')
		</if>
		<if test="salesmanName != null and salesmanName != ''">
			and c.name = #{salesmanName,jdbcType=VARCHAR}
		</if>
		<if test="financeName != null and financeName != ''">
			and d.name = #{financeName,jdbcType=VARCHAR}
		</if>
  </select>
  
  <select id="selectBillByOrderNo" parameterType="java.lang.String" resultType="com.goafanti.order.bo.BillListBo">
  	select
		a.bill_no as billNo,
		date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
		a.transaction_amount as transactionAmount,
		a.transaction_channel as transactionChannel,
		a.transaction_subject as transactionSubject,
		a.transaction_mode as transactionMode,
		a.financial_pay_no as financialPayNo,
		date_format(a.financial_pay_time,'%Y-%m-%d %H:%i:%S') as financialPayTime,
		a.confirm_sign as confirmSign,
		a.delete_sign as deleteSign,
		date_format(a.confirm_time,'%Y-%m-%d %H:%i:%S') as confirmTime,
		b.order_no as orderNo,
		c.nickname as payeeName,
		d.nickname as payerName,
		e.name as financeName,
		f.name as salesmanName,
		g.name as departmentName
	from
		t_order_bill a left join t_order b on
		a.order_no = b.order_no left join user c on 
		a.payee_id = c.id left join user d on
		a.payer_id = d.id left join admin e on 
		b.finance_id = e.id left join admin f on 
		b.salesman_id = f.id left join department g on
		f.department_id = g.id
	where a.order_no = #{orderNo,jdbcType=VARCHAR} and a.delete_sign = 0
	order by a.create_time desc
  </select>
  <select id="selectByUserName" resultType="java.lang.String">
  	    select b.nickname from t_order a inner join user b on a.buyer_id =b.id
    where a.order_no= #{orderNo,jdbcType=VARCHAR}
  </select>
</mapper>