package com.fs.live.mapper;

import java.util.List;
import com.fs.live.domain.LiveCouponIssue;
import com.fs.live.domain.LiveCouponIssueRelation;
import com.fs.live.param.CouponPO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 优惠券领取Mapper接口
 *
 * @author fs
 * @date 2025-09-30
 */
public interface LiveCouponIssueMapper
{
    /**
     * 查询优惠券领取
     *
     * @param id 优惠券领取ID
     * @return 优惠券领取
     */
    public LiveCouponIssue selectLiveCouponIssueById(Long id);

    /**
     * 查询优惠券领取列表
     *
     * @param liveCouponIssue 优惠券领取
     * @return 优惠券领取集合
     */
    public List<LiveCouponIssue> selectLiveCouponIssueList(LiveCouponIssue liveCouponIssue);

    /**
     * 新增优惠券领取
     *
     * @param liveCouponIssue 优惠券领取
     * @return 结果
     */
    public int insertLiveCouponIssue(LiveCouponIssue liveCouponIssue);

    /**
     * 修改优惠券领取
     *
     * @param liveCouponIssue 优惠券领取
     * @return 结果
     */
    public int updateLiveCouponIssue(LiveCouponIssue liveCouponIssue);

    /**
     * 删除优惠券领取
     *
     * @param id 优惠券领取ID
     * @return 结果
     */
    public int deleteLiveCouponIssueById(Long id);

    /**
     * 批量删除优惠券领取
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteLiveCouponIssueByIds(Long[] ids);

    @Select("select lci.* from live_coupon_issue_user lciu left join live_coupon_issue lci on lci.id=lciu.issue_id where lciu.user_id = #{coupon.userId} ")
    List<LiveCouponIssue> selectLiveCouponIssueUserByCouponPO(@Param("coupon") CouponPO coupon);

    @Select("select lci.* from live_coupon_issue_user lciu where lciu.user_id=#{coupon.userId} and lciu.goods_id=#{coupon.goodsId}")
    List<LiveCouponIssue> curCoupon(@Param("coupon") CouponPO coupon);

    @Select("select * from live_coupon_issue_relation where live_id= #{liveId}")
    List<LiveCouponIssueRelation> selectRelationByLiveId(Long existLiveId);

    @Insert("insert into live_coupon_issue_relation(live_id,coupon_issue_id,is_show,goods_id) values(#{liveId},#{couponIssueId},#{isShow},#{goodsId})")
    void insertLiveCouponIssueRelation(LiveCouponIssueRelation liveCouponIssueRelation);

    @Select("select * from live_coupon_issue where coupon_id= #{couponId}")
    LiveCouponIssue selectLiveCouponIssueByCouponId(@Param("couponId") Long couponId);
}
