#!/bin/bash

# 检查订单状态脚本

BASE_URL="http://localhost:5010"

# 管理员登录
echo "管理员登录..."
LOGIN_RESPONSE=$(curl -s -X POST "$BASE_URL/admin/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123"}')

TOKEN=$(echo "$LOGIN_RESPONSE" | jq -r '.data.token')

# 查询订单详情
echo ""
echo "查询订单 F20260324013123000002 详情..."
ORDER1=$(curl -s -X GET "$BASE_URL/admin/order/list?pageNum=1&pageSize=20&type=1&status=2" \
  -H "Authorization: Bearer $TOKEN")

echo "$ORDER1" | jq '.data.list[] | select(.orderNo == "F20260324013123000002") | {orderNo, status, approveTime, confirmTime}'

echo ""
echo "查询订单 F202603240004937000000 详情..."
echo "$ORDER1" | jq '.data.list[] | select(.orderNo == "F202603240004937000000") | {orderNo, status, approveTime, confirmTime}'

echo ""
echo "查询用户 5 的账户余额..."
USER_DETAIL=$(curl -s -X GET "$BASE_URL/admin/user/detail?userId=5" \
  -H "Authorization: Bearer $TOKEN")

echo "$USER_DETAIL" | jq '.data.fund | {balance, frozen, totalDeposit, totalWithdraw}'
