package com.fzm.mall.server.admin.finance_center.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fzm.mall.server.admin.finance_center.entity.vo.IntegralListVO;
import com.fzm.mall.server.admin.finance_center.model.MerchantIntegral;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author wangp
 * @date 2021/4/27 15:53
 * @description Mapper 接口
 * @since JDK 1.8
 */
@Mapper
public interface MerchantIntegralMapper extends BaseMapper<MerchantIntegral> {
    IPage<IntegralListVO> page(IPage<IntegralListVO> page, String label, String merchantName, Integer status);

    @Select("SELECT * FROM merchant_integral WHERE merchant_id = #{merchantId} AND is_delete = 0 ORDER BY create_time DESC LIMIT 1")
    MerchantIntegral queryByMerchantId(String merchantId);

    @Select("SELECT * FROM merchant_integral WHERE label = #{label} AND merchant_id = #{merchantId} AND status =5 AND is_delete = 0")
    MerchantIntegral queryByMerchantIdAndLabel(String label, String merchantId);

    @Select("SELECT * FROM merchant_integral WHERE label = #{label} AND status =3 AND is_delete = 0")
    MerchantIntegral queryByLabel(String label);
}
