package com.talentcard.server.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.talentcard.server.entity.MerchantCouponManagement; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import java.time.LocalDate; import java.util.List; import java.util.Map; @Mapper public interface MerchantCouponManagementMapper extends BaseMapper { @Select(""" """) List> selectManagementPage(@Param("merchantId") Long merchantId, @Param("couponType") String couponType, @Param("batchNo") String batchNo, @Param("status") Integer status, @Param("keyword") String keyword, @Param("validOn") LocalDate validOn, @Param("size") int size, @Param("offset") int offset); @Select(""" """) Long countManagementPage(@Param("merchantId") Long merchantId, @Param("couponType") String couponType, @Param("batchNo") String batchNo, @Param("status") Integer status, @Param("keyword") String keyword, @Param("validOn") LocalDate validOn); @Select("select count(*) from merchant where id = #{merchantId} and deleted = 0") Long countMerchant(@Param("merchantId") Long merchantId); @Update(""" update merchant_coupon set claimed_quantity = claimed_quantity + 1 where id = #{couponId} and deleted = 0 and status = 1 and (total_quantity = -1 or claimed_quantity < total_quantity) """) int reserveOne(@Param("couponId") Long couponId); @Update("update merchant_coupon set claimed_quantity = greatest(claimed_quantity - 1, 0) where id = #{couponId} and deleted = 0") int releaseOne(@Param("couponId") Long couponId); @Select("select count(*) from talent_user where id = #{talentId} and deleted = 0") Long countTalent(@Param("talentId") Long talentId); @Select("select count(*) from talent_card where id = #{cardId} and talent_id = #{talentId} and deleted = 0") Long countTalentCard(@Param("cardId") Long cardId, @Param("talentId") Long talentId);}