Fix payout calculation in reports daily summary

- Changed payout calculation from ExtractionStatsModel.total_redistributed to sum of winning bet win_amount
- Now correctly calculates payout by summing win_amount for all winning bet details in the selected timeframe
- Uses is_bet_detail_winning() function to determine winning bets
- Fixes issue where payout showed 0 instead of actual winning amounts
parent b21f3919
...@@ -5974,14 +5974,26 @@ def get_daily_reports_summary(): ...@@ -5974,14 +5974,26 @@ def get_daily_reports_summary():
total_payin += bet_total total_payin += bet_total
total_bets += len(bet_details) total_bets += len(bet_details)
# Calculate total payout from extraction stats for the day # Calculate total payout from winning bets for the day
extraction_stats = session.query(ExtractionStatsModel).filter( # Get all bet details for the target date (excluding cancelled bets)
ExtractionStatsModel.match_datetime >= start_datetime, bet_details_query = session.query(BetDetailModel).join(BetModel).filter(
ExtractionStatsModel.match_datetime <= end_datetime BetModel.bet_datetime >= start_datetime,
).all() BetModel.bet_datetime <= end_datetime,
BetDetailModel.result != 'cancelled'
)
total_payout = sum(float(stat.total_redistributed) for stat in extraction_stats) bet_details = bet_details_query.all()
total_matches = len(extraction_stats)
# Sum win_amount for all winning bet details
total_payout = 0.0
for detail in bet_details:
match = session.query(MatchModel).filter_by(id=detail.match_id).first()
if is_bet_detail_winning(detail, match, session):
total_payout += float(detail.win_amount or 0)
# Get unique matches count
unique_match_ids = set(detail.match_id for detail in bet_details)
total_matches = len(unique_match_ids)
summary = { summary = {
'date': target_date.isoformat(), 'date': target_date.isoformat(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment