From 7361c250cee0a13724bd4ac613a39e57b8576ec5 Mon Sep 17 00:00:00 2001
From: wenminjie <1036699586@qq.com>
Date: 星期三, 12 八月 2026 17:02:16 +0800
Subject: [PATCH] 小程序对接
---
talent-card-server/src/main/java/com/talentcard/server/mapper/TicketPackageCodeMapper.java | 74 +++++++++++++++++++++++++++++++++---
1 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/talent-card-server/src/main/java/com/talentcard/server/mapper/TicketPackageCodeMapper.java b/talent-card-server/src/main/java/com/talentcard/server/mapper/TicketPackageCodeMapper.java
index f5be65e..205b3b8 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/mapper/TicketPackageCodeMapper.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/mapper/TicketPackageCodeMapper.java
@@ -53,7 +53,10 @@
join ticket_package p on p.id = c.package_id and p.deleted = 0 and p.status = 1
where c.deleted = 0
and c.status = 'AVAILABLE'
- and p.merchant_id = #{merchantId}
+ and (p.merchant_id = #{merchantId} or exists (
+ select 1 from ticket_package_merchant pm
+ where pm.package_id = p.id and pm.merchant_id = #{merchantId} and pm.deleted = 0
+ ))
and (p.valid_start is null or p.valid_start <= current_date)
and (p.valid_end is null or p.valid_end >= current_date)
order by c.id asc
@@ -94,7 +97,20 @@
p.package_no as packageNo,
p.package_name as packageName,
p.merchant_id as merchantId,
- m.merchant_name as merchantName,
+ coalesce(m.merchant_name, (
+ select m0.merchant_name
+ from ticket_package_merchant pm0
+ join merchant m0 on m0.id = pm0.merchant_id and m0.deleted = 0
+ where pm0.package_id = p.id and pm0.deleted = 0
+ order by pm0.sort_no asc, pm0.id asc
+ limit 1
+ )) as merchantName,
+ (
+ select group_concat(m1.merchant_name order by pm1.sort_no asc, pm1.id asc separator '、')
+ from ticket_package_merchant pm1
+ join merchant m1 on m1.id = pm1.merchant_id and m1.deleted = 0
+ where pm1.package_id = p.id and pm1.deleted = 0
+ ) as merchantNames,
p.valid_start as validStart,
p.valid_end as validEnd,
p.status as packageStatus,
@@ -136,7 +152,20 @@
p.package_no as packageNo,
p.package_name as packageName,
p.merchant_id as merchantId,
- m.merchant_name as merchantName,
+ coalesce(m.merchant_name, (
+ select m0.merchant_name
+ from ticket_package_merchant pm0
+ join merchant m0 on m0.id = pm0.merchant_id and m0.deleted = 0
+ where pm0.package_id = p.id and pm0.deleted = 0
+ order by pm0.sort_no asc, pm0.id asc
+ limit 1
+ )) as merchantName,
+ (
+ select group_concat(m1.merchant_name order by pm1.sort_no asc, pm1.id asc separator '、')
+ from ticket_package_merchant pm1
+ join merchant m1 on m1.id = pm1.merchant_id and m1.deleted = 0
+ where pm1.package_id = p.id and pm1.deleted = 0
+ ) as merchantNames,
p.valid_start as validStart,
p.valid_end as validEnd,
p.status as packageStatus,
@@ -177,12 +206,21 @@
@Select("""
select c.id,
c.package_id as packageId,
+ p.package_no as packageNo,
p.package_name as packageName,
+ coalesce((
+ select group_concat(m1.merchant_name order by pm1.sort_no asc, pm1.id asc separator '、')
+ from ticket_package_merchant pm1
+ join merchant m1 on m1.id = pm1.merchant_id and m1.deleted = 0
+ where pm1.package_id = p.id and pm1.deleted = 0
+ ), m.merchant_name) as merchantNames,
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,
+ coalesce(cl.talent_name, u.name) as lockedTalentName,
+ coalesce(cl.talent_mobile, u.mobile) as lockedTalentMobile,
c.locked_at as lockedAt,
c.issued_claim_id as issuedClaimId,
c.issued_at as issuedAt,
@@ -192,11 +230,21 @@
c.updated_at as updatedAt
from ticket_package_code c
join ticket_package p on p.id = c.package_id and p.deleted = 0
+ left join merchant m on m.id = p.merchant_id and m.deleted = 0
+ left join ticket_package_claim cl on cl.code_id = c.id and cl.deleted = 0
+ left join talent_user u on u.id = c.locked_by_talent_id and u.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}, '%'))
+ and (#{keyword} is null or #{keyword} = '' or cast(c.id as char) like concat('%', #{keyword}, '%') or c.exchange_code like concat('%', #{keyword}, '%'))
+ and (#{packageKeyword} is null or #{packageKeyword} = '' or p.package_name like concat('%', #{packageKeyword}, '%') or p.package_no like concat('%', #{packageKeyword}, '%'))
+ and (#{merchantKeyword} is null or #{merchantKeyword} = '' or m.merchant_name like concat('%', #{merchantKeyword}, '%') or exists (
+ select 1
+ from ticket_package_merchant pm
+ join merchant mm on mm.id = pm.merchant_id and mm.deleted = 0
+ where pm.package_id = p.id and pm.deleted = 0 and mm.merchant_name like concat('%', #{merchantKeyword}, '%')
+ ))
order by c.id desc
limit #{size} offset #{offset}
""")
@@ -204,6 +252,8 @@
@Param("status") String status,
@Param("batchNo") String batchNo,
@Param("keyword") String keyword,
+ @Param("packageKeyword") String packageKeyword,
+ @Param("merchantKeyword") String merchantKeyword,
@Param("size") int size,
@Param("offset") int offset);
@@ -211,14 +261,24 @@
select count(*)
from ticket_package_code c
join ticket_package p on p.id = c.package_id and p.deleted = 0
+ left join merchant m on m.id = p.merchant_id and m.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}, '%'))
+ and (#{keyword} is null or #{keyword} = '' or cast(c.id as char) like concat('%', #{keyword}, '%') or c.exchange_code like concat('%', #{keyword}, '%'))
+ and (#{packageKeyword} is null or #{packageKeyword} = '' or p.package_name like concat('%', #{packageKeyword}, '%') or p.package_no like concat('%', #{packageKeyword}, '%'))
+ and (#{merchantKeyword} is null or #{merchantKeyword} = '' or m.merchant_name like concat('%', #{merchantKeyword}, '%') or exists (
+ select 1
+ from ticket_package_merchant pm
+ join merchant mm on mm.id = pm.merchant_id and mm.deleted = 0
+ where pm.package_id = p.id and pm.deleted = 0 and mm.merchant_name like concat('%', #{merchantKeyword}, '%')
+ ))
""")
Long countAdminPage(@Param("packageId") Long packageId,
@Param("status") String status,
@Param("batchNo") String batchNo,
- @Param("keyword") String keyword);
-}
\ No newline at end of file
+ @Param("keyword") String keyword,
+ @Param("packageKeyword") String packageKeyword,
+ @Param("merchantKeyword") String merchantKeyword);
+}
--
Gitblit v1.7.1