From eefe7167ee13a2da09f3b1e20ecffee2ca731b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=85=E6=88=BF?= Date: Tue, 6 Jan 2026 16:24:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=A5=E5=90=8D=E6=97=B6=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=98=AF=E5=90=A6=E5=B7=B2=E5=AD=98=E5=9C=A8=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E9=80=89=E6=89=8B=E8=AE=B0=E5=BD=95=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=87=8D=E5=A4=8D=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在提交报名时,先检查是否已存在相同选手+比赛+项目的记录 - 如果存在则更新订单ID,而不是创建新记录 - 解决添加选手后再报名导致重复记录的问题 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .../MartialRegistrationOrderController.java | 59 ++++++++++++------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java b/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java index d6a914e..772b2f6 100644 --- a/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java +++ b/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java @@ -167,27 +167,46 @@ public class MartialRegistrationOrderController extends BladeController { // Create a record for each project for (Long projectId : projectIds) { - MartialAthlete newRecord = new MartialAthlete(); - newRecord.setOrderId(orderId); - newRecord.setCompetitionId(dto.getCompetitionId()); - newRecord.setProjectId(projectId); - newRecord.setPlayerName(existingAthlete.getPlayerName()); - newRecord.setGender(existingAthlete.getGender()); - newRecord.setIdCard(existingAthlete.getIdCard()); - newRecord.setIdCardType(existingAthlete.getIdCardType()); - newRecord.setContactPhone(existingAthlete.getContactPhone()); - newRecord.setOrganization(existingAthlete.getOrganization()); - newRecord.setTeamName(existingAthlete.getTeamName()); - newRecord.setRegistrationStatus(1); - newRecord.setCompetitionStatus(0); - newRecord.setCreateUser(AuthUtil.getUserId()); - newRecord.setCreateTime(new java.util.Date()); - newRecord.setTenantId("000000"); - newRecord.setIsDeleted(0); - newRecord.setStatus(1); + // Check if record already exists for this athlete + competition + project + LambdaQueryWrapper checkWrapper = new LambdaQueryWrapper<>(); + checkWrapper.eq(MartialAthlete::getCompetitionId, dto.getCompetitionId()) + .eq(MartialAthlete::getProjectId, projectId) + .eq(MartialAthlete::getIdCard, existingAthlete.getIdCard()) + .eq(MartialAthlete::getIsDeleted, 0); + MartialAthlete existingRecord = athleteService.getOne(checkWrapper, false); - athleteService.save(newRecord); - log.info("创建选手参赛记录: playerName={}, projectId={}", existingAthlete.getPlayerName(), projectId); + if (existingRecord != null) { + // Update existing record with order info + existingRecord.setOrderId(orderId); + existingRecord.setRegistrationStatus(1); + existingRecord.setUpdateUser(AuthUtil.getUserId()); + existingRecord.setUpdateTime(new java.util.Date()); + athleteService.updateById(existingRecord); + log.info("更新已存在的选手参赛记录: playerName={}, projectId={}", existingAthlete.getPlayerName(), projectId); + } else { + // Create new record + MartialAthlete newRecord = new MartialAthlete(); + newRecord.setOrderId(orderId); + newRecord.setCompetitionId(dto.getCompetitionId()); + newRecord.setProjectId(projectId); + newRecord.setPlayerName(existingAthlete.getPlayerName()); + newRecord.setGender(existingAthlete.getGender()); + newRecord.setIdCard(existingAthlete.getIdCard()); + newRecord.setIdCardType(existingAthlete.getIdCardType()); + newRecord.setContactPhone(existingAthlete.getContactPhone()); + newRecord.setOrganization(existingAthlete.getOrganization()); + newRecord.setTeamName(existingAthlete.getTeamName()); + newRecord.setRegistrationStatus(1); + newRecord.setCompetitionStatus(0); + newRecord.setCreateUser(AuthUtil.getUserId()); + newRecord.setCreateTime(new java.util.Date()); + newRecord.setTenantId("000000"); + newRecord.setIsDeleted(0); + newRecord.setStatus(1); + + athleteService.save(newRecord); + log.info("创建选手参赛记录: playerName={}, projectId={}", existingAthlete.getPlayerName(), projectId); + } } } }