package com.fuint.common.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.common.dto.PointDto;
import com.fuint.common.dto.RaffleDto;
import com.fuint.common.dto.RaffleItemDto;
import com.fuint.common.dto.UserInfo;
import com.fuint.common.param.RaffleParam;
import com.fuint.framework.exception.BusinessCheckException;
import com.fuint.framework.pagination.PaginationRequest;
import com.fuint.framework.pagination.PaginationResponse;
import com.fuint.framework.web.ResponseObject;
import com.fuint.repository.model.MtPoint;
import com.fuint.repository.model.MtRaffle;
import com.fuint.repository.model.MtRaffleItem;
import com.fuint.repository.model.MtUser;

import java.util.List;

/**
 * 抽奖业务接口
 *
 * Created by FSQ
 * CopyRight https://www.fuint.cn
 */
public interface RaffleService extends IService<MtRaffle> {

    /**
     * 分页查询抽奖列表
     *
     * @param paginationRequest
     * @return
     */
    PaginationResponse<RaffleDto> queryListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;


    /**
     * 保存抽奖
     *
     * @param reqRaffleDto
     * @return
     */
    int addRaffle(MtRaffle reqRaffleDto) throws BusinessCheckException;

    /**
     * 保存抽奖明细
     *
     * @param reqRaffleItemDto
     * @return
     */
    void addRaffleItem(MtRaffleItem reqRaffleItemDto) throws BusinessCheckException;

    /**
     * 保存抽奖明细
     *
     * @param raffleItemDto
     * @return
     */
    List<MtRaffleItem> queryRaffleItemByRaffleId(RaffleItemDto raffleItemDto) throws BusinessCheckException;
    List<RaffleItemDto> queryRaffleItemByRaffleId2wechat(Integer raffleId) throws BusinessCheckException;


    List<MtRaffleItem> doRaffleByRaffleId(Integer raffleId,Integer num, UserInfo mtUser,Integer forwardUserId) throws BusinessCheckException;

    ResponseObject findRaffleList(RaffleParam raffleParam) throws  BusinessCheckException;

    MtRaffle queryRaffle(Integer raffleId) throws BusinessCheckException;

    /**
     * 保存抽奖
     *
     * @param reqRaffleDto
     * @return
     */
    int updRaffle(MtRaffle reqRaffleDto) throws BusinessCheckException;

    /**
     * 保存抽奖明细
     *
     * @param userId
     * @return
     */
    List<RaffleItemDto> queryRaffleItemByUserId(Integer userId) throws BusinessCheckException;


    boolean tranfer2Point(Integer raffleItemId, Integer userId) throws BusinessCheckException;

    Integer userPoint(Integer userId) throws  BusinessCheckException;

    boolean dealRaffleItem(Integer raffleItemId, String name) throws BusinessCheckException;

    /**
     * 最新抽奖列表
     *
     * @param limit
     * @return
     */
    List<RaffleDto> getLatestRaffles(Integer limit) throws BusinessCheckException;

    /**
     * 最新中奖列表
     *
     * @param limit
     * @return
     */
    List<RaffleItemDto> getLatestWinItems(Integer limit) throws BusinessCheckException;

}
