From deeee6baf469939eee0236affbb4dd9c6f4e411b Mon Sep 17 00:00:00 2001 From: Mars Date: Fri, 27 Jun 2025 14:41:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E5=91=A8=E4=BA=94=E6=B2=A1=E6=9C=89=E6=8E=A8=E8=8D=90=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/endpoints/prediction.py | 42 +++++++++--- frontend/src/views/NumberGenerator.vue | 89 ++++++++++++++++--------- 2 files changed, 89 insertions(+), 42 deletions(-) diff --git a/backend/app/api/endpoints/prediction.py b/backend/app/api/endpoints/prediction.py index b405c56..1c77df9 100644 --- a/backend/app/api/endpoints/prediction.py +++ b/backend/app/api/endpoints/prediction.py @@ -72,14 +72,25 @@ def get_ensemble_prediction( @router.post("/recommend/today") def recommend_today(db: Session = Depends(get_db)): """ - 每日推荐:一三六推荐大乐透,二四日推荐双色球,固定投注1注+推荐4注,共5注,推送内容合并快乐8。 + 每日推荐:一三六推荐大乐透,二四日推荐双色球,周五休息一天。 """ + # 判断彩种 + weekday = datetime.datetime.now().isoweekday() + + # 周五休息一天 + if weekday == 5: # 周五 + return { + 'success': True, + 'lottery_type': 'rest', + 'message': '今日休息,明天再来!', + 'recommend': [] + } + # 固定投注号码(写死) FIXED_SSQ = {'red': [4, 6, 7, 12, 18, 19], 'blue': [9]} FIXED_DLT = {'red': [4, 6, 9, 18, 19], 'blue': [7, 12]} - # 判断彩种 - weekday = datetime.datetime.now().isoweekday() - if weekday in [1, 3, 6]: + + if weekday in [1, 3, 6]: # 周一、三、六 lottery_type = 'dlt' BetModel = DLTLotteryBetRecord recommend_type = '集成预测-每日推荐' @@ -90,7 +101,7 @@ def recommend_today(db: Session = Depends(get_db)): fixed = FIXED_DLT title = "你好,帮忙买下大乐透。" dlt_append = True - else: + else: # 周二、四、日 lottery_type = 'ssq' BetModel = SSQLotteryBetRecord recommend_type = '集成预测-每日推荐' @@ -186,10 +197,12 @@ def recommend_today(db: Session = Depends(get_db)): # 2. 组装推送内容(固定投注+4注推荐) msg_lines = [title] # 固定投注 - msg_lines.append(f"红球:{' '.join(f'{n:02d}' for n in fixed['red'])} 蓝球:{' '.join(f'{n:02d}' for n in fixed['blue'])}") + msg_lines.append(f"红球:{' '.join(f'{n:02d}' for n in fixed['red'])} 蓝球:{ + ' '.join(f'{n:02d}' for n in fixed['blue'])}") # 推荐号码 for rec in results: - msg_lines.append(f"红球:{' '.join(f'{n:02d}' for n in rec['red'])} 蓝球:{' '.join(f'{n:02d}' for n in rec['blue'])}") + msg_lines.append(f"红球:{' '.join(f'{n:02d}' for n in rec['red'])} 蓝球:{ + ' '.join(f'{n:02d}' for n in rec['blue'])}") if dlt_append: msg_lines.append("都追加,谢谢。") # 3. 快乐8推送(3注十选,合并到主消息) @@ -217,15 +230,26 @@ def get_today_recommendations(db: Session = Depends(get_db)): """获取今日拼盘推荐""" try: today = datetime.datetime.now().strftime('%Y%m%d') + weekday = datetime.datetime.now().isoweekday() + + # 周五休息一天 + if weekday == 5: + return { + 'success': True, + 'lottery_type': 'rest', + 'message': '今日休息,明天再来!', + 'recommend': [], + 'count': 0 + } # 查询今日的双色球推荐 ssq_recommendations = db.query(SSQLotteryBetRecord).filter( - SSQLotteryBetRecord.batch_id.like(f'SSQ_{today}%') + SSQLotteryBetRecord.batch_id.like(f'{today}%') ).order_by(SSQLotteryBetRecord.created_at.desc()).all() # 查询今日的大乐透推荐 dlt_recommendations = db.query(DLTLotteryBetRecord).filter( - DLTLotteryBetRecord.batch_id.like(f'DLT_{today}%') + DLTLotteryBetRecord.batch_id.like(f'{today}%') ).order_by(DLTLotteryBetRecord.created_at.desc()).all() # 确定当前彩票类型(根据推荐数量) diff --git a/frontend/src/views/NumberGenerator.vue b/frontend/src/views/NumberGenerator.vue index 5417af4..fd76afd 100644 --- a/frontend/src/views/NumberGenerator.vue +++ b/frontend/src/views/NumberGenerator.vue @@ -47,14 +47,17 @@

今日拼盘

- {{ currentLotteryType === 'ssq' ? '双色球' : '大乐透' }} + + {{ currentLotteryType === 'ssq' ? '双色球' : currentLotteryType === 'dlt' ? '大乐透' : '休息日' }} +
-

下单时间:{{ todayRecommend.length ? todayRecommend[0].time : '还没开锅,快来点一份吧~' }}

-

拼盘编号:{{ todayRecommend.length ? todayRecommend[0].batch_id : '暂无,先点单再说~' }}

+

今日休息,明天再来!

+

{{ todayRecommend.length ? todayRecommend[0].time : '还没开锅,快来点一份吧~' }}

+

{{ todayRecommend.length ? todayRecommend[0].batch_id : '暂无,先点单再说~' }}

-
+
{{ idx + 1 }} @@ -67,25 +70,30 @@ {{ order.recommend_type }}
-
+
+

今日休息,大厨也要休息一天哦!明天再来享受美味拼盘吧~

+
+

今日拼盘还没出锅,快点下方按钮,开启你的好运早餐!

@@ -238,15 +246,19 @@ export default { const response = await getTodayRecommendations() if (response.data && response.data.success) { this.currentLotteryType = response.data.lottery_type - this.todayRecommend = response.data.recommend.map(item => { - const { redNumbers, blueNumbers } = this.parseNumbers(item.numbers) - return { - ...item, - redNumbers, - blueNumbers, - time: new Date(item.created_at).toLocaleString() - } - }) + if (response.data.lottery_type === 'rest') { + this.todayRecommend = [] + } else { + this.todayRecommend = response.data.recommend.map(item => { + const { redNumbers, blueNumbers } = this.parseNumbers(item.numbers) + return { + ...item, + redNumbers, + blueNumbers, + time: new Date(item.created_at).toLocaleString() + } + }) + } } } catch (error) { console.error('加载今日推荐失败:', error) @@ -258,19 +270,24 @@ export default { const response = await recommendToday() if (response.data.success) { this.currentLotteryType = response.data.lottery_type - // 解析多注推荐 - this.todayRecommend = (response.data.recommend || []).map(item => { - const { redNumbers, blueNumbers } = this.parseNumbers(item.numbers) - return { - ...item, - redNumbers, - blueNumbers, - time: new Date().toLocaleString() - } - }) - // 刷新历史记录 - this.loadHistory() - this.$message.success('拼盘出锅成功,祝你好运连连!') + if (response.data.lottery_type === 'rest') { + this.todayRecommend = [] + this.$message.info('今日休息,明天再来!') + } else { + // 解析多注推荐 + this.todayRecommend = (response.data.recommend || []).map(item => { + const { redNumbers, blueNumbers } = this.parseNumbers(item.numbers) + return { + ...item, + redNumbers, + blueNumbers, + time: new Date().toLocaleString() + } + }) + // 刷新历史记录 + this.loadHistory() + this.$message.success('拼盘出锅成功,祝你好运连连!') + } } } catch (error) { console.error('生成号码失败:', error) @@ -310,12 +327,18 @@ export default { } }, setActiveTabByDay() { - // 自动根据今天是周几切换tab,1=Monday, 7=Sunday - const weekday = new Date().getDay() || 7 - if ([1, 3, 6].includes(weekday)) { + // 自动根据今天是周几切换tab,使用isoweekday逻辑:1=Monday, 7=Sunday + // 一三六推荐大乐透,二四日推荐双色球,周五休息 + const day = new Date().getDay() // 0=Sunday, 1=Monday, ..., 6=Saturday + const weekday = day === 0 ? 7 : day // 转换为1-7格式:1=Monday, 7=Sunday + + if (weekday === 5) { // 周五休息 + this.activeTab = 'rest' + this.currentLotteryType = 'rest' + } else if ([1, 3, 6].includes(weekday)) { // 周一、三、六 this.activeTab = 'dlt' this.currentLotteryType = 'dlt' - } else { + } else { // 周二、四、日 this.activeTab = 'ssq' this.currentLotteryType = 'ssq' }