test_goddess_card_members.sh
4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# 测试女神卡列表接口(带门店筛选)
echo "=========================================="
echo "测试女神卡列表接口"
echo "=========================================="
# 获取token
echo "1. 获取登录token..."
TOKEN=$(curl -s -X POST "http://localhost:2011/api/oauth/Login" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "account=admin&password=e10adc3949ba59abbe56e057f20f883e" | \
python3 -c "import sys, json; print(json.load(sys.stdin)['data']['token'])" 2>/dev/null)
if [ -z "$TOKEN" ]; then
echo "❌ 获取token失败"
exit 1
fi
echo "✅ Token获取成功"
echo ""
# 测试1: 不带门店筛选
echo "2. 测试1: 不带门店筛选..."
RESPONSE1=$(curl -s -X POST "http://localhost:2011/api/Extend/lqstatistics/GetGoddessCardMembers" \
-H "Authorization: $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"PageIndex": 1,
"PageSize": 5
}')
echo "$RESPONSE1" | python3 -c "
import sys, json
try:
data = json.load(sys.stdin)
if data.get('code') == 200:
total = data.get('data', {}).get('pagination', {}).get('total', 0)
count = len(data.get('data', {}).get('list', []))
print(f'✅ 成功 - 总记录数: {total}, 当前页记录数: {count}')
else:
print(f'❌ 失败 - Code: {data.get(\"code\")}, Msg: {data.get(\"msg\")}')
except Exception as e:
print(f'❌ 解析失败: {e}')
print(sys.stdin.read())
" 2>/dev/null || echo "$RESPONSE1" | head -10
echo ""
# 获取一个门店ID用于测试
echo "3. 获取门店ID..."
STORE_ID=$(curl -s -X GET "http://localhost:2011/api/Extend/lqmdxx?currentPage=1&pageSize=1" \
-H "Authorization: $TOKEN" | \
python3 -c "import sys, json; data = json.load(sys.stdin); print(data.get('data', {}).get('list', [{}])[0].get('id', ''))" 2>/dev/null)
if [ -z "$STORE_ID" ]; then
echo "❌ 获取门店ID失败"
exit 1
fi
echo "✅ 门店ID: $STORE_ID"
echo ""
# 测试2: 带单个门店筛选
echo "4. 测试2: 带单个门店筛选 (StoreId)..."
RESPONSE2=$(curl -s -X POST "http://localhost:2011/api/Extend/lqstatistics/GetGoddessCardMembers" \
-H "Authorization: $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"PageIndex\": 1,
\"PageSize\": 5,
\"StoreId\": \"$STORE_ID\"
}")
echo "$RESPONSE2" | python3 -c "
import sys, json
try:
data = json.load(sys.stdin)
if data.get('code') == 200:
total = data.get('data', {}).get('pagination', {}).get('total', 0)
count = len(data.get('data', {}).get('list', []))
stores = set([m.get('storeName', '') for m in data.get('data', {}).get('list', [])])
print(f'✅ 成功 - 总记录数: {total}, 当前页记录数: {count}')
if stores:
print(f' 门店列表: {stores}')
else:
print(f'❌ 失败 - Code: {data.get(\"code\")}, Msg: {data.get(\"msg\")}')
except Exception as e:
print(f'❌ 解析失败: {e}')
print(sys.stdin.read())
" 2>/dev/null || echo "$RESPONSE2" | head -10
echo ""
# 测试3: 带多个门店筛选
echo "5. 测试3: 带多个门店筛选 (StoreIds)..."
STORE_ID2=$(curl -s -X GET "http://localhost:2011/api/Extend/lqmdxx?currentPage=1&pageSize=2" \
-H "Authorization: $TOKEN" | \
python3 -c "import sys, json; data = json.load(sys.stdin); stores = data.get('data', {}).get('list', []); print(stores[1].get('id', '') if len(stores) > 1 else '')" 2>/dev/null)
if [ -n "$STORE_ID2" ]; then
RESPONSE3=$(curl -s -X POST "http://localhost:2011/api/Extend/lqstatistics/GetGoddessCardMembers" \
-H "Authorization: $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"PageIndex\": 1,
\"PageSize\": 5,
\"StoreIds\": [\"$STORE_ID\", \"$STORE_ID2\"]
}")
echo "$RESPONSE3" | python3 -c "
import sys, json
try:
data = json.load(sys.stdin)
if data.get('code') == 200:
total = data.get('data', {}).get('pagination', {}).get('total', 0)
count = len(data.get('data', {}).get('list', []))
stores = set([m.get('storeName', '') for m in data.get('data', {}).get('list', [])])
print(f'✅ 成功 - 总记录数: {total}, 当前页记录数: {count}')
if stores:
print(f' 门店列表: {stores}')
else:
print(f'❌ 失败 - Code: {data.get(\"code\")}, Msg: {data.get(\"msg\")}')
except Exception as e:
print(f'❌ 解析失败: {e}')
print(sys.stdin.read())
" 2>/dev/null || echo "$RESPONSE3" | head -10
else
echo "⚠️ 只有一个门店,跳过多门店筛选测试"
fi
echo ""
echo "=========================================="
echo "测试完成"
echo "=========================================="