<?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.slodon.b2b2c.dao.read.system.BillOrderBindReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.system.pojo.BillOrderBind">
    <id column="bind_id" property="bindId" />
    <result column="bill_sn" property="billSn" />
    <result column="order_sn" property="orderSn" />
    <result column="order_amount" property="orderAmount" />
    <result column="commission" property="commission" />
    <result column="attach_commission" property="attachCommission" />
    <result column="refund_commission" property="refundCommission" />
    <result column="refund_amount" property="refundAmount" />
    <result column="platform_activity_amount" property="platformActivityAmount" />
    <result column="platform_voucher_amount" property="platformVoucherAmount" />
    <result column="integral_cash_amount" property="integralCashAmount" />
    <result column="compensation_amount" property="compensationAmount" />
    <result column="create_time" property="createTime" />
    <result column="finish_time" property="finishTime" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `bind_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.bindIdNotEquals != null">
          AND `bind_id` != #{example.bindIdNotEquals}
        </if>
        <if test="example.bindIdIn != null">
          AND `bind_id` in (${example.bindIdIn})
        </if>
        <if test="example.billSn != null">
          AND `bill_sn` = #{example.billSn}
        </if>
        <if test="example.billSnLike != null">
          AND `bill_sn` like concat('%',#{example.billSnLike},'%')
        </if>
        <if test="example.orderSn != null">
          AND `order_sn` = #{example.orderSn}
        </if>
        <if test="example.orderSnLike != null">
          AND `order_sn` like concat('%',#{example.orderSnLike},'%')
        </if>
        <if test="example.orderAmount != null">
          AND `order_amount` = #{example.orderAmount}
        </if>
        <if test="example.commission != null">
          AND `commission` = #{example.commission}
        </if>
        <if test="example.attachCommission != null">
          AND `attach_commission` = #{example.attachCommission}
        </if>
        <if test="example.refundCommission != null">
          AND `refund_commission` = #{example.refundCommission}
        </if>
        <if test="example.refundAmount != null">
          AND `refund_amount` = #{example.refundAmount}
        </if>
        <if test="example.platformActivityAmount != null">
          AND `platform_activity_amount` = #{example.platformActivityAmount}
        </if>
        <if test="example.platformVoucherAmount != null">
          AND `platform_voucher_amount` = #{example.platformVoucherAmount}
        </if>
        <if test="example.integralCashAmount != null">
          AND `integral_cash_amount` = #{example.integralCashAmount}
        </if>
        <if test="example.compensationAmount != null">
          AND `compensation_amount` = #{example.compensationAmount}
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.finishTimeAfter != null">
          AND `finish_time` <![CDATA[ >= ]]> #{example.finishTimeAfter}
        </if>
        <if test="example.finishTimeBefore != null">
          AND `finish_time` <![CDATA[ <= ]]> #{example.finishTimeBefore}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `bind_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.system.example.BillOrderBindExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `sys_bill_order_bind`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `sys_bill_order_bind`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `sys_bill_order_bind`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `sys_bill_order_bind`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `sys_bill_order_bind`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `sys_bill_order_bind`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
</mapper>