package com.talentcard.server.mapper;
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.talentcard.server.entity.MerchantCouponClaim;
|
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Select;
|
|
import java.time.LocalDateTime;
|
import java.util.List;
|
import java.util.Map;
|
|
@Mapper
|
public interface MerchantCouponClaimMapper extends BaseMapper<MerchantCouponClaim> {
|
@Select("""
|
<script>
|
select cc.*, c.coupon_name as couponName, c.coupon_type as couponType, c.coupon_amount as couponAmount,
|
m.merchant_name as merchantName, u.name as talentName, u.mobile as talentMobile, tc.card_no as cardNo
|
from merchant_coupon_claim cc
|
join merchant_coupon c on c.id = cc.coupon_id and c.deleted = 0
|
join merchant m on m.id = cc.merchant_id and m.deleted = 0
|
left join talent_user u on u.id = cc.talent_id and u.deleted = 0
|
left join talent_card tc on tc.id = cc.card_id and tc.deleted = 0
|
where cc.deleted = 0
|
<if test="couponId != null">and cc.coupon_id = #{couponId}</if>
|
<if test="merchantId != null">and cc.merchant_id = #{merchantId}</if>
|
<if test="batchNo != null and batchNo != ''">and cc.batch_no = #{batchNo}</if>
|
<if test="claimStatus != null">and cc.claim_status = #{claimStatus}</if>
|
<if test="useStatus != null">and cc.use_status = #{useStatus}</if>
|
<if test="keyword != null and keyword != ''">and (cc.claim_no like concat('%', #{keyword}, '%') or u.name like concat('%', #{keyword}, '%') or u.mobile like concat('%', #{keyword}, '%') or tc.card_no like concat('%', #{keyword}, '%'))</if>
|
<if test="startTime != null">and cc.claimed_at >= #{startTime}</if>
|
<if test="endTime != null">and cc.claimed_at < #{endTime}</if>
|
order by cc.claimed_at desc, cc.id desc
|
limit #{size} offset #{offset}
|
</script>
|
""")
|
List<Map<String, Object>> selectClaimPage(@Param("couponId") Long couponId,
|
@Param("merchantId") Long merchantId,
|
@Param("batchNo") String batchNo,
|
@Param("claimStatus") Integer claimStatus,
|
@Param("useStatus") Integer useStatus,
|
@Param("keyword") String keyword,
|
@Param("startTime") LocalDateTime startTime,
|
@Param("endTime") LocalDateTime endTime,
|
@Param("size") int size,
|
@Param("offset") int offset);
|
|
@Select("""
|
<script>
|
select count(*) from merchant_coupon_claim cc
|
left join talent_user u on u.id = cc.talent_id and u.deleted = 0
|
left join talent_card tc on tc.id = cc.card_id and tc.deleted = 0
|
where cc.deleted = 0
|
<if test="couponId != null">and cc.coupon_id = #{couponId}</if>
|
<if test="merchantId != null">and cc.merchant_id = #{merchantId}</if>
|
<if test="batchNo != null and batchNo != ''">and cc.batch_no = #{batchNo}</if>
|
<if test="claimStatus != null">and cc.claim_status = #{claimStatus}</if>
|
<if test="useStatus != null">and cc.use_status = #{useStatus}</if>
|
<if test="keyword != null and keyword != ''">and (cc.claim_no like concat('%', #{keyword}, '%') or u.name like concat('%', #{keyword}, '%') or u.mobile like concat('%', #{keyword}, '%') or tc.card_no like concat('%', #{keyword}, '%'))</if>
|
<if test="startTime != null">and cc.claimed_at >= #{startTime}</if>
|
<if test="endTime != null">and cc.claimed_at < #{endTime}</if>
|
</script>
|
""")
|
Long countClaimPage(@Param("couponId") Long couponId,
|
@Param("merchantId") Long merchantId,
|
@Param("batchNo") String batchNo,
|
@Param("claimStatus") Integer claimStatus,
|
@Param("useStatus") Integer useStatus,
|
@Param("keyword") String keyword,
|
@Param("startTime") LocalDateTime startTime,
|
@Param("endTime") LocalDateTime endTime);
|
}
|