🚑 修复道具购买限制检查

This commit is contained in:
HibiKier 2024-12-24 06:06:09 +08:00
parent 012a23008b
commit f8015689bb

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 "今天的购买已达限制了喔!"