逻辑调整,周五没有推荐内容

This commit is contained in:
Mars 2025-06-27 14:41:28 +08:00
parent 379f295ab0
commit deeee6baf4
2 changed files with 89 additions and 42 deletions

View File

@ -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()
# 确定当前彩票类型(根据推荐数量)

View File

@ -47,14 +47,17 @@
<div class="order-card">
<div class="card-header">
<h3>今日拼盘</h3>
<span class="lottery-type" :class="{ active: currentLotteryType === 'ssq' }">{{ currentLotteryType === 'ssq' ? '双色球' : '大乐透' }}</span>
<span class="lottery-type" :class="{ active: currentLotteryType !== 'rest' }">
{{ currentLotteryType === 'ssq' ? '双色球' : currentLotteryType === 'dlt' ? '大乐透' : '休息日' }}
</span>
</div>
<div class="order-content">
<div class="order-info">
<p class="order-time">下单时间{{ todayRecommend.length ? todayRecommend[0].time : '还没开锅,快来点一份吧~' }}</p>
<p class="order-batch">拼盘编号{{ todayRecommend.length ? todayRecommend[0].batch_id : '暂无,先点单再说~' }}</p>
<p class="order-time" v-if="currentLotteryType === 'rest'">今日休息明天再来</p>
<p class="order-time" v-else>{{ todayRecommend.length ? todayRecommend[0].time : '还没开锅快来点一份吧~' }}</p>
<p class="order-batch" v-if="currentLotteryType !== 'rest'">{{ todayRecommend.length ? todayRecommend[0].batch_id : '暂无先点单再说~' }}</p>
</div>
<div class="order-numbers" v-if="todayRecommend.length">
<div class="order-numbers" v-if="todayRecommend.length && currentLotteryType !== 'rest'">
<div v-for="(order, idx) in todayRecommend" :key="order.id" class="number-display multi">
<span class="order-index">{{ idx + 1 }}</span>
<span class="red-balls">
@ -67,25 +70,30 @@
<span class="recommend-type">{{ order.recommend_type }}</span>
</div>
</div>
<div class="no-order" v-else>
<div class="no-order" v-if="currentLotteryType === 'rest'">
<p>今日休息大厨也要休息一天哦明天再来享受美味拼盘吧~</p>
</div>
<div class="no-order" v-else-if="!todayRecommend.length">
<p>今日拼盘还没出锅快点下方按钮开启你的好运早餐</p>
</div>
</div>
<div class="order-actions">
<button
@click="generateNumbers"
:disabled="loading"
:disabled="loading || currentLotteryType === 'rest'"
class="generate-btn"
>
<span v-if="loading">大厨配号中...</span>
<span v-else-if="currentLotteryType === 'rest'">今日休息</span>
<span v-else>来一份拼盘</span>
</button>
<button
@click="copyAllNumbers"
:disabled="loading"
:disabled="loading || currentLotteryType === 'rest' || !todayRecommend.length"
class="copy-all-btn"
>
<span v-if="loading">打包中...</span>
<span v-else-if="currentLotteryType === 'rest'">休息中</span>
<span v-else>打包带走</span>
</button>
</div>
@ -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() {
// tab1=Monday, 7=Sunday
const weekday = new Date().getDay() || 7
if ([1, 3, 6].includes(weekday)) {
// tab使isoweekday1=Monday, 7=Sunday
//
const day = new Date().getDay() // 0=Sunday, 1=Monday, ..., 6=Saturday
const weekday = day === 0 ? 7 : day // 1-71=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'
}