Blame view

scripts/sh/verify_store_total_performance_data.sh 3.65 KB
1fffa876   “wangming”   优化储扣列表接口:增加门店、时间、...
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
  #!/bin/bash
  
  # 验证门店总业绩统计数据准确性
  
  echo "=== 验证门店总业绩统计数据准确性 ==="
  
  # 获取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 ""
  
  # 查询实时数据
  echo "--- 查询实时数据(2025年12月,前5条) ---"
  RESPONSE=$(curl -s -X POST "http://localhost:2011/api/Extend/LqStatistics/get-store-total-performance-statistics-list" \
    -H "Authorization: $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"statisticsMonth": "202512", "pageIndex": 1, "pageSize": 5}')
  
  echo "$RESPONSE" | python3 -c "
  import sys, json
  data = json.load(sys.stdin)
  items = data.get('data', {}).get('list', [])[:5]
  print('实时查询结果(前5条):')
  print('=' * 100)
  for i, item in enumerate(items, 1):
      print(f'{i}. {item.get(\"StoreName\", \"无\")}')
      print(f'   总业绩: {item.get(\"TotalPerformance\", 0):,.2f}')
      print(f'   总单业绩: {item.get(\"TotalOrderPerformance\", 0):,.2f}')
      print(f'   实际业绩: {item.get(\"ActualPerformance\", 0):,.2f}')
      print(f'   首开单: {item.get(\"FirstOrderCount\", 0)}, 升单: {item.get(\"UpgradeOrderCount\", 0)}')
      print(f'   品项数量: {item.get(\"ItemQuantity\", 0)}')
      print(f'   退款金额: {item.get(\"RefundAmount\", 0):,.2f}, 退款次数: {item.get(\"RefundCount\", 0)}')
      print('')
  " 2>/dev/null
  
  # 验证数据完整性
  echo "--- 数据完整性验证 ---"
  TOTAL=$(echo "$RESPONSE" | python3 -c "import sys, json; data=json.load(sys.stdin); print(data.get('data', {}).get('pagination', {}).get('total', 0))" 2>/dev/null)
  LIST_COUNT=$(echo "$RESPONSE" | python3 -c "import sys, json; data=json.load(sys.stdin); print(len(data.get('data', {}).get('list', [])))" 2>/dev/null)
  
  echo "总记录数: $TOTAL"
  echo "当前页记录数: $LIST_COUNT"
  
  # 检查数据字段完整性
  echo ""
  echo "--- 字段完整性检查 ---"
  echo "$RESPONSE" | python3 -c "
  import sys, json
  data = json.load(sys.stdin)
  items = data.get('data', {}).get('list', [])
  if items:
      first_item = items[0]
      required_fields = ['StoreId', 'StoreName', 'StatisticsMonth', 'TotalPerformance', 
                        'TotalOrderPerformance', 'ActualPerformance', 'FirstOrderCount', 
                        'UpgradeOrderCount', 'ItemQuantity', 'RefundAmount', 'RefundCount']
      missing_fields = []
      for field in required_fields:
          if field not in first_item:
              missing_fields.append(field)
      if missing_fields:
          print(f'❌ 缺少字段: {missing_fields}')
      else:
          print('✅ 所有必需字段都存在')
          
      # 验证数据逻辑
      print('')
      print('--- 数据逻辑验证 ---')
      for i, item in enumerate(items[:3], 1):
          total_perf = item.get('TotalPerformance', 0)
          total_order = item.get('TotalOrderPerformance', 0)
          actual = item.get('ActualPerformance', 0)
          refund = item.get('RefundAmount', 0)
          
          # 验证:实际业绩 = 总单业绩 - 退款金额
          expected_actual = total_order - refund
          if abs(actual - expected_actual) < 0.01:
              print(f'{i}. {item.get(\"StoreName\", \"无\")}: ✅ 实际业绩计算正确')
          else:
              print(f'{i}. {item.get(\"StoreName\", \"无\")}: ❌ 实际业绩计算错误 (期望: {expected_actual:.2f}, 实际: {actual:.2f})')
  else:
      print('❌ 未找到数据')
  " 2>/dev/null
  
  echo ""
  echo "=== 验证完成 ==="