🚑 修复道具购买限制检查 (#1796)

This commit is contained in:
HibiKier 2024-12-24 11:26:52 +08:00 committed by GitHub
parent 108cdd45b1
commit ebf05fd884
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
import asyncio import asyncio
from collections.abc import Callable from collections.abc import Callable
from datetime import datetime, timedelta
import inspect import inspect
import time import time
from types import MappingProxyType from types import MappingProxyType
@ -413,8 +414,15 @@ class ShopManage:
price = goods.goods_price * num * goods.goods_discount price = goods.goods_price * num * goods.goods_discount
if user.gold < price: if user.gold < price:
return "糟糕! 您的金币好像不太够哦..." return "糟糕! 您的金币好像不太够哦..."
today = datetime.now()
create_time = today - timedelta(
hours=today.hour, minutes=today.minute, seconds=today.second
)
count = await UserPropsLog.filter( count = await UserPropsLog.filter(
user_id=user_id, handle=PropHandle.BUY user_id=user_id,
handle=PropHandle.BUY,
uuid=goods.uuid,
create_time__gte=create_time,
).count() ).count()
if goods.daily_limit and count >= goods.daily_limit: if goods.daily_limit and count >= goods.daily_limit:
return "今天的购买已达限制了喔!" return "今天的购买已达限制了喔!"