package com.ym.mec.biz.service;

import com.ym.mec.biz.dal.dto.HorseRaceLampDto;
import com.ym.mec.biz.dal.dto.SysCouponCodeDto;
import com.ym.mec.biz.dal.entity.CouponPayParam;
import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
import com.ym.mec.biz.dal.entity.SysCouponCode;
import com.ym.mec.biz.dal.page.SysCouponCodeQueryInfo;
import com.ym.mec.common.page.PageInfo;
import com.ym.mec.common.page.QueryInfo;
import com.ym.mec.common.service.BaseService;

import java.math.BigDecimal;
import java.util.List;

public interface SysCouponCodeService extends BaseService<Long, SysCouponCode> {

    /**
     * @param userId:         用户编号
     * @param couponId:       优惠券编号
     * @param paymentOrderId: 订单编号
     * @param exchangeNum:    兑换数量
     * @return boolean
     * @describe 兑换优惠券
     * @author Joburgess
     * @date 2021/9/8 0008
     */
    boolean exchangeCoupon(Integer userId, Integer couponId, Long paymentOrderId, Integer exchangeNum, int type, Integer issueId);

    boolean exchangeCouponTest(Integer userId, Integer couponId, Long paymentOrderId, Integer exchangeNum);

    /**
     * @param queryInfo:
     * @return com.ym.mec.common.page.PageInfo<com.ym.mec.biz.dal.dto.SysCouponCodeDto>
     * @describe 优惠券领取列表
     * @author Joburgess
     * @date 2021/9/8 0008
     */
    PageInfo<SysCouponCodeDto> querySysCouponUseList(SysCouponCodeQueryInfo queryInfo);

    /**
     * 获取优惠券跑马灯
     *
     * @param queryInfo
     * @return
     */
    PageInfo<HorseRaceLampDto> queryHorseRaceLampDtoList(QueryInfo queryInfo);

    /**
     * 使用优惠券
     *
     * @param couponIdList
     * @param amount
     * @param useFlag      是否消耗优惠券
     * @return
     */
    StudentPaymentOrder use(List<Integer> couponIdList, BigDecimal amount, Boolean useFlag);

    StudentPaymentOrder use(List<Integer> couponIdList, BigDecimal amount, Boolean useFlag, String... allowType);

    List<SysCouponCodeDto> checkCoupon(List<Integer> couponIdList, String... allowType);

    /**
     * 获取优惠券相关参数-校验优惠券和传入的支付金额是否合法
     *
     * @param couponIdList 优惠券集合
     * @param allowType    本次允许使用的优惠券类型,null则不验证
     */
    CouponPayParam getCouponPayParam(List<Integer> couponIdList, String... allowType);

    /**
     * 获取优惠券相关参数-校验优惠券和传入的支付金额是否合法
     *
     * @param couponIdList 优惠券集合
     */
    CouponPayParam getCouponPayParam(List<Integer> couponIdList);

    List<SysCouponCodeDto> findByIdList(List<Integer> couponIdList);

    void useCoupon(List<Integer> couponIdList);

    /**
     * 退优惠券
     *
     * @param couponCodeId
     */
    void quit(String couponCodeId);
}
