update
This commit is contained in:
parent
feb59bb540
commit
a12ed5d934
@ -415,10 +415,11 @@ async def create_order(
|
|||||||
|
|
||||||
# 发送企业微信消息
|
# 发送企业微信消息
|
||||||
wecom_bot = WecomBot()
|
wecom_bot = WecomBot()
|
||||||
|
order_info = OrderInfo.model_validate(db_order)
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
wecom_bot.send_order_notification,
|
wecom_bot.send_order_notification,
|
||||||
db,
|
db,
|
||||||
db_order,
|
order_info,
|
||||||
OrderStatus.CREATED
|
OrderStatus.CREATED
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -916,10 +917,11 @@ async def cancel_order(
|
|||||||
|
|
||||||
# 发送企业微信消息
|
# 发送企业微信消息
|
||||||
wecom_bot = WecomBot()
|
wecom_bot = WecomBot()
|
||||||
|
order_info = OrderInfo.model_validate(order)
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
wecom_bot.send_order_notification,
|
wecom_bot.send_order_notification,
|
||||||
db,
|
db,
|
||||||
order,
|
order_info,
|
||||||
OrderStatus.CANCELLED
|
OrderStatus.CANCELLED
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1169,11 +1171,11 @@ async def deliveryman_cancel_order(
|
|||||||
|
|
||||||
# 发送企业微信消息
|
# 发送企业微信消息
|
||||||
wecom_bot = WecomBot()
|
wecom_bot = WecomBot()
|
||||||
|
order_info = OrderInfo.model_validate(order)
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
wecom_bot.send_order_notification,
|
wecom_bot.send_order_notification,
|
||||||
db,
|
db,
|
||||||
order,
|
order_info,
|
||||||
OrderStatus.CANCELLED
|
OrderStatus.CANCELLED
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1278,10 +1280,11 @@ async def deliveryman_complete_order(
|
|||||||
|
|
||||||
# 发送企业微信消息
|
# 发送企业微信消息
|
||||||
wecom_bot = WecomBot()
|
wecom_bot = WecomBot()
|
||||||
|
order_info = OrderInfo.model_validate(order)
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
wecom_bot.send_order_notification,
|
wecom_bot.send_order_notification,
|
||||||
db,
|
db,
|
||||||
order,
|
order_info,
|
||||||
OrderStatus.COMPLETED
|
OrderStatus.COMPLETED
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1370,11 +1373,11 @@ async def deliveryman_receive_order(
|
|||||||
|
|
||||||
# 发送企业微信消息
|
# 发送企业微信消息
|
||||||
wecom_bot = WecomBot()
|
wecom_bot = WecomBot()
|
||||||
|
order_info = OrderInfo.model_validate(order)
|
||||||
background_tasks.add_task(
|
background_tasks.add_task(
|
||||||
wecom_bot.send_order_notification,
|
wecom_bot.send_order_notification,
|
||||||
db,
|
db,
|
||||||
order,
|
order_info,
|
||||||
OrderStatus.RECEIVED
|
OrderStatus.RECEIVED
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -108,6 +108,32 @@ class QCloudManager:
|
|||||||
except TencentCloudSDKException as e:
|
except TencentCloudSDKException as e:
|
||||||
raise Exception(f"发送短信失败: {str(e)}")
|
raise Exception(f"发送短信失败: {str(e)}")
|
||||||
|
|
||||||
|
async def send_sms_order_complete(self, phone: str) -> tuple[str, str]:
|
||||||
|
"""
|
||||||
|
发送订单完成短信
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self._init_sms_client()
|
||||||
|
|
||||||
|
# 构建请求
|
||||||
|
req = sms_models.SendSmsRequest()
|
||||||
|
req.SmsSdkAppId = settings.SMS_SDK_APP_ID
|
||||||
|
req.SignName = settings.SMS_SIGN_NAME
|
||||||
|
req.TemplateId = settings.SMS_TEMPLATE_ID_ORDER_COMPLETE
|
||||||
|
req.PhoneNumberSet = [f"+86{phone}"]
|
||||||
|
|
||||||
|
# 发送短信
|
||||||
|
response = self.sms_client.SendSms(req)
|
||||||
|
|
||||||
|
# 检查发送结果
|
||||||
|
if response.SendStatusSet[0].Code != "Ok":
|
||||||
|
raise Exception(response.SendStatusSet[0].Message)
|
||||||
|
|
||||||
|
return response.RequestId
|
||||||
|
|
||||||
|
except TencentCloudSDKException as e:
|
||||||
|
raise Exception(f"发送订单完成短信失败: {str(e)}")
|
||||||
|
|
||||||
async def send_sms_code_additional_fee(self, phone: str) -> tuple[str, str]:
|
async def send_sms_code_additional_fee(self, phone: str) -> tuple[str, str]:
|
||||||
"""
|
"""
|
||||||
发送加价短信验证码
|
发送加价短信验证码
|
||||||
|
|||||||
@ -4,7 +4,7 @@ from typing import List, Dict, Union, Optional
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from app.core.utils import CommonUtils
|
from app.core.utils import CommonUtils
|
||||||
from app.models.order import OrderStatus
|
from app.models.order import OrderStatus
|
||||||
from app.models.order import ShippingOrderDB
|
from app.models.order import OrderInfo
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from app.models.community import CommunityDB
|
from app.models.community import CommunityDB
|
||||||
from app.models.merchant_complaint import MerchantComplaintDB
|
from app.models.merchant_complaint import MerchantComplaintDB
|
||||||
@ -195,7 +195,7 @@ class WecomBot:
|
|||||||
logging.exception(f"发送企业微信消息失败: {str(e)}")
|
logging.exception(f"发送企业微信消息失败: {str(e)}")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
async def send_order_notification(self,db: Session, shipping_order: ShippingOrderDB, notify_type: OrderStatus = OrderStatus.CREATED) -> bool:
|
async def send_order_notification(self,db: Session, shipping_order: OrderInfo, notify_type: OrderStatus = OrderStatus.CREATED) -> bool:
|
||||||
"""
|
"""
|
||||||
发送订单通知
|
发送订单通知
|
||||||
|
|
||||||
|
|||||||
BIN
jobs.sqlite
BIN
jobs.sqlite
Binary file not shown.
Loading…
Reference in New Issue
Block a user