# Add Cost Analysis to Lottery Simulation

I will enhance the lottery simulation feature to include cost calculation and financial analysis.

## 1. Backend Changes (`internal/api/admin/lottery_admin.go`)

- **Update Response Structures**:
  - Add `Cost` (int64) to `simulateRewardStat` (Unit cost in cents).
  - Add `TotalCost` (int64) to `simulateRewardStat` (WonCount * Cost).
  - Add `TotalSimulationCost` (int64) to `simulateIssueResponse`.
  - Add `TotalSimulationRevenue` (int64) to `simulateIssueResponse` (TotalDraws * Activity.PriceDraw).
  - Add `GrossProfit` (int64) to `simulateIssueResponse` (Revenue - Cost).
  - Add `GrossProfitRate` (float64) to `simulateIssueResponse`.

- **Logic Update**:
  - In `SimulateIssue`:
    - Fetch the `Activity` details to get `PriceDraw`.
    - Collect all `ProductID`s from the rewards.
    - Batch query the `Products` table to get prices.
    - Map product prices to rewards (if `ProductID > 0`).
    - Calculate financial stats after the simulation loop.

## 2. Frontend Changes (`web/admin/src/views/operations/lottery-simulation/index.vue`)

- **Update API Type Definition**: Update `SimulateRewardStat` and `SimulateIssueResponse` interfaces in `api/operations.ts`.
- **UI Enhancement**:
  - **Summary Cards**: Add a row of summary cards at the top of the results section showing:
    - Total Revenue (总收入)
    - Total Cost (总成本)
    - Gross Profit (毛利润)
    - Profit Margin (毛利率)
  - **Table Columns**:
    - Add "Unit Cost" (单价/成本) column.
    - Add "Total Cost" (总发放成本) column.

## 3. Verification
- Verify compilation.
- (Self-Correction) Ensure `Price` is handled as integer (cents) and formatted correctly in frontend (divided by 100).
