package com.jeesharp.business.modules.coupon.stats.mapper;

import com.jeesharp.business.modules.coupon.stats.vo.CouponStatsDateCountVO;
import com.jeesharp.business.modules.coupon.stats.vo.CouponStatsTemplateRankRowVO;
import com.jeesharp.business.modules.coupon.stats.vo.CouponStatsTenantScope;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 优惠券统计聚合 Mapper；所有 SQL 须携带租户条件。
 *
 * @author jeesharp
 * @since 2026-07-03
 */
@Mapper
public interface CouponStatsMapper {

    Long countCouponTemplate(@Param("scope") CouponStatsTenantScope scope, @Param("status") Integer status);

    Long countMemberCoupon(@Param("scope") CouponStatsTenantScope scope,
                           @Param("status") Integer status,
                           @Param("getSource") String getSource,
                           @Param("startDateTime") LocalDateTime startDateTime,
                           @Param("endDateTime") LocalDateTime endDateTime);

    List<CouponStatsDateCountVO> dailyClaimByGetDate(@Param("scope") CouponStatsTenantScope scope,
                                                     @Param("startDateTime") LocalDateTime startDateTime,
                                                     @Param("endDateTime") LocalDateTime endDateTime);

    List<CouponStatsDateCountVO> dailyGrantByGetDate(@Param("scope") CouponStatsTenantScope scope,
                                                     @Param("getSource") String getSource,
                                                     @Param("startDateTime") LocalDateTime startDateTime,
                                                     @Param("endDateTime") LocalDateTime endDateTime);

    List<CouponStatsDateCountVO> dailyUseByUseDate(@Param("scope") CouponStatsTenantScope scope,
                                                   @Param("startDateTime") LocalDateTime startDateTime,
                                                   @Param("endDateTime") LocalDateTime endDateTime);

    List<CouponStatsTemplateRankRowVO> topClaimTemplates(@Param("scope") CouponStatsTenantScope scope,
                                                         @Param("limit") int limit);
}
