From 6c42f8fb5ef1b7778ddd75a2baa02b5af2afb0c8 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期五, 18 九月 2026 12:56:28 +0800
Subject: [PATCH] docs(scratch): 结算记录查询条件的复现与验证脚本

---
 .scratch/settlement-query-failure/value-merchant-type.txt |    1 +
 .scratch/settlement-query-failure/value-merchant-name.txt |    1 +
 .scratch/settlement-query-failure/verify-filters.sh       |   41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/.scratch/settlement-query-failure/value-merchant-name.txt b/.scratch/settlement-query-failure/value-merchant-name.txt
new file mode 100644
index 0000000..dafda4a
--- /dev/null
+++ b/.scratch/settlement-query-failure/value-merchant-name.txt
@@ -0,0 +1 @@
+存量商户验证专用
diff --git a/.scratch/settlement-query-failure/value-merchant-type.txt b/.scratch/settlement-query-failure/value-merchant-type.txt
new file mode 100644
index 0000000..6256370
--- /dev/null
+++ b/.scratch/settlement-query-failure/value-merchant-type.txt
@@ -0,0 +1 @@
+景区服务
diff --git a/.scratch/settlement-query-failure/verify-filters.sh b/.scratch/settlement-query-failure/verify-filters.sh
new file mode 100644
index 0000000..43ce491
--- /dev/null
+++ b/.scratch/settlement-query-failure/verify-filters.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+# 验证「财务管理 / 结算记录」页的查询条件真的生效:同一接口只改一个条件,返回的商户/条数必须随之变化。
+#
+# 用法:bash verify-filters.sh [base-url]       默认 http://localhost:8080
+# 中文值一律走 `--data-urlencode name@file`:Shell 传中文命令行参数时可能被转成 GBK 字节,
+# 那样通道参数不是合法 UTF-8,Tomcat 会报「Character decoding failed」而返回 500——那是测法的问题,不是接口的问题。
+set -u
+
+BASE="${1:-http://localhost:8080}"
+URL="$BASE/api/admin/management/merchant-settlement/settlements"
+VALUES="$(dirname "$0")"
+BEGIN="${BEGIN:-20260819}"
+END="${END:-20260918}"
+
+TOKEN=$(curl -s -X POST "$BASE/api/admin/auth/login" -H 'Content-Type: application/json' \
+  -d '{"account":"admin","password":"123456"}' | sed -n 's/.*"accessToken":"\([^"]*\)".*/\1/p')
+if [ -z "$TOKEN" ]; then
+  echo "登录失败:后台账号密码可能已改,请改成本地可用的凭据" >&2
+  exit 2
+fi
+
+probe() {
+  local label="$1"
+  shift
+  local body
+  body=$(curl -s -G "$URL" --data "size=50" --data "beginDate=$BEGIN" --data "endDate=$END" "$@" \
+    -H "Authorization: Bearer $TOKEN")
+  printf '%-26s 条数=%-4s 商户=%s\n' "$label" \
+    "$(printf '%s' "$body" | grep -o 'providerTransactionNo' | wc -l | tr -d ' ')" \
+    "$(printf '%s' "$body" | grep -o '"merchantName":"[^"]*"' | sed 's/.*:"//; s/"$//' | sort -u | tr '\n' ' ')"
+}
+
+probe "无条件"
+probe "商家=存量商户验证专用" --data-urlencode "merchantName@$VALUES/value-merchant-name.txt"
+probe "商家类型=景区服务" --data-urlencode "merchantType@$VALUES/value-merchant-type.txt"
+probe "状态=已结算(S)" --data "status=S"
+probe "状态=处理中(P)" --data "status=P"
+
+echo
+echo "期望:商家/商家类型两项的条数与商户都收窄;状态=S 全量、状态=P 为 0(当前没有处理中的流水)。"
+echo "无条件那一行仍是全部——它只是基线。"

--
Gitblit v1.7.1