<?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.fzm.mall.server.admin.finance_center.mapper.MerchantIntegralMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.finance_center.model.MerchantIntegral">
        <id column="id" property="id"/>
        <result column="merchant_id" property="merchantId"/>
        <result column="label" property="label"/>
        <result column="name" property="name"/>
        <result column="logo" property="logo"/>
        <result column="issue_num" property="issueNum"/>
        <result column="balance_num" property="balanceNum"/>
        <result column="issue_addr" property="issueAddr"/>
        <result column="description" property="description"/>
        <result column="type" property="type"/>
        <result column="status" property="status"/>
        <result column="fail_reason" property="failReason"/>
        <result column="err_msg" property="errMsg"/>
        <result column="is_delete" property="idDel"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="page" resultType="com.fzm.mall.server.admin.finance_center.entity.vo.IntegralListVO">
        SELECT
        A.label,A.name,A.description,A.issue_num,A.issue_addr,A.merchant_ratio,A.base_ratio,B.enterprise_name AS
        applyName,A.status
        FROM
        merchant_integral A
        LEFT JOIN
        merchant B
        ON
        A.merchant_id = B.merchant_id
        <where>
            A.status IN (3,5,6)
            AND
            A.is_delete = 0
            <if test="label!=null and label!=''">
                AND
                A.label = #{label}
            </if>
            <if test="merchantName!=null and merchantName!=''">
                AND
                B.enterprise_name = #{merchantName}
            </if>
            <if test="status!=null">
                AND
                A.status = #{status}
            </if>
        </where>
        ORDER BY
        A.create_time
        DESC
    </select>
</mapper>
