From 131a28347f2c3ce272f61fce425a6eea4fa5e51c Mon Sep 17 00:00:00 2001
From: shinnosuke <tantao@1hoper.com>
Date: 星期五, 18 九月 2026 15:01:10 +0800
Subject: [PATCH] 更新....

---
 talent-card-server/src/test/java/com/talentcard/server/business/admin/AdminBusinessServiceTests.java |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/talent-card-server/src/test/java/com/talentcard/server/business/admin/AdminBusinessServiceTests.java b/talent-card-server/src/test/java/com/talentcard/server/business/admin/AdminBusinessServiceTests.java
index 3459405..c59ef90 100644
--- a/talent-card-server/src/test/java/com/talentcard/server/business/admin/AdminBusinessServiceTests.java
+++ b/talent-card-server/src/test/java/com/talentcard/server/business/admin/AdminBusinessServiceTests.java
@@ -3,9 +3,16 @@
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import com.talentcard.server.common.BusinessException;
+import java.util.List;
+import org.mockito.ArgumentCaptor;
 import org.junit.jupiter.api.Test;
 import org.springframework.jdbc.core.JdbcTemplate;
 
@@ -56,4 +63,22 @@
 				.contains("bo.refund_status is null or bo.refund_status = 0")
 				.endsWith("as sales_count");
 	}
+
+	@Test
+	void productAuditListOnlyKeepsTheLatestRecordPerProduct() {
+		// 同一个团单修改后再次提交会插入新的审核记录;列表只保留每个团单最新的一条,
+		// 否则同一个团单会出现多行、销量被重复统计。
+		JdbcTemplate jdbc = mock(JdbcTemplate.class);
+		AdminBusinessService adminService = new AdminBusinessService(jdbc);
+		when(jdbc.queryForObject(anyString(), eq(Long.class), any(Object[].class))).thenReturn(1L);
+		when(jdbc.queryForList(anyString(), any(Object[].class))).thenReturn(List.of());
+
+		adminService.products(null, null, null, null, null, null, null, null, 1, 10);
+
+		ArgumentCaptor<String> sql = ArgumentCaptor.forClass(String.class);
+		verify(jdbc).queryForList(sql.capture(), any(Object[].class));
+		assertThat(sql.getValue())
+				.contains("from merchant_product_audit_record r")
+				.contains("select max(newer.id) from merchant_product_audit_record newer");
+	}
 }

--
Gitblit v1.7.1