修复周六投注周日中奖检查问题

This commit is contained in:
Mars 2025-07-14 15:07:59 +08:00
parent 809802e655
commit 82a34ff1ab

View File

@ -216,31 +216,44 @@ class LotteryScheduler:
yesterday = datetime.now() - timedelta(days=1)
target_date = yesterday.strftime('%Y-%m-%d')
current_weekday = datetime.now().isoweekday()
if current_weekday == 6: # 周六
logger.info("周六休息,不推送中奖检查")
return
if current_weekday in [1, 3, 5, 7]:
lottery_type = 'ssq'
BetModel = SSQLotteryBetRecord
LotteryModel = SSQLottery
fixed_numbers = {'red': [4, 6, 7, 12, 18, 19], 'blue': [9]}
else:
# 移除错误的周六休息逻辑 - 周六投注的大乐透在周日需要检查中奖
# 根据昨天的日期确定彩票类型
yesterday_weekday = yesterday.isoweekday()
if yesterday_weekday in [1, 3, 6]: # 昨天是周一、三、六,投注的是大乐透
lottery_type = 'dlt'
BetModel = DLTLotteryBetRecord
LotteryModel = DLTLottery
fixed_numbers = {'red': [4, 6, 9, 18, 19], 'blue': [7, 12]}
elif yesterday_weekday in [2, 4, 7]: # 昨天是周二、四、日,投注的是双色球
lottery_type = 'ssq'
BetModel = SSQLotteryBetRecord
LotteryModel = SSQLottery
fixed_numbers = {'red': [4, 6, 7, 12, 18, 19], 'blue': [9]}
else: # 昨天是周五,休息日,没有投注
logger.info("昨日是周五休息日,没有投注记录,跳过中奖检查")
return
db = SessionLocal()
try:
target_batch_id_pattern = f"{yesterday.strftime('%Y%m%d')}%"
bet_records = db.query(BetModel).filter(
BetModel.batch_id.like(target_batch_id_pattern)
).all()
# 先执行中奖检查更新
self.updater.check_and_update_bet_wins(lottery_type, db)
# 重新查询更新后的记录
updated_records = db.query(BetModel).filter(
BetModel.batch_id.like(target_batch_id_pattern)
).all()
# 查询昨天的开奖数据
last_draw = db.query(LotteryModel).filter(
LotteryModel.open_time == yesterday.date()).first()
open_code_str = ""
if last_draw:
if lottery_type == 'ssq':
@ -258,6 +271,7 @@ class LotteryScheduler:
red_str = ' '.join(f"{n:02d}" for n in open_red)
blue_str = ' '.join(f"{n:02d}" for n in open_blue)
open_code_str = f"{red_str} | {blue_str}"
# 固定号码开奖比对
fixed_result = None
if last_draw: