<?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.gxwebsoft.apps.mapper.CashierMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM apps_cashier a
        <where>
            <if test="param.cashierId != null">
                AND a.cashier_id = #{param.cashierId}
            </if>
            <if test="param.buyerId != null">
                AND a.buyer_id LIKE CONCAT('%', #{param.buyerId}, '%')
            </if>
            <if test="param.merchantCode != null">
                AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
            </if>
            <if test="param.code != null">
                AND a.code LIKE CONCAT('%', #{param.code}, '%')
            </if>
            <if test="param.msg != null">
                AND a.msg LIKE CONCAT('%', #{param.msg}, '%')
            </if>
            <if test="param.outTradeNo != null">
                AND a.out_trade_no LIKE CONCAT('%', #{param.outTradeNo}, '%')
            </if>
            <if test="param.amount != null">
                AND a.amount LIKE CONCAT('%', #{param.amount}, '%')
            </if>
            <if test="param.payTime != null">
                AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%')
            </if>
            <if test="param.payType != null">
                AND a.pay_type LIKE CONCAT('%', #{param.payType}, '%')
            </if>
            <if test="param.totalAmount != null">
                AND a.total_amount = #{param.totalAmount}
            </if>
            <if test="param.receiptAmount != null">
                AND a.receipt_amount = #{param.receiptAmount}
            </if>
            <if test="param.feeAmount != null">
                AND a.fee_amount = #{param.feeAmount}
            </if>
            <if test="param.settleAmount != null">
                AND a.settle_amount = #{param.settleAmount}
            </if>
            <if test="param.merchantName != null">
                AND a.merchant_name LIKE CONCAT('%', #{param.merchantName}, '%')
            </if>
            <if test="param.mobile != null">
                AND a.mobile LIKE CONCAT('%', #{param.mobile}, '%')
            </if>
            <if test="param.orderRemark != null">
                AND a.order_remark LIKE CONCAT('%', #{param.orderRemark}, '%')
            </if>
            <if test="param.orderStatus != null">
                AND a.order_status LIKE CONCAT('%', #{param.orderStatus}, '%')
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.apps.entity.Cashier">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.apps.entity.Cashier">
        <include refid="selectSql"></include>
    </select>

</mapper>
