<?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.common.system.mapper.PaymentMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM gxwebsoft_core.sys_payment a
        <where>
            <if test="param.id != null">
                AND a.id = #{param.id}
            </if>
            <if test="param.name != null">
                AND a.name LIKE CONCAT('%', #{param.name}, '%')
            </if>
            <if test="param.type != null">
              AND a.type = #{param.type}
            </if>
            <if test="param.code != null">
                AND a.code = #{param.code}
            </if>
            <if test="param.wechatType != null">
                AND a.wechat_type = #{param.wechatType}
            </if>
            <if test="param.appId != null">
                AND a.app_id LIKE CONCAT('%', #{param.appId}, '%')
            </if>
            <if test="param.mchId != null">
                AND a.mch_id LIKE CONCAT('%', #{param.mchId}, '%')
            </if>
            <if test="param.apiKey != null">
                AND a.api_key LIKE CONCAT('%', #{param.apiKey}, '%')
            </if>
            <if test="param.apiclientCert != null">
                AND a.apiclient_cert LIKE CONCAT('%', #{param.apiclientCert}, '%')
            </if>
            <if test="param.apiclientKey != null">
                AND a.apiclient_key LIKE CONCAT('%', #{param.apiclientKey}, '%')
            </if>
            <if test="param.merchantSerialNumber != null">
                AND a.merchant_serial_number LIKE CONCAT('%', #{param.merchantSerialNumber}, '%')
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </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.tenantId != null">
                AND a.tenant_id = #{param.tenantId}
            </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.common.system.entity.Payment">
        <include refid="selectSql"></include>
    </select>

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

    <select id="getByType" resultType="com.gxwebsoft.common.system.entity.Payment">
        SELECT a.*
        FROM gxwebsoft_core.sys_payment a
        WHERE a.type = #{param.type}
          AND a.deleted = 0
          AND a.status = 1
          AND a.tenant_id = #{param.tenantId}
    </select>


</mapper>
