From 0b064045b0af20040b6ad976a7ce33cdc03d91f7 Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期五, 28 八月 2026 15:57:48 +0800
Subject: [PATCH] fix: allow scanned benefit codes to finish verification
---
talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantVerificationService.java | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantVerificationService.java b/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantVerificationService.java
index 82188d5..8dfdda1 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantVerificationService.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantVerificationService.java
@@ -69,11 +69,12 @@
if (number(attempt.get("attemptStatus")) == 1) {
return confirmed(attempt.get("verifyNo"), null);
}
- if (number(attempt.get("attemptStatus")) != 0 || expired(attempt.get("expiresAt"))) {
+ String credentialType = String.valueOf(attempt.get("credentialType"));
+ boolean codeExpiryRequired = !ORDER_CODE.equals(credentialType) && !FREE_STAY_CODE.equals(credentialType);
+ if (number(attempt.get("attemptStatus")) != 0 || (codeExpiryRequired && expired(attempt.get("expiresAt")))) {
jdbc.update("update merchant_verification_attempt set status = 2 where id = ? and status = 0", number(attempt.get("attemptId")));
throw new BusinessException(ErrorCode.CONFLICT, "核销凭证已失效,请重新扫码");
}
- String credentialType = String.valueOf(attempt.get("credentialType"));
return switch (credentialType) {
case TALENT_CODE -> throw new BusinessException(ErrorCode.CONFLICT, "人才码需要先录入消费金额并发送订单");
case ORDER_CODE -> confirmOrderCode(principal, attempt);
@@ -159,19 +160,19 @@
from order_dynamic_verification_code c
join benefit_order o on o.id = c.order_id and o.deleted = 0
left join talent_card tc on tc.id = o.card_id and tc.deleted = 0
- where c.id = ? and c.status = 0
+ where c.id = ? and c.status in (0, 2)
limit 1 for update
""", number(attempt.get("orderVerificationCodeId")));
if (codes.isEmpty()) {
throw new BusinessException(ErrorCode.CONFLICT, "订单核销码已被使用或已失效");
}
Map<String, Object> code = codes.get(0);
- if (!belongsToPrincipal(code, principal) || number(code.get("orderStatus")) != 1 || number(code.get("verifyStatus")) != 0 || expired(code.get("expiresAt"))) {
+ if (!belongsToPrincipal(code, principal) || number(code.get("orderStatus")) != 1 || number(code.get("verifyStatus")) != 0) {
throw new BusinessException(ErrorCode.CONFLICT, "订单当前不可核销");
}
int codeUpdated = jdbc.update("""
update order_dynamic_verification_code set status = 1
- where id = ? and status = 0 and expires_at > now()
+ where id = ? and status in (0, 2)
""", number(code.get("orderVerificationCodeId")));
int orderUpdated = jdbc.update("""
update benefit_order set verify_status = 1
@@ -194,7 +195,7 @@
from free_stay_verification_code c
join talent_free_stay_voucher v on v.id = c.voucher_id
left join talent_card tc on tc.id = v.card_id and tc.deleted = 0
- where c.id = ? and c.status = 0
+ where c.id = ? and c.status in (0, 2)
limit 1 for update
""", number(attempt.get("freeStayVerificationCodeId")));
if (codes.isEmpty()) {
@@ -202,12 +203,12 @@
}
Map<String, Object> code = codes.get(0);
if (!principal.merchantId().equals(number(code.get("merchantId"))) || number(code.get("voucherStatus")) != 1
- || expiredDate(code.get("validEnd")) || number(code.get("usedCount")) >= number(code.get("totalCount")) || expired(code.get("expiresAt"))) {
+ || expiredDate(code.get("validEnd")) || number(code.get("usedCount")) >= number(code.get("totalCount"))) {
throw new BusinessException(ErrorCode.CONFLICT, "免费入住券当前不可核销");
}
int codeUpdated = jdbc.update("""
update free_stay_verification_code set status = 1
- where id = ? and status = 0 and expires_at > now()
+ where id = ? and status in (0, 2)
""", number(code.get("freeStayVerificationCodeId")));
int voucherUpdated = jdbc.update("""
update talent_free_stay_voucher set used_count = used_count + 1
--
Gitblit v1.7.1