From 4550a10489742bab4886bc3d28388e0c016c49c8 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Sat, 8 Mar 2025 13:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=9D=BF=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/order_additional_fee.py | 19 +++++++++++++++++++ app/core/config.py | 2 ++ app/core/qwen_client.py | 1 + 3 files changed, 22 insertions(+) diff --git a/app/api/endpoints/order_additional_fee.py b/app/api/endpoints/order_additional_fee.py index c6723c7..528d5cf 100644 --- a/app/api/endpoints/order_additional_fee.py +++ b/app/api/endpoints/order_additional_fee.py @@ -17,11 +17,14 @@ from datetime import datetime import aiohttp from app.core.config import settings from app.core.qcloud import qcloud_manager +from fastapi import BackgroundTasks +from app.core.mpmessage import sent_order_status_change_message router = APIRouter() @router.post("", response_model=ResponseModel) async def create_additional_fee_request( + background_tasks: BackgroundTasks, fee_request: OrderAdditionalFeeCreate, db: Session = Depends(get_db), deliveryman: UserDB = Depends(get_deliveryman_user) @@ -65,9 +68,25 @@ async def create_additional_fee_request( db.commit() db.refresh(db_fee_request) + # 发送通知给用户 user = db.query(UserDB).filter(UserDB.userid == order.userid).first() if user: await qcloud_manager.send_sms_code_additional_fee(user.phone) + + if user.mp_openid: + #发送模板消息 + data={ + "character_string1": fee_request.orderid, + "thing2": deliveryman.nickname, + "time3": datetime.now().strftime("%Y-%m-%d %H:%M:%S") + } + background_tasks.add_task( + sent_order_status_change_message, + openid=user.mp_openid, + template_id=settings.ADDITIONAL_FEE_REQUEST_TEMPLATE_ID, + data=data, + orderid=fee_request.orderid + ) return success_response(data=OrderAdditionalFeeInfo.model_validate(db_fee_request)) except Exception as e: diff --git a/app/core/config.py b/app/core/config.py index ea262ec..664f259 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -99,6 +99,8 @@ class Settings(BaseSettings): DELIVERY_ORDER_COMPLETED_TEMPLATE_ID: str = "eR7UlBRWRXEuQdVNNU6AB0MkkRwMKyUspBLyK7bFYyI" #配送订单取消 DELIVERY_ORDER_CANCELLED_TEMPLATE_ID: str = "iGR0rPtOFC_u8Xj5-R730zoDD_4Kbswkf_jSTnSSd6E" + # 加价请求 + ADDITIONAL_FEE_REQUEST_TEMPLATE_ID: str = "oGOuil8q1vSXiIyzJ14ExSOSptVgE4A-b7WSmmGqiRw" # 反馈需求企业微信 FEEDBACK_NEED_WECOM_BOT_WEBHOOK_URL: str = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ccd6e8d4-4c8a-45b4-9b6b-dd4cae563176" diff --git a/app/core/qwen_client.py b/app/core/qwen_client.py index a1aa2ec..e758546 100644 --- a/app/core/qwen_client.py +++ b/app/core/qwen_client.py @@ -74,6 +74,7 @@ class QwenClient: try: output = response.output + print(f"千问output: {output}") if output: choices = output.get('choices', []) if choices and len(choices) > 0: