package com.ym.mec.biz.dal.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ym.mec.biz.dal.entity.SysCoupon;
import com.ym.mec.biz.dal.entity.SysCouponIssueRecord;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 优惠券发放记录(SysCouponIssueRecord)表数据库访问层
 *
 * @author hgw
 * @since 2021-12-29 20:25:21
 */
public interface SysCouponIssueRecordDao extends BaseMapper<SysCouponIssueRecord> {

    int insertBatch(@Param("entities") List<SysCouponIssueRecord> entities);

    <T> IPage<T> queryIssueDetail(Page<T> page, @Param("param") Map<String, Object> param);

    <T> IPage<T> queryIssueRecord(Page<T> page, @Param("param") Map<String, Object> param);

    int queryCouponCode(@Param("issueId") Integer issueId, @Param("state") Integer state);

    /**
     * 撤回未使用的优惠券
     */
    void revoke(Integer issueId);

    /**
     * @param id         sys_coupon表的id
     * @param consumeNum 消费数量
     */
    void opsConsume(@Param("id") Integer id, @Param("consumeNum") Integer consumeNum);

    List<SysCoupon> queryUserCanGetCoupon(@Param("userId") Integer userId,@Param("tenantId") Integer tenantId);
}

