package com.ylx.coupon.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ylx.common.core.domain.R;
import com.ylx.coupon.domain.Coupon;
import com.ylx.coupon.domain.CouponReceive;
import com.ylx.massage.domain.vo.ClaimCouponRequestVO;
import com.ylx.massage.domain.vo.CouponReceiveVo;
import com.ylx.massage.domain.vo.CouponReceivesVO;

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

/**
 * 优惠券领取表(CouponReceive)表服务接口
 *
 * @author makejava
 * @since 2024-05-14 11:25:45
 */
public interface CouponReceiveService extends IService<CouponReceive> {

    /**
     * 领取优惠券
     * @param couponReceive
     * @return Coupon
     */
    Coupon submit(CouponReceive couponReceive);

    /**
     * 领取优惠券
     * @param couponReceive
     * @return
     */
    Integer submits(CouponReceivesVO couponReceive);

    /**
     * 领取优惠券
     * @param claimCouponRequestVO
     * @return R<?>
     */
    R<?> receiveVolution(ClaimCouponRequestVO claimCouponRequestVO);


    List<CouponReceiveVo> getByOpenId(String openid);

    void removeCoupons(List<CouponReceiveVo> coupons);


    List<Coupon> couponWindows(CouponReceive couponReceive);


    Map<String, Object> selectCouponDetailForCalc(String couponId, String openId);

    int useCouponOptimisticLock(String couponId, String openId, Long orderId, Integer orderType, LocalDateTime now);

    int incrementUsedNum(String couponId);

    int returnCouponOptimisticLock(String couponId, String openId, Long orderId);

    void decrementUsedNum(String couponId);
}

