<?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="cn.superdesk.uniorder.dao.mapper.base.UnifiedOrderCreditMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCredit">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="order_sn" jdbcType="VARCHAR" property="orderSn" />
    <result column="order_id" jdbcType="BIGINT" property="orderId" />
    <result column="goods_id" jdbcType="BIGINT" property="goodsId" />
    <result column="out_snapshot_order_credit_id" jdbcType="BIGINT" property="outSnapshotOrderCreditId" />
    <result column="credit_type" jdbcType="INTEGER" property="creditType" />
    <result column="credit_name" jdbcType="VARCHAR" property="creditName" />
    <result column="daily_account_type" jdbcType="INTEGER" property="dailyAccountType" />
    <result column="batchs" jdbcType="VARCHAR" property="batchs" />
    <result column="balance" jdbcType="DECIMAL" property="balance" />
    <result column="enterprise_id" jdbcType="BIGINT" property="enterpriseId" />
    <result column="member_id" jdbcType="BIGINT" property="memberId" />
    <result column="pay_status" jdbcType="INTEGER" property="payStatus" />
    <result column="pay_type" jdbcType="INTEGER" property="payType" />
    <result column="credit_locking_customer" jdbcType="TINYINT" property="creditLockingCustomer" />
    <result column="credit_locking_supplier" jdbcType="TINYINT" property="creditLockingSupplier" />
    <result column="accounting_state_customer" jdbcType="TINYINT" property="accountingStateCustomer" />
    <result column="accounting_state_supplier" jdbcType="TINYINT" property="accountingStateSupplier" />
    <result column="invoice_apply_status" jdbcType="TINYINT" property="invoiceApplyStatus" />
    <result column="invoice_make_status" jdbcType="TINYINT" property="invoiceMakeStatus" />
    <result column="back_status" jdbcType="TINYINT" property="backStatus" />
    <result column="direction" jdbcType="TINYINT" property="direction" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_user_id" jdbcType="BIGINT" property="createUserId" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="update_user_id" jdbcType="BIGINT" property="updateUserId" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <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">
    <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">
    id, order_sn, order_id, goods_id, out_snapshot_order_credit_id, credit_type, credit_name, 
    daily_account_type, batchs, balance, enterprise_id, member_id, pay_status, pay_type, 
    credit_locking_customer, credit_locking_supplier, accounting_state_customer, accounting_state_supplier, 
    invoice_apply_status, invoice_make_status, back_status, direction, create_time, create_user_id, 
    update_time, update_user_id
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCreditExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from unified_order_credit
    <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.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from unified_order_credit
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from unified_order_credit
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCreditExample">
    delete from unified_order_credit
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCredit">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_order_credit (order_sn, order_id, goods_id, 
      out_snapshot_order_credit_id, credit_type, credit_name, 
      daily_account_type, batchs, balance, 
      enterprise_id, member_id, pay_status, 
      pay_type, credit_locking_customer, credit_locking_supplier, 
      accounting_state_customer, accounting_state_supplier, 
      invoice_apply_status, invoice_make_status, 
      back_status, direction, create_time, 
      create_user_id, update_time, update_user_id
      )
    values (#{orderSn,jdbcType=VARCHAR}, #{orderId,jdbcType=BIGINT}, #{goodsId,jdbcType=BIGINT}, 
      #{outSnapshotOrderCreditId,jdbcType=BIGINT}, #{creditType,jdbcType=INTEGER}, #{creditName,jdbcType=VARCHAR}, 
      #{dailyAccountType,jdbcType=INTEGER}, #{batchs,jdbcType=VARCHAR}, #{balance,jdbcType=DECIMAL}, 
      #{enterpriseId,jdbcType=BIGINT}, #{memberId,jdbcType=BIGINT}, #{payStatus,jdbcType=INTEGER}, 
      #{payType,jdbcType=INTEGER}, #{creditLockingCustomer,jdbcType=TINYINT}, #{creditLockingSupplier,jdbcType=TINYINT}, 
      #{accountingStateCustomer,jdbcType=TINYINT}, #{accountingStateSupplier,jdbcType=TINYINT}, 
      #{invoiceApplyStatus,jdbcType=TINYINT}, #{invoiceMakeStatus,jdbcType=TINYINT}, 
      #{backStatus,jdbcType=TINYINT}, #{direction,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, 
      #{createUserId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updateUserId,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCredit">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into unified_order_credit
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orderSn != null">
        order_sn,
      </if>
      <if test="orderId != null">
        order_id,
      </if>
      <if test="goodsId != null">
        goods_id,
      </if>
      <if test="outSnapshotOrderCreditId != null">
        out_snapshot_order_credit_id,
      </if>
      <if test="creditType != null">
        credit_type,
      </if>
      <if test="creditName != null">
        credit_name,
      </if>
      <if test="dailyAccountType != null">
        daily_account_type,
      </if>
      <if test="batchs != null">
        batchs,
      </if>
      <if test="balance != null">
        balance,
      </if>
      <if test="enterpriseId != null">
        enterprise_id,
      </if>
      <if test="memberId != null">
        member_id,
      </if>
      <if test="payStatus != null">
        pay_status,
      </if>
      <if test="payType != null">
        pay_type,
      </if>
      <if test="creditLockingCustomer != null">
        credit_locking_customer,
      </if>
      <if test="creditLockingSupplier != null">
        credit_locking_supplier,
      </if>
      <if test="accountingStateCustomer != null">
        accounting_state_customer,
      </if>
      <if test="accountingStateSupplier != null">
        accounting_state_supplier,
      </if>
      <if test="invoiceApplyStatus != null">
        invoice_apply_status,
      </if>
      <if test="invoiceMakeStatus != null">
        invoice_make_status,
      </if>
      <if test="backStatus != null">
        back_status,
      </if>
      <if test="direction != null">
        direction,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createUserId != null">
        create_user_id,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateUserId != null">
        update_user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orderSn != null">
        #{orderSn,jdbcType=VARCHAR},
      </if>
      <if test="orderId != null">
        #{orderId,jdbcType=BIGINT},
      </if>
      <if test="goodsId != null">
        #{goodsId,jdbcType=BIGINT},
      </if>
      <if test="outSnapshotOrderCreditId != null">
        #{outSnapshotOrderCreditId,jdbcType=BIGINT},
      </if>
      <if test="creditType != null">
        #{creditType,jdbcType=INTEGER},
      </if>
      <if test="creditName != null">
        #{creditName,jdbcType=VARCHAR},
      </if>
      <if test="dailyAccountType != null">
        #{dailyAccountType,jdbcType=INTEGER},
      </if>
      <if test="batchs != null">
        #{batchs,jdbcType=VARCHAR},
      </if>
      <if test="balance != null">
        #{balance,jdbcType=DECIMAL},
      </if>
      <if test="enterpriseId != null">
        #{enterpriseId,jdbcType=BIGINT},
      </if>
      <if test="memberId != null">
        #{memberId,jdbcType=BIGINT},
      </if>
      <if test="payStatus != null">
        #{payStatus,jdbcType=INTEGER},
      </if>
      <if test="payType != null">
        #{payType,jdbcType=INTEGER},
      </if>
      <if test="creditLockingCustomer != null">
        #{creditLockingCustomer,jdbcType=TINYINT},
      </if>
      <if test="creditLockingSupplier != null">
        #{creditLockingSupplier,jdbcType=TINYINT},
      </if>
      <if test="accountingStateCustomer != null">
        #{accountingStateCustomer,jdbcType=TINYINT},
      </if>
      <if test="accountingStateSupplier != null">
        #{accountingStateSupplier,jdbcType=TINYINT},
      </if>
      <if test="invoiceApplyStatus != null">
        #{invoiceApplyStatus,jdbcType=TINYINT},
      </if>
      <if test="invoiceMakeStatus != null">
        #{invoiceMakeStatus,jdbcType=TINYINT},
      </if>
      <if test="backStatus != null">
        #{backStatus,jdbcType=TINYINT},
      </if>
      <if test="direction != null">
        #{direction,jdbcType=TINYINT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        #{updateUserId,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>

  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCreditExample" resultType="java.lang.Long">
    select count(*) from unified_order_credit
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update unified_order_credit
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.orderSn != null">
        order_sn = #{record.orderSn,jdbcType=VARCHAR},
      </if>
      <if test="record.orderId != null">
        order_id = #{record.orderId,jdbcType=BIGINT},
      </if>
      <if test="record.goodsId != null">
        goods_id = #{record.goodsId,jdbcType=BIGINT},
      </if>
      <if test="record.outSnapshotOrderCreditId != null">
        out_snapshot_order_credit_id = #{record.outSnapshotOrderCreditId,jdbcType=BIGINT},
      </if>
      <if test="record.creditType != null">
        credit_type = #{record.creditType,jdbcType=INTEGER},
      </if>
      <if test="record.creditName != null">
        credit_name = #{record.creditName,jdbcType=VARCHAR},
      </if>
      <if test="record.dailyAccountType != null">
        daily_account_type = #{record.dailyAccountType,jdbcType=INTEGER},
      </if>
      <if test="record.batchs != null">
        batchs = #{record.batchs,jdbcType=VARCHAR},
      </if>
      <if test="record.balance != null">
        balance = #{record.balance,jdbcType=DECIMAL},
      </if>
      <if test="record.enterpriseId != null">
        enterprise_id = #{record.enterpriseId,jdbcType=BIGINT},
      </if>
      <if test="record.memberId != null">
        member_id = #{record.memberId,jdbcType=BIGINT},
      </if>
      <if test="record.payStatus != null">
        pay_status = #{record.payStatus,jdbcType=INTEGER},
      </if>
      <if test="record.payType != null">
        pay_type = #{record.payType,jdbcType=INTEGER},
      </if>
      <if test="record.creditLockingCustomer != null">
        credit_locking_customer = #{record.creditLockingCustomer,jdbcType=TINYINT},
      </if>
      <if test="record.creditLockingSupplier != null">
        credit_locking_supplier = #{record.creditLockingSupplier,jdbcType=TINYINT},
      </if>
      <if test="record.accountingStateCustomer != null">
        accounting_state_customer = #{record.accountingStateCustomer,jdbcType=TINYINT},
      </if>
      <if test="record.accountingStateSupplier != null">
        accounting_state_supplier = #{record.accountingStateSupplier,jdbcType=TINYINT},
      </if>
      <if test="record.invoiceApplyStatus != null">
        invoice_apply_status = #{record.invoiceApplyStatus,jdbcType=TINYINT},
      </if>
      <if test="record.invoiceMakeStatus != null">
        invoice_make_status = #{record.invoiceMakeStatus,jdbcType=TINYINT},
      </if>
      <if test="record.backStatus != null">
        back_status = #{record.backStatus,jdbcType=TINYINT},
      </if>
      <if test="record.direction != null">
        direction = #{record.direction,jdbcType=TINYINT},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createUserId != null">
        create_user_id = #{record.createUserId,jdbcType=BIGINT},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updateUserId != null">
        update_user_id = #{record.updateUserId,jdbcType=BIGINT},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update unified_order_credit
    set id = #{record.id,jdbcType=BIGINT},
      order_sn = #{record.orderSn,jdbcType=VARCHAR},
      order_id = #{record.orderId,jdbcType=BIGINT},
      goods_id = #{record.goodsId,jdbcType=BIGINT},
      out_snapshot_order_credit_id = #{record.outSnapshotOrderCreditId,jdbcType=BIGINT},
      credit_type = #{record.creditType,jdbcType=INTEGER},
      credit_name = #{record.creditName,jdbcType=VARCHAR},
      daily_account_type = #{record.dailyAccountType,jdbcType=INTEGER},
      batchs = #{record.batchs,jdbcType=VARCHAR},
      balance = #{record.balance,jdbcType=DECIMAL},
      enterprise_id = #{record.enterpriseId,jdbcType=BIGINT},
      member_id = #{record.memberId,jdbcType=BIGINT},
      pay_status = #{record.payStatus,jdbcType=INTEGER},
      pay_type = #{record.payType,jdbcType=INTEGER},
      credit_locking_customer = #{record.creditLockingCustomer,jdbcType=TINYINT},
      credit_locking_supplier = #{record.creditLockingSupplier,jdbcType=TINYINT},
      accounting_state_customer = #{record.accountingStateCustomer,jdbcType=TINYINT},
      accounting_state_supplier = #{record.accountingStateSupplier,jdbcType=TINYINT},
      invoice_apply_status = #{record.invoiceApplyStatus,jdbcType=TINYINT},
      invoice_make_status = #{record.invoiceMakeStatus,jdbcType=TINYINT},
      back_status = #{record.backStatus,jdbcType=TINYINT},
      direction = #{record.direction,jdbcType=TINYINT},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      create_user_id = #{record.createUserId,jdbcType=BIGINT},
      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{record.updateUserId,jdbcType=BIGINT}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCredit">
    update unified_order_credit
    <set>
      <if test="orderSn != null">
        order_sn = #{orderSn,jdbcType=VARCHAR},
      </if>
      <if test="orderId != null">
        order_id = #{orderId,jdbcType=BIGINT},
      </if>
      <if test="goodsId != null">
        goods_id = #{goodsId,jdbcType=BIGINT},
      </if>
      <if test="outSnapshotOrderCreditId != null">
        out_snapshot_order_credit_id = #{outSnapshotOrderCreditId,jdbcType=BIGINT},
      </if>
      <if test="creditType != null">
        credit_type = #{creditType,jdbcType=INTEGER},
      </if>
      <if test="creditName != null">
        credit_name = #{creditName,jdbcType=VARCHAR},
      </if>
      <if test="dailyAccountType != null">
        daily_account_type = #{dailyAccountType,jdbcType=INTEGER},
      </if>
      <if test="batchs != null">
        batchs = #{batchs,jdbcType=VARCHAR},
      </if>
      <if test="balance != null">
        balance = #{balance,jdbcType=DECIMAL},
      </if>
      <if test="enterpriseId != null">
        enterprise_id = #{enterpriseId,jdbcType=BIGINT},
      </if>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=BIGINT},
      </if>
      <if test="payStatus != null">
        pay_status = #{payStatus,jdbcType=INTEGER},
      </if>
      <if test="payType != null">
        pay_type = #{payType,jdbcType=INTEGER},
      </if>
      <if test="creditLockingCustomer != null">
        credit_locking_customer = #{creditLockingCustomer,jdbcType=TINYINT},
      </if>
      <if test="creditLockingSupplier != null">
        credit_locking_supplier = #{creditLockingSupplier,jdbcType=TINYINT},
      </if>
      <if test="accountingStateCustomer != null">
        accounting_state_customer = #{accountingStateCustomer,jdbcType=TINYINT},
      </if>
      <if test="accountingStateSupplier != null">
        accounting_state_supplier = #{accountingStateSupplier,jdbcType=TINYINT},
      </if>
      <if test="invoiceApplyStatus != null">
        invoice_apply_status = #{invoiceApplyStatus,jdbcType=TINYINT},
      </if>
      <if test="invoiceMakeStatus != null">
        invoice_make_status = #{invoiceMakeStatus,jdbcType=TINYINT},
      </if>
      <if test="backStatus != null">
        back_status = #{backStatus,jdbcType=TINYINT},
      </if>
      <if test="direction != null">
        direction = #{direction,jdbcType=TINYINT},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createUserId != null">
        create_user_id = #{createUserId,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUserId != null">
        update_user_id = #{updateUserId,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.base.UnifiedOrderCredit">
    update unified_order_credit
    set order_sn = #{orderSn,jdbcType=VARCHAR},
      order_id = #{orderId,jdbcType=BIGINT},
      goods_id = #{goodsId,jdbcType=BIGINT},
      out_snapshot_order_credit_id = #{outSnapshotOrderCreditId,jdbcType=BIGINT},
      credit_type = #{creditType,jdbcType=INTEGER},
      credit_name = #{creditName,jdbcType=VARCHAR},
      daily_account_type = #{dailyAccountType,jdbcType=INTEGER},
      batchs = #{batchs,jdbcType=VARCHAR},
      balance = #{balance,jdbcType=DECIMAL},
      enterprise_id = #{enterpriseId,jdbcType=BIGINT},
      member_id = #{memberId,jdbcType=BIGINT},
      pay_status = #{payStatus,jdbcType=INTEGER},
      pay_type = #{payType,jdbcType=INTEGER},
      credit_locking_customer = #{creditLockingCustomer,jdbcType=TINYINT},
      credit_locking_supplier = #{creditLockingSupplier,jdbcType=TINYINT},
      accounting_state_customer = #{accountingStateCustomer,jdbcType=TINYINT},
      accounting_state_supplier = #{accountingStateSupplier,jdbcType=TINYINT},
      invoice_apply_status = #{invoiceApplyStatus,jdbcType=TINYINT},
      invoice_make_status = #{invoiceMakeStatus,jdbcType=TINYINT},
      back_status = #{backStatus,jdbcType=TINYINT},
      direction = #{direction,jdbcType=TINYINT},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      create_user_id = #{createUserId,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user_id = #{updateUserId,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>