wenminjie
2026-08-04 93414e8ee25852aca467213402585d0e65c08a4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.talentcard.server.mapper;
 
import java.util.List;
import java.util.Map;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.talentcard.server.entity.TicketPackageCode;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
@Mapper
public interface TicketPackageCodeMapper extends BaseMapper<TicketPackageCode> {
 
    @Select("""
            select *
            from ticket_package_code
            where package_id = #{packageId}
              and status = 'AVAILABLE'
              and deleted = 0
            order by id asc
            limit 1
            for update
            """)
    TicketPackageCode selectAvailableCodeForUpdate(@Param("packageId") Long packageId);
 
    @Select("""
            select c.id,
                   c.package_id as packageId,
                   p.package_name as packageName,
                   c.exchange_code as exchangeCode,
                   c.batch_no as batchNo,
                   c.status,
                   c.locked_by_talent_id as lockedByTalentId,
                   c.locked_by_card_id as lockedByCardId,
                   c.locked_at as lockedAt,
                   c.issued_claim_id as issuedClaimId,
                   c.issued_at as issuedAt,
                   c.used_at as usedAt,
                   c.remark,
                   c.created_at as createdAt,
                   c.updated_at as updatedAt
            from ticket_package_code c
            join ticket_package p on p.id = c.package_id and p.deleted = 0
            where c.deleted = 0
              and (#{packageId} is null or c.package_id = #{packageId})
              and (#{status} is null or #{status} = '' or c.status = #{status})
              and (#{batchNo} is null or #{batchNo} = '' or c.batch_no = #{batchNo})
              and (#{keyword} is null or #{keyword} = '' or c.exchange_code like concat('%', #{keyword}, '%') or p.package_name like concat('%', #{keyword}, '%'))
            order by c.id desc
            limit #{size} offset #{offset}
            """)
    List<Map<String, Object>> selectAdminPage(@Param("packageId") Long packageId,
                                              @Param("status") String status,
                                              @Param("batchNo") String batchNo,
                                              @Param("keyword") String keyword,
                                              @Param("size") int size,
                                              @Param("offset") int offset);
 
    @Select("""
            select count(*)
            from ticket_package_code c
            join ticket_package p on p.id = c.package_id and p.deleted = 0
            where c.deleted = 0
              and (#{packageId} is null or c.package_id = #{packageId})
              and (#{status} is null or #{status} = '' or c.status = #{status})
              and (#{batchNo} is null or #{batchNo} = '' or c.batch_no = #{batchNo})
              and (#{keyword} is null or #{keyword} = '' or c.exchange_code like concat('%', #{keyword}, '%') or p.package_name like concat('%', #{keyword}, '%'))
            """)
    Long countAdminPage(@Param("packageId") Long packageId,
                        @Param("status") String status,
                        @Param("batchNo") String batchNo,
                        @Param("keyword") String keyword);
}