Skip to content

Commit

Permalink
🚑 修复道具购买限制检查 (#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier authored Dec 24, 2024
1 parent 108cdd4 commit ebf05fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zhenxun/builtin_plugins/shop/_data_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
from collections.abc import Callable
from datetime import datetime, timedelta
import inspect
import time
from types import MappingProxyType
Expand Down Expand Up @@ -413,8 +414,15 @@ async def buy_prop(
price = goods.goods_price * num * goods.goods_discount
if user.gold < price:
return "糟糕! 您的金币好像不太够哦..."
today = datetime.now()
create_time = today - timedelta(
hours=today.hour, minutes=today.minute, seconds=today.second
)
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()
if goods.daily_limit and count >= goods.daily_limit:
return "今天的购买已达限制了喔!"
Expand Down

0 comments on commit ebf05fd

Please sign in to comment.