test_tianwang_api.py
2.51 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import sys
from datetime import datetime
# 测试接口
import subprocess
# 测试2025年1月的数据
cmd1 = [
'curl', '-s', '-X', 'POST',
'http://localhost:2011/api/Extend/LqDailyReport/get-tianwang-group-performance-completion',
'-H', 'Content-Type: application/json',
'-d', '{"startTime": "2025-01-01", "endTime": "2025-01-31"}'
]
result1 = subprocess.run(cmd1, capture_output=True, text=True)
data1 = json.loads(result1.stdout)
print("=" * 60)
print("2025年1月数据")
print("=" * 60)
print(f"接口状态: {data1.get('code')}")
print(f"返回消息: {data1.get('msg')}")
depts1 = [d for d in data1.get('data', []) if '教育' in d.get('DepartmentName', '')]
print("\n=== 教育部数据 ===")
for d in depts1:
print(f"{d.get('DepartmentName')}:")
print(f" BillingPerformance: {d.get('BillingPerformance')}")
print(f" RefundPerformance: {d.get('RefundPerformance')}")
print(f" DeductAmount: {d.get('DeductAmount')}")
print(f" CompletedPerformance: {d.get('CompletedPerformance')}")
print(f" StoreCount: {d.get('StoreCount')}")
total1 = sum([d.get('BillingPerformance', 0) for d in depts1])
print(f"\n教育一部+教育二部合计 BillingPerformance: {total1}")
# 测试当前月份的数据
current_month = datetime.now().strftime("%Y-%m")
start_date = f"{current_month}-01"
end_date = datetime.now().strftime("%Y-%m-%d")
cmd2 = [
'curl', '-s', '-X', 'POST',
'http://localhost:2011/api/Extend/LqDailyReport/get-tianwang-group-performance-completion',
'-H', 'Content-Type: application/json',
'-d', f'{{"startTime": "{start_date}", "endTime": "{end_date}"}}'
]
result2 = subprocess.run(cmd2, capture_output=True, text=True)
data2 = json.loads(result2.stdout)
print("\n" + "=" * 60)
print(f"当前月份 ({current_month}) 数据")
print("=" * 60)
print(f"接口状态: {data2.get('code')}")
depts2 = [d for d in data2.get('data', []) if '教育' in d.get('DepartmentName', '')]
print("\n=== 教育部数据 ===")
for d in depts2:
print(f"{d.get('DepartmentName')}:")
print(f" BillingPerformance: {d.get('BillingPerformance')}")
print(f" RefundPerformance: {d.get('RefundPerformance')}")
print(f" DeductAmount: {d.get('DeductAmount')}")
print(f" CompletedPerformance: {d.get('CompletedPerformance')}")
print(f" StoreCount: {d.get('StoreCount')}")
total2 = sum([d.get('BillingPerformance', 0) for d in depts2])
print(f"\n教育一部+教育二部合计 BillingPerformance: {total2}")