改为东八区时间。

This commit is contained in:
aaron 2025-02-19 16:02:48 +08:00
parent f504123bae
commit d55e536838
3 changed files with 16 additions and 5 deletions

View File

@ -578,7 +578,7 @@ async def cancel_order(
template_id=settings.DELIVERY_ORDER_CANCELLED_TEMPLATE_ID,
data={
"character_string1": order.orderid,
"time19": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"time19": CommonUtils.get_current_time(),
"thing5": "用户主动取消订单"
}
)
@ -744,7 +744,7 @@ async def deliveryman_cancel_order(
template_id=settings.DELIVERY_ORDER_CANCELLED_TEMPLATE_ID,
data={
"character_string1": order.orderid,
"time19": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"time19": CommonUtils.get_current_time(),
"thing5": order.cancel_reason
}
)
@ -821,7 +821,7 @@ async def complete_order(
data={
"character_string13": order.orderid,
"thing3": deliveryman_user.nickname,
"time5" : datetime.now().strftime("%Y-%m-%d %H:%M:%S")
"time5" : CommonUtils.get_current_time()
},
miniprogram={
"appid": settings.WECHAT_APPID,
@ -883,7 +883,7 @@ async def receive_order(
template_id=settings.DELIVERY_ORDER_RECEIVED_TEMPLATE_ID,
data={
"character_string9": order.orderid,
"time8": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"time8": CommonUtils.get_current_time(),
"thing3": deliveryman_user.nickname
},
miniprogram={

View File

@ -1,9 +1,19 @@
from datetime import datetime
import time
from typing import Optional
import pytz # 需要先安装: pip install pytz
class CommonUtils:
"""工具类"""
@staticmethod
def get_current_time(timezone='Asia/Shanghai'):
"""
获取指定时区的当前时间
:param timezone: 时区名称默认为上海时区东八区
"""
tz = pytz.timezone(timezone)
return datetime.now(tz).strftime('%Y-%m-%d %H:%M:%S')
@staticmethod
def generate_order_id(prefix: str) -> str:

View File

@ -15,4 +15,5 @@ bcrypt
aiohttp==3.9.1
cryptography==42.0.2
qrcode>=7.3.1
pillow>=9.0.0
pillow>=9.0.0
pytz==2024.1