#!/bin/bash
# 查询订单抽奖记录

mysql -h 150.158.78.154 -P 3306 -u root -p'bindbox2025kdy' bindbox_game -e "
SELECT 
    o.id as order_id,
    o.order_no,
    o.user_id,
    o.activity_id,
    o.issue_id,
    dl.id as draw_log_id,
    dl.reward_id,
    dl.created_at as draw_time,
    ar.product_id,
    ar.weight,
    p.name as reward_name
FROM orders o 
LEFT JOIN activity_draw_logs dl ON dl.order_id = o.id 
LEFT JOIN activity_rewards ar ON ar.id = dl.reward_id 
LEFT JOIN products p ON p.id = ar.product_id 
WHERE o.order_no = 'O20260115145414801';
"

echo ""
echo "=== 查询抽奖凭证 ==="
mysql -h 150.158.78.154 -P 3306 -u root -p'bindbox2025kdy' bindbox_game -e "
SELECT 
    dr.id,
    dr.draw_log_id,
    dr.algo_version,
    dr.server_seed_hash,
    dr.server_sub_seed,
    dr.rand_salt,
    dr.weights_snapshot,
    dr.created_at
FROM activity_draw_receipts dr
JOIN activity_draw_logs dl ON dl.id = dr.draw_log_id
JOIN orders o ON o.id = dl.order_id
WHERE o.order_no = 'O20260115145414801';
"
