deliveryman-api/app/core/mpmessage.py
2025-03-23 10:10:37 +08:00

37 lines
1.2 KiB
Python

from app.core.config import settings
from app.core.mpclient import mp_client
from app.core.config import settings
import logging
# 发送订单状态改变消息
async def sent_order_status_change_message(openid: str, orderid: str, template_id: str, data: dict):
try:
await mp_client.send_template_message(
openid=openid,
template_id=template_id,
data=data,
miniprogram={
"appid": settings.WECHAT_APPID,
"pagepath": f"/pages/order/detail/index?id={orderid}"
}
)
except Exception as e:
logging.exception(f"发送模板消息失败: {str(e)}")
# 发送商家订单状态改变消息
async def sent_merchant_order_status_change_message(openid: str, orderid: str, template_id: str, data: dict):
try:
await mp_client.send_template_message(
openid=openid,
template_id=template_id,
data=data,
miniprogram={
"appid": settings.WECHAT_APPID,
"pagepath": f"/pages/merchant_order/detail/index?id={orderid}"
}
)
except Exception as e:
logging.exception(f"发送模板消息失败: {str(e)}")