From 971e637c2eebe93011a485ddfa99d4f19289811d Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期三, 05 八月 2026 16:06:36 +0800
Subject: [PATCH] feat(admin): 添加优惠券人才等级数量配置功能并完善商户入驻流程
---
talent-card-server/src/main/java/com/talentcard/server/business/auth/TalentAuthService.java | 36 +++++++++++++++++++++++++++++++++---
1 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/auth/TalentAuthService.java b/talent-card-server/src/main/java/com/talentcard/server/business/auth/TalentAuthService.java
index 268d2b9..48a9496 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/auth/TalentAuthService.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/auth/TalentAuthService.java
@@ -108,17 +108,47 @@
where mobile = ? and deleted = 0 and status = 1
limit 1 for update
""", mobile);
- if (talents.isEmpty()) throw new BusinessException(ErrorCode.FORBIDDEN, "当前手机号未录入人才服务名单,请联系管理员");
+ if (talents.isEmpty()) return issueSession(registerVisitor(openId, mobile));
Map<String, Object> talent = talents.get(0);
long talentId = number(talent.get("id"));
- List<Map<String, Object>> binding = rows("select id from talent_user where openid = ? and deleted = 0 limit 1 for update", openId);
+ List<Map<String, Object>> binding = rows("""
+ select t.id,
+ exists(select 1 from talent_card c where c.talent_id = t.id and c.deleted = 0 and c.card_type = 'PERSONAL') has_talent_card
+ from talent_user t
+ where t.openid = ? and t.deleted = 0
+ limit 1 for update
+ """, openId);
if (!binding.isEmpty() && number(binding.get(0).get("id")) != talentId) {
- throw new BusinessException(ErrorCode.CONFLICT, "当前微信已绑定其他人才账号,请联系管理员");
+ if (number(binding.get(0).get("hasTalentCard")) != 0) {
+ throw new BusinessException(ErrorCode.CONFLICT, "当前微信已绑定其他人才账号,请联系管理员");
+ }
+ jdbc.update("update talent_user set openid = null where id = ?", number(binding.get(0).get("id")));
}
jdbc.update("update talent_user set openid = ? where id = ?", openId, talentId);
return issueSession(talentId);
}
+ private long registerVisitor(String openId, String mobile) {
+ List<Map<String, Object>> bindings = rows("""
+ select id
+ from talent_user
+ where openid = ? and deleted = 0 and status = 1
+ limit 1 for update
+ """, openId);
+ if (!bindings.isEmpty()) {
+ long talentId = number(bindings.get(0).get("id"));
+ jdbc.update("update talent_user set mobile = ? where id = ?", mobile, talentId);
+ return talentId;
+ }
+ jdbc.update("""
+ insert into talent_user(openid, name, mobile, talent_level, source_area_type, status)
+ values (?, '普通游客', ?, '普通游客', 'LOCAL', 1)
+ """, openId, mobile);
+ Long talentId = jdbc.queryForObject("select last_insert_id()", Long.class);
+ if (talentId == null) throw new BusinessException(ErrorCode.INTERNAL_ERROR, "普通游客注册失败");
+ return talentId;
+ }
+
private Map<String, Object> issueSession(long talentId) {
jdbc.update("update talent_session set revoked_at = now() where talent_id = ? and revoked_at is null", talentId);
--
Gitblit v1.7.1