package com.yonge.cooleshow.biz.dal.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yonge.cooleshow.biz.dal.dto.UserParam;
import com.yonge.cooleshow.biz.dal.entity.CouponIssue;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
import com.yonge.cooleshow.biz.dal.enums.SendTypeEnum;
import com.yonge.cooleshow.biz.dal.queryInfo.CouponInfoQuery;
import com.yonge.cooleshow.biz.dal.queryInfo.CouponIssueQueryInfo;
import com.yonge.cooleshow.biz.dal.vo.CouponIssueUserVo;
import com.yonge.cooleshow.biz.dal.vo.coupon.CouponInfoWrapper;
import com.yonge.cooleshow.biz.dal.vo.coupon.CouponIssueWrapper;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 优惠券发放 服务类
 * </p>
 *
 * @author Eric
 * @since 2022-09-02
 */
public interface CouponIssueService extends IService<CouponIssue> {

    /**
     * 优惠券发放记录分页
     *
     * @param page
     * @param query
     * @return
     */
    IPage<CouponIssueWrapper> queryCouponIssueInfo(IPage<CouponIssueWrapper> page, CouponIssueQueryInfo query);

    /**
     * 撤销优惠券
     *
     * @param couponIssueId 优惠券发放记录id
     * @return
     */
    Boolean withdrawCoupon(Long couponIssueId);

    /**
     * 发放优惠券
     * @param couponId 优惠券id
     * @param userParam 用户信息
     * @param issuer
     * @param reason
     * @param date
     * @return
     */
    void issueCoupon(Long couponId, List<UserParam> userParam, Long issuer, String reason,SendTypeEnum issueWay, Date date);

    /**
     * 保存发放优惠券记录，不发推送
     */
    void saveIssueCoupon(Long couponId, List<UserParam> userParam, Long issuer, String reason, SendTypeEnum issueWay, Date date);

    /**
     * 查询能发放优惠券的用户列表
     *
     * @param couponId 优惠券id
     * @param client 客户端
     * @param keyword 真实姓名/昵称/手机号/编号
     */
    IPage<CouponIssueUserVo> queryUser(IPage<CouponIssueUserVo> iPage, Long couponId, ClientEnum client, String keyword);

    /**
     * 统计用户优惠券状态
     * @param id 用户ID
     * @param query CouponInfoQuery.CouponStateStatQuery
     * @return List<CouponInfoWrapper.CouponStat>
     */
    List<CouponInfoWrapper.CouponStat> queryCouponStateStatInfo(Long id, CouponInfoQuery.CouponStateStatQuery query);
}
